From 25fefcd4b04ba6909d2db583c4cbe267aa5fbc2f Mon Sep 17 00:00:00 2001 From: rakow Date: Tue, 10 Oct 2023 17:41:39 +0200 Subject: [PATCH 01/25] add CustomRebalancingStrategyParams for rebalancing strategies bound by the user (#2832) --- .../CustomRebalancingStrategyParams.java | 33 +++++++++++++++++++ .../rebalancing/RebalancingModule.java | 2 ++ .../rebalancing/RebalancingParams.java | 3 ++ 3 files changed, 38 insertions(+) create mode 100644 contribs/drt/src/main/java/org/matsim/contrib/drt/optimizer/rebalancing/CustomRebalancingStrategyParams.java diff --git a/contribs/drt/src/main/java/org/matsim/contrib/drt/optimizer/rebalancing/CustomRebalancingStrategyParams.java b/contribs/drt/src/main/java/org/matsim/contrib/drt/optimizer/rebalancing/CustomRebalancingStrategyParams.java new file mode 100644 index 00000000000..266229bc349 --- /dev/null +++ b/contribs/drt/src/main/java/org/matsim/contrib/drt/optimizer/rebalancing/CustomRebalancingStrategyParams.java @@ -0,0 +1,33 @@ +/* *********************************************************************** * + * project: org.matsim.* + * *********************************************************************** * + * * + * copyright : (C) 2023 by the members listed in the COPYING, * + * LICENSE and WARRANTY file. * + * email : info at matsim dot org * + * * + * *********************************************************************** * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * See also COPYING, LICENSE and WARRANTY file * + * * + * *********************************************************************** */ + +package org.matsim.contrib.drt.optimizer.rebalancing; + +import org.matsim.core.config.ReflectiveConfigGroup; + +/** + * Custom rebalancing strategy parameters. User is responsible for installing rebalancing module and parameters. + */ +public final class CustomRebalancingStrategyParams extends ReflectiveConfigGroup + implements RebalancingParams.RebalancingStrategyParams { + public static final String SET_NAME = "CustomRebalancingStrategy"; + + public CustomRebalancingStrategyParams() { + super(SET_NAME); + } +} diff --git a/contribs/drt/src/main/java/org/matsim/contrib/drt/optimizer/rebalancing/RebalancingModule.java b/contribs/drt/src/main/java/org/matsim/contrib/drt/optimizer/rebalancing/RebalancingModule.java index a263bca4e35..b9c008bc3a1 100644 --- a/contribs/drt/src/main/java/org/matsim/contrib/drt/optimizer/rebalancing/RebalancingModule.java +++ b/contribs/drt/src/main/java/org/matsim/contrib/drt/optimizer/rebalancing/RebalancingModule.java @@ -54,6 +54,8 @@ public void install() { install(new DrtModePlusOneRebalanceModule(drtCfg)); } else if (rebalancingParams.getRebalancingStrategyParams() instanceof FeedforwardRebalancingStrategyParams) { install(new DrtModeFeedforwardRebalanceModule(drtCfg)); + } else if (rebalancingParams.getRebalancingStrategyParams() instanceof CustomRebalancingStrategyParams) { + // User is responsible for installing custom module } else { throw new RuntimeException( "Unsupported rebalancingStrategyParams: " + rebalancingParams.getRebalancingStrategyParams()); diff --git a/contribs/drt/src/main/java/org/matsim/contrib/drt/optimizer/rebalancing/RebalancingParams.java b/contribs/drt/src/main/java/org/matsim/contrib/drt/optimizer/rebalancing/RebalancingParams.java index 09c826427c4..07b422912d9 100644 --- a/contribs/drt/src/main/java/org/matsim/contrib/drt/optimizer/rebalancing/RebalancingParams.java +++ b/contribs/drt/src/main/java/org/matsim/contrib/drt/optimizer/rebalancing/RebalancingParams.java @@ -79,6 +79,9 @@ private void initSingletonParameterSets() { addDefinition(PlusOneRebalancingStrategyParams.SET_NAME, PlusOneRebalancingStrategyParams::new, () -> (ConfigGroup)rebalancingStrategyParams, params -> rebalancingStrategyParams = (RebalancingStrategyParams)params); + addDefinition(CustomRebalancingStrategyParams.SET_NAME, CustomRebalancingStrategyParams::new, + () -> (ConfigGroup)rebalancingStrategyParams, + params -> rebalancingStrategyParams = (RebalancingStrategyParams)params); } @Override From 2656089928f364678fcd5cf46ff2ef35c0ccf612 Mon Sep 17 00:00:00 2001 From: u229187 Date: Wed, 11 Oct 2023 13:33:38 +0200 Subject: [PATCH 02/25] Improve behavior of pt routing where only intermodal routes are found. --- .../config/SwissRailRaptorConfigGroup.java | 55 +++++- .../routing/pt/raptor/RaptorStaticConfig.java | 15 +- .../matsim/routing/pt/raptor/RaptorUtils.java | 21 +-- .../routing/pt/raptor/SwissRailRaptor.java | 42 +++-- .../pt/raptor/SwissRailRaptorCore.java | 59 +++--- .../raptor/SwissRailRaptorIntermodalTest.java | 172 +++++++++++------- .../pt/raptor/SwissRailRaptorTest.java | 9 +- 7 files changed, 240 insertions(+), 133 deletions(-) diff --git a/matsim/src/main/java/ch/sbb/matsim/config/SwissRailRaptorConfigGroup.java b/matsim/src/main/java/ch/sbb/matsim/config/SwissRailRaptorConfigGroup.java index 024a101002e..f0e18a1e410 100644 --- a/matsim/src/main/java/ch/sbb/matsim/config/SwissRailRaptorConfigGroup.java +++ b/matsim/src/main/java/ch/sbb/matsim/config/SwissRailRaptorConfigGroup.java @@ -45,6 +45,8 @@ public class SwissRailRaptorConfigGroup extends ReflectiveConfigGroup { private static final String PARAM_TRANSFER_WALK_MARGIN = "transferWalkMargin"; private static final String PARAM_TRANSFER_WALK_MARGIN_DESC = "time deducted from transfer walk leg during transfers between pt legs in order to avoid missing a vehicle by a few seconds due to delays."; + private static final String PARAM_INTERMODAL_LEG_ONLYHANDLING = "intermodalLegOnlyHandling"; + private static final String PARAM_INTERMODAL_LEG_ONLYHANDLING_DESC = "Define how routes containing only intermodal legs are handled: Useful options: alllow, avoid, forbid"; private boolean useRangeQuery = false; private boolean useIntermodality = false; @@ -57,6 +59,7 @@ public class SwissRailRaptorConfigGroup extends ReflectiveConfigGroup { private double transferPenaltyMaxCost = Double.POSITIVE_INFINITY; private double transferPenaltyHourlyCost = 0; private double transferWalkMargin = 5; + private IntermodalLegOnlyHandling intermodalLegOnlyHandling = IntermodalLegOnlyHandling.forbid; private ScoringParameters scoringParameters = ScoringParameters.Default; @@ -69,7 +72,27 @@ public class SwissRailRaptorConfigGroup extends ReflectiveConfigGroup { public enum IntermodalAccessEgressModeSelection { CalcLeastCostModePerStop, RandomSelectOneModePerRoutingRequestAndDirection } - + + public enum IntermodalLegOnlyHandling { + /** + * allows transit routes that only consist of intermodal feeder legs if these have the lowest cost. + */ + allow, + /** + * avoids transit routes that only consist of feeder routes, unless no route containing at least one pt leg is found + */ + avoid, + /** + * explicitly forbids such routes, tries to find a pt route and returns null if nothing is found + */ + forbid, + /** + * mimics the behaviour implemented between 2019 and 2023. Returns null if a purely intermodal route has the lowest cost, does not check if a real pt route exists. + */ + @Deprecated + returnNull + } + public enum ScoringParameters { Default, Individual } @@ -78,7 +101,24 @@ public SwissRailRaptorConfigGroup() { super(GROUP); } - @StringGetter(PARAM_USE_RANGE_QUERY) + @StringSetter(PARAM_INTERMODAL_LEG_ONLYHANDLING) + public void setIntermodalLegOnlyHandling(String intermodalLegOnlyHandling) { + this.intermodalLegOnlyHandling = IntermodalLegOnlyHandling.valueOf(intermodalLegOnlyHandling); + } + public void setIntermodalLegOnlyHandling(IntermodalLegOnlyHandling intermodalLegOnlyHandling) { + this.intermodalLegOnlyHandling = intermodalLegOnlyHandling; + } + + @StringGetter(PARAM_INTERMODAL_LEG_ONLYHANDLING) + public String getIntermodalLegOnlyHandlingString() { + return intermodalLegOnlyHandling.toString(); + } + + public IntermodalLegOnlyHandling getIntermodalLegOnlyHandling() { + return intermodalLegOnlyHandling; + } + + @StringGetter(PARAM_USE_RANGE_QUERY) public boolean isUseRangeQuery() { return this.useRangeQuery; } @@ -284,7 +324,8 @@ public Collection getModeMappingForPasseng return this.modeMappingForPassengersByRouteMode.values(); } - public static class RangeQuerySettingsParameterSet extends ReflectiveConfigGroup { + + public static class RangeQuerySettingsParameterSet extends ReflectiveConfigGroup { private static final String TYPE = "rangeQuerySettings"; @@ -459,7 +500,7 @@ public IntermodalAccessEgressParameterSet setMaxRadius(double maxRadius) { this.maxRadius = maxRadius; return this ; } - + @StringGetter(PARAM_INITIAL_SEARCH_RADIUS) public double getInitialSearchRadius() { return initialSearchRadius; @@ -470,7 +511,7 @@ public IntermodalAccessEgressParameterSet setInitialSearchRadius(double initialS this.initialSearchRadius = initialSearchRadius; return this ; } - + @StringGetter(PARAM_SEARCH_EXTENSION_RADIUS) public double getSearchExtensionRadius() { return searchExtensionRadius; @@ -536,7 +577,7 @@ public IntermodalAccessEgressParameterSet setStopFilterValue(String stopFilterVa this.stopFilterValue = stopFilterValue; return this ; } - + @StringGetter(PARAM_SHARE_TRIP_SEARCH_RADIUS) public double getShareTripSearchRadius() { return shareTripSearchRadius; @@ -560,7 +601,7 @@ public Map getComments() { map.put(PARAM_INITIAL_SEARCH_RADIUS, "Radius from the origin / destination coord in which transit stops are searched. Only if less than 2 transit stops are found the search radius is increased step-wise until the maximum search radius set in param radius is reached."); map.put(PARAM_SEARCH_EXTENSION_RADIUS, "If less than 2 stops were found in initialSearchRadius take the distance of the closest transit stop and add this extension radius to search again.The search radius will not exceed the maximum search radius set in param radius. Default is 200 meters."); map.put(PARAM_SHARE_TRIP_SEARCH_RADIUS, "The share of the trip crowfly distance within which the stops for access and egress will be searched for. This is a harder constraint than initial search radius. Default is positive infinity."); - + return map; } } diff --git a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/RaptorStaticConfig.java b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/RaptorStaticConfig.java index 64f9f556028..162ac694962 100644 --- a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/RaptorStaticConfig.java +++ b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/RaptorStaticConfig.java @@ -4,6 +4,8 @@ package ch.sbb.matsim.routing.pt.raptor; +import ch.sbb.matsim.config.SwissRailRaptorConfigGroup; + import java.util.HashMap; import java.util.Map; @@ -29,7 +31,8 @@ public enum RaptorOptimization { */ OneToAllRouting } - /** + + /** * The distance in meters that agents can walk to get from one stop to * another stop of a nearby transit line. */ @@ -47,6 +50,8 @@ public enum RaptorOptimization { private RaptorOptimization optimization = RaptorOptimization.OneToOneRouting; + private SwissRailRaptorConfigGroup.IntermodalLegOnlyHandling intermodalLegOnlyHandling = SwissRailRaptorConfigGroup.IntermodalLegOnlyHandling.forbid; + public double getBeelineWalkConnectionDistance() { return this.beelineWalkConnectionDistance; } @@ -118,4 +123,12 @@ public RaptorOptimization getOptimization() { public void setOptimization(RaptorOptimization optimization) { this.optimization = optimization; } + + public SwissRailRaptorConfigGroup.IntermodalLegOnlyHandling getIntermodalLegOnlyHandling() { + return intermodalLegOnlyHandling; + } + + public void setIntermodalLegOnlyHandling(SwissRailRaptorConfigGroup.IntermodalLegOnlyHandling intermodalLegOnlyHandling) { + this.intermodalLegOnlyHandling = intermodalLegOnlyHandling; + } } diff --git a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/RaptorUtils.java b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/RaptorUtils.java index 199b8be1096..5dbe0c60bd5 100644 --- a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/RaptorUtils.java +++ b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/RaptorUtils.java @@ -41,13 +41,13 @@ public static RaptorStaticConfig createStaticConfig(Config config) { RaptorStaticConfig staticConfig = new RaptorStaticConfig(); - staticConfig.setBeelineWalkConnectionDistance(config.transitRouter().getMaxBeelineWalkConnectionDistance()); - - PlansCalcRouteConfigGroup.TeleportedModeParams walk = pcrConfig.getModeRoutingParams().get(TransportMode.walk ); - staticConfig.setBeelineWalkSpeed(walk.getTeleportedModeSpeed() / walk.getBeelineDistanceFactor()); - staticConfig.setBeelineWalkDistanceFactor(walk.getBeelineDistanceFactor()); - staticConfig.setTransferWalkMargin(srrConfig.getTransferWalkMargin()); - staticConfig.setMinimalTransferTime(config.transitRouter().getAdditionalTransferTime()); + staticConfig.setBeelineWalkConnectionDistance(config.transitRouter().getMaxBeelineWalkConnectionDistance()); + PlansCalcRouteConfigGroup.TeleportedModeParams walk = pcrConfig.getModeRoutingParams().get(TransportMode.walk ); + staticConfig.setBeelineWalkSpeed(walk.getTeleportedModeSpeed() / walk.getBeelineDistanceFactor()); + staticConfig.setBeelineWalkDistanceFactor(walk.getBeelineDistanceFactor()); + staticConfig.setTransferWalkMargin(srrConfig.getTransferWalkMargin()); + staticConfig.setIntermodalLegOnlyHandling(srrConfig.getIntermodalLegOnlyHandling()); + staticConfig.setMinimalTransferTime(config.transitRouter().getAdditionalTransferTime()); staticConfig.setUseModeMappingForPassengers(srrConfig.isUseModeMappingForPassengers()); if (srrConfig.isUseModeMappingForPassengers()) { @@ -81,7 +81,7 @@ public static RaptorParameters createParameters(Config config) { double marginalUtility_utl_s = modeParams.getMarginalUtilityOfTraveling()/3600.0 - marginalUtilityPerforming; raptorParams.setMarginalUtilityOfTravelTime_utl_s(mode, marginalUtility_utl_s); } - + double costPerHour = advancedConfig.getTransferPenaltyCostPerTravelTimeHour(); if (costPerHour == 0.0) { // for backwards compatibility, use the default utility of line switch. @@ -104,9 +104,8 @@ public static List convertRouteToLegs(RaptorRoute route, for (RaptorRoute.RoutePart part : route.parts) { if (part.planElements != null) { for (PlanElement pe : part.planElements) { - if (pe instanceof Leg) { - Leg leg = (Leg) pe; - legs.add(leg); + if (pe instanceof Leg leg) { + legs.add(leg); if (leg.getDepartureTime().isUndefined()) { leg.setDepartureTime(lastArrivalTime); } diff --git a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptor.java b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptor.java index d83df73f7c4..284126758df 100644 --- a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptor.java +++ b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptor.java @@ -67,7 +67,7 @@ public List calcRoute(RoutingRequest request) { final double departureTime = request.getDepartureTime(); final Person person = request.getPerson(); final Attributes routingAttributes = request.getAttributes(); - + RaptorParameters parameters = this.parametersForPerson.getRaptorParameters(person); if (parameters.getConfig().isUseRangeQuery()) { return this.performRangeQuery(fromFacility, toFacility, departureTime, person, routingAttributes, parameters); @@ -83,11 +83,11 @@ public List calcRoute(RoutingRequest request) { * compatibility, but leads to many trips with only a single "transit_walk" leg which are then considered pt * trips by the main mode identifier even though they do not contain any pt leg and should rather be considered * "walk" trips. - * + * * That problem can be avoided by setting a very high direct walk factor in TransitRouterConfigGroup. However * this should be combined with enabling mode choice for pt and walk trips such that slow pt trips can be * replaced by (faster) walk trips by mode choice. Otherwise agents can be stuck with very slow pt trips. - * + * * Comparison is only made between a pt trip and a direct walk trip, other modes (e.g. intermodal access/egress * modes) are not considered. If they had been considered here, the router would effectively be a mode choice * module although it is supposed not to change mode choice but rather to simply return a route for a given @@ -97,32 +97,39 @@ public List calcRoute(RoutingRequest request) { * always chose a direct drt trip over the pt trip, because the router might consistently underestimate drt * travel time). So it seems a bad idea to compare other modes than walk here. Walk is usually teleported at a * fixed speed, so it is usually completely deterministic whereas other modes are not. - * - * Overall enabling mode choice and setting a very high direct walk factor (e.g. Double.POSITIVE_INFINITY which + * + * Overall enabling mode choice and setting a very high direct walk factor (e.g. Double.POSITIVE_INFINITY which * effectively excludes all direct walks) seems cleaner and better. - * + * * vsp-gleich sep'19 (after talking with KN) - * - * + * + * * foundRoute.parts.size() == 0 can happen if SwissRasilRaptorCore.createRaptorRoute() finds a trip made up of, * only 2 parts which consists only of an access and an egress leg without any pt leg inbetween. */ - if (foundRoute == null || foundRoute.parts.size() == 0 || hasNoPtLeg(foundRoute.parts)) { + if (directWalk.getTotalCosts() * parameters.getDirectWalkFactor() < foundRoute.getTotalCosts()) { + foundRoute = directWalk; + } + boolean forbidPurelyIntermodalRoutes = data.config.getIntermodalLegOnlyHandling().equals(SwissRailRaptorConfigGroup.IntermodalLegOnlyHandling.forbid) || data.config.getIntermodalLegOnlyHandling().equals(SwissRailRaptorConfigGroup.IntermodalLegOnlyHandling.returnNull); + if (foundRoute == null || (foundRoute.parts.size() == 0 && forbidPurelyIntermodalRoutes)) { if (person == null) { log.debug("No route found for person null: trip from x=" + fromFacility.getCoord().getX() + ",y=" + fromFacility.getCoord().getY() + " departure at " + departureTime + " to x=" + toFacility.getCoord().getX() + ",y=" + toFacility.getCoord().getY()); } else { log.debug("No route found for person " + person.getId() + ": trip from x=" + fromFacility.getCoord().getX() + ",y=" + fromFacility.getCoord().getY() + " departure at " + departureTime + " to x=" + toFacility.getCoord().getX() + ",y=" + toFacility.getCoord().getY()); } - return null; - } - if (directWalk.getTotalCosts() * parameters.getDirectWalkFactor() < foundRoute.getTotalCosts()) { - foundRoute = directWalk; + return null; } + else if ((hasNoPtLeg(foundRoute.parts))){ + if (forbidPurelyIntermodalRoutes){ + return null; + } + } + List legs = RaptorUtils.convertRouteToLegs(foundRoute, this.data.config.getTransferWalkMargin()); return legs; } - + private boolean hasNoPtLeg(List parts) { for (RoutePart part : parts) { // if the route part has a TransitLine, it must be a real pt leg @@ -142,10 +149,9 @@ private List performRangeQuery(Facility fromFacility, Fac double earliestDepartureTime = desiredDepartureTime - rangeSettings.getMaxEarlierDeparture(); double latestDepartureTime = desiredDepartureTime + rangeSettings.getMaxLaterDeparture(); - if (this.defaultRouteSelector instanceof ConfigurableRaptorRouteSelector) { - ConfigurableRaptorRouteSelector selector = (ConfigurableRaptorRouteSelector) this.defaultRouteSelector; + if (this.defaultRouteSelector instanceof ConfigurableRaptorRouteSelector selector) { - SwissRailRaptorConfigGroup.RouteSelectorParameterSet params = srrConfig.getRouteSelector(subpopulation); + SwissRailRaptorConfigGroup.RouteSelectorParameterSet params = srrConfig.getRouteSelector(subpopulation); selector.setBetaTransfer(params.getBetaTransfers()); selector.setBetaTravelTime(params.getBetaTravelTime()); @@ -174,7 +180,7 @@ public List calcRoute(Facility fromFacility, Facility toF } else { log.debug("No route found for person " + person.getId() + ": trip from x=" + fromFacility.getCoord().getX() + ",y=" + fromFacility.getCoord().getY() + " departure at " + desiredDepartureTime + " to x=" + toFacility.getCoord().getX() + ",y=" + toFacility.getCoord().getY()); } - return null; + return null; } if (directWalk.getTotalCosts() * parameters.getDirectWalkFactor() < foundRoute.getTotalCosts()) { foundRoute = directWalk; diff --git a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorCore.java b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorCore.java index adca5d074ed..fa8ebb19a04 100644 --- a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorCore.java +++ b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorCore.java @@ -4,6 +4,7 @@ package ch.sbb.matsim.routing.pt.raptor; +import ch.sbb.matsim.config.SwissRailRaptorConfigGroup; import ch.sbb.matsim.routing.pt.raptor.OccupancyData.DepartureData; import ch.sbb.matsim.routing.pt.raptor.RaptorInVehicleCostCalculator.RouteSegmentIterator; import ch.sbb.matsim.routing.pt.raptor.SwissRailRaptorData.CachingTransferProvider; @@ -694,7 +695,7 @@ private int findNextDepartureIndex(RRoute route, RRouteStop routeStop, int time) if (this.useCapacityConstraints) { return findNextDepartureIndexWithConstraints(route, routeStop, time); } - int depTimeAtRouteStart = (int) (time - routeStop.departureOffset); + int depTimeAtRouteStart = time - routeStop.departureOffset; int fromIndex = route.indexFirstDeparture; int toIndex = fromIndex + route.countDepartures; int pos = Arrays.binarySearch(this.data.departures, fromIndex, toIndex, depTimeAtRouteStart); @@ -771,23 +772,45 @@ private void handleTransfers(boolean strict, RaptorParameters raptorParams) { private PathElement findLeastCostArrival(Map destinationStops) { double leastCost = Double.POSITIVE_INFINITY; + double leastCostFeederFeederOnly = Double.POSITIVE_INFINITY; PathElement leastCostPath = null; + PathElement leastCostPathFeederFeederOnly = null; - for (Map.Entry e : destinationStops.entrySet()) { + SwissRailRaptorConfigGroup.IntermodalLegOnlyHandling intermodalLegOnlyHandling = data.config.getIntermodalLegOnlyHandling(); + boolean checkBothPtAndPurelyIntermodalRoutes = intermodalLegOnlyHandling.equals(SwissRailRaptorConfigGroup.IntermodalLegOnlyHandling.avoid) || intermodalLegOnlyHandling.equals(SwissRailRaptorConfigGroup.IntermodalLegOnlyHandling.forbid); + for (Map.Entry e : destinationStops.entrySet()) { TransitStopFacility stop = e.getKey(); int stopIndex = this.data.stopFacilityIndices.get(stop); PathElement pe = this.arrivalPathPerStop[stopIndex]; - if (pe != null) { - InitialStop egressStop = e.getValue(); - int arrivalTime = (int) (pe.arrivalTime + egressStop.accessTime); - double arrivalTravelCost = pe.arrivalTravelCost + egressStop.accessCost; - double totalCost = arrivalTravelCost + pe.arrivalTransferCost; - if ((totalCost < leastCost) || (totalCost == leastCost && pe.transferCount < leastCostPath.transferCount)) { - leastCost = totalCost; - leastCostPath = new PathElement(pe, null, pe.firstDepartureTime, TIME_UNDEFINED, arrivalTime, arrivalTravelCost, pe.arrivalTransferCost, egressStop.distance, pe.transferCount, true, null, egressStop); // this is the egress leg - } - } + if (pe!=null) { + InitialStop egressStop = e.getValue(); + int arrivalTime = (int) (pe.arrivalTime + egressStop.accessTime); + double arrivalTravelCost = pe.arrivalTravelCost + egressStop.accessCost; + double totalCost = arrivalTravelCost + pe.arrivalTransferCost; + if ((totalCost < leastCost) || (totalCost == leastCost && pe.transferCount < leastCostPath.transferCount)) { + PathElement egressLegCandidate = new PathElement(pe, null, pe.firstDepartureTime, TIME_UNDEFINED, arrivalTime, arrivalTravelCost, pe.arrivalTransferCost, egressStop.distance, pe.transferCount, true, null, egressStop); + + if (pe.comingFrom == null && checkBothPtAndPurelyIntermodalRoutes) { + if (totalCost < leastCostFeederFeederOnly) { + leastCostFeederFeederOnly = totalCost; + leastCostPathFeederFeederOnly = egressLegCandidate; + } + } else { + // this is the egress leg + leastCostPath = egressLegCandidate; + leastCost = totalCost; + } + } + + } + } + + if (checkBothPtAndPurelyIntermodalRoutes){ + if (Double.isInfinite(leastCost)){ + return leastCostPathFeederFeederOnly; + } + } return leastCostPath; } @@ -803,18 +826,6 @@ private static RaptorRoute createRaptorRoute(Facility fromFacility, Facility toF } pes.addFirst(pe); } - if (pes.size() == 2 && pes.get(0).isTransfer && pes.get(1).isTransfer) { - // it's only access and egress, no real pt trip - arrivalCost = Double.POSITIVE_INFINITY; - pes.clear(); - } - - // yyyyyy I am having the following situation: - // * assume there is only one drt link. This happens when the pt trip is outside the service area, and then both the starting and the ending - // location are mapped to the same link. - // * In consequence, the trip becomes "access_walk_to_drt"---"egress_walk_to_drt" (*). However, the cost of that is set to infty here ... with the - // consequence that the raptor returns a "pure transit walk" later. - // I thought that you said that it would directly return (*). It would (I think) also be easier to debug. kai, jun'19 RaptorRoute raptorRoute = new RaptorRoute(fromFacility, toFacility, arrivalCost); double time = departureTime; diff --git a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorIntermodalTest.java b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorIntermodalTest.java index a171cf23f1c..7ec0a2f552c 100644 --- a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorIntermodalTest.java +++ b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorIntermodalTest.java @@ -27,11 +27,7 @@ import org.matsim.core.population.routes.GenericRouteImpl; import org.matsim.core.population.routes.NetworkRoute; import org.matsim.core.population.routes.RouteUtils; -import org.matsim.core.router.DefaultRoutingRequest; -import org.matsim.core.router.RoutingModule; -import org.matsim.core.router.RoutingRequest; -import org.matsim.core.router.TeleportationRoutingModule; -import org.matsim.core.router.TripRouter; +import org.matsim.core.router.*; import org.matsim.core.scenario.ScenarioUtils; import org.matsim.core.utils.geometry.CoordUtils; import org.matsim.facilities.Facility; @@ -43,7 +39,6 @@ import org.matsim.pt.transitSchedule.api.TransitSchedule; import org.matsim.pt.transitSchedule.api.TransitScheduleFactory; import org.matsim.pt.transitSchedule.api.TransitStopFacility; -import org.matsim.utils.objectattributes.attributable.Attributes; import org.matsim.utils.objectattributes.attributable.AttributesImpl; import java.util.ArrayList; @@ -135,7 +130,7 @@ public void testIntermodalTrip_TripRouterIntegration() { TripRouter.Builder tripRouterBuilder = new TripRouter.Builder(f.config) .setRoutingModule(TransportMode.walk, walkRoutingModule) .setRoutingModule(TransportMode.bike, bikeRoutingModule); - + TripRouter tripRouter = tripRouterBuilder.build(); f.srrConfig.setUseIntermodalAccessEgress(true); @@ -289,7 +284,7 @@ public void testIntermodalTrip_withoutPt() { Assert.assertNull("The router should not find a route and return null, but did return something else.", legs); } - + @Test public void testDirectWalkFactor() { IntermodalFixture f = new IntermodalFixture(); @@ -309,7 +304,6 @@ public void testDirectWalkFactor() { new TeleportationRoutingModule(TransportMode.walk, f.scenario, 1.1, 1.3)); routingModules.put(TransportMode.bike, new TeleportationRoutingModule(TransportMode.bike, f.scenario, 3.0, 1.4)); - f.srrConfig.setUseIntermodalAccessEgress(true); IntermodalAccessEgressParameterSet walkAccess = new IntermodalAccessEgressParameterSet(); walkAccess.setMode(TransportMode.walk); @@ -326,10 +320,10 @@ public void testDirectWalkFactor() { bikeAccess.setLinkIdAttribute("accessLinkId_bike"); bikeAccess.setStopFilterValue("true"); f.srrConfig.addIntermodalAccessEgress(bikeAccess); - + f.srrConfig.setIntermodalLegOnlyHandling(SwissRailRaptorConfigGroup.IntermodalLegOnlyHandling.avoid); Facility fromFac = new FakeFacility(new Coord(9000, 15000), Id.create("from", Link.class)); Facility toFac = new FakeFacility(new Coord(10500, 15000), Id.create("to", Link.class)); - + // direct walk factor off f.config.transitRouter().setDirectWalkFactor(1.0); SwissRailRaptorData data = SwissRailRaptorData.create(f.scenario.getTransitSchedule(), null, RaptorUtils.createStaticConfig(f.config), f.scenario.getNetwork(), null); @@ -346,7 +340,7 @@ public void testDirectWalkFactor() { Assert.assertEquals(TransportMode.walk, leg.getMode()); Assert.assertEquals(Id.create("from", Link.class), leg.getRoute().getStartLinkId()); Assert.assertEquals(Id.create("to", Link.class), leg.getRoute().getEndLinkId()); - + // direct walk factor on f.config.transitRouter().setDirectWalkFactor(Double.POSITIVE_INFINITY); data = SwissRailRaptorData.create(f.scenario.getTransitSchedule(), null, RaptorUtils.createStaticConfig(f.config), f.scenario.getNetwork(), null); @@ -380,13 +374,13 @@ public void testDirectWalkFactor() { Assert.assertEquals(Id.create("bike_3", Link.class), leg.getRoute().getStartLinkId()); Assert.assertEquals(Id.create("to", Link.class), leg.getRoute().getEndLinkId()); } - + @Test public void testAccessEgressModeFasterThanPt() { IntermodalFixture f = new IntermodalFixture(); - /* - * setDirectWalkFactor(Double.POSITIVE_INFINITY) leads to the case where in SwissRailRaptor.calcRoute() both the found - * route and the direct walk have cost infinity, so if we would not check for the found route to have at least one + /* + * setDirectWalkFactor(Double.POSITIVE_INFINITY) leads to the case where in SwissRailRaptor.calcRoute() both the found + * route and the direct walk have cost infinity, so if we would not check for the found route to have at least one * RoutePart, the router would return 0 legs. */ f.config.transitRouter().setDirectWalkFactor(Double.POSITIVE_INFINITY); @@ -423,16 +417,58 @@ public void testAccessEgressModeFasterThanPt() { Facility fromFac = new FakeFacility(new Coord(10000, 10500), Id.create("from", Link.class)); Facility toFac = new FakeFacility(new Coord(10500, 10500), Id.create("to", Link.class)); - List legs = raptor.calcRoute(DefaultRoutingRequest.withoutAttributes(fromFac, toFac, 7*3600, f.dummyPerson)); - - /* - * Going by access/egress mode bike from "fromFac" to stop 3 (which is bikeAccessible) and from there by bike - * to the destination is faster than any alternative including pt (because bike is extremely fast in this test). - * Therefore, the raptor returns as fastest path a v-shaped bike trip from the fromFac via stop 3 to the toFac, - * alternatives including pt are not found. This should be caught by SwissRailRaptor and it should return null. - */ - Assert.assertNull("The router should not find a route and return null, but did return something else.", legs); - } + //both directly 10000 metres from stop[3] + Facility fromFac2 = new FakeFacility(new Coord(10500, 20000), Id.create("from2", Link.class)); + Facility toFac2 = new FakeFacility(new Coord(10500, 0), Id.create("to2", Link.class)); + + + /* + * Going by access/egress mode bike from "fromFac" to stop 3 (which is bikeAccessible) and from there by bike + * to the destination is faster than any alternative including pt (because bike is extremely fast in this test). + * Therefore, the raptor returns as fastest path a v-shaped bike trip from the fromFac via stop 3 to the toFac, + * alternatives including pt are not found. Depending on the setting of intermodal legs, different outcomes should be expected. + */ + + //returnNull + data.config.setIntermodalLegOnlyHandling(SwissRailRaptorConfigGroup.IntermodalLegOnlyHandling.returnNull); + List legs = raptor.calcRoute(DefaultRoutingRequest.withoutAttributes(fromFac, toFac, 7*3600, f.dummyPerson)); + Assert.assertNull("The router should not find a route and return null, but did return something else.", legs); + + legs = raptor.calcRoute(DefaultRoutingRequest.withoutAttributes(fromFac2, toFac2, 7*3600, f.dummyPerson)); + Assert.assertNull("The router should not find a route and return null, but did return something else.", legs); + + //forbid + data.config.setIntermodalLegOnlyHandling(SwissRailRaptorConfigGroup.IntermodalLegOnlyHandling.forbid); + legs = raptor.calcRoute(DefaultRoutingRequest.withoutAttributes(fromFac, toFac, 7*3600, f.dummyPerson)); + Assert.assertNotNull("The router should find a pt route and not return null, but did return null", legs); + Assert.assertTrue( legs.stream().filter(Leg.class::isInstance).anyMatch(planElement -> ((Leg) planElement).getMode().equals(TransportMode.pt))); + + legs = raptor.calcRoute(DefaultRoutingRequest.withoutAttributes(fromFac2, toFac2, 7*3600, f.dummyPerson)); + Assert.assertNull("The router should not find a pt route and return null, but did return something else", legs); + + //avoid + data.config.setIntermodalLegOnlyHandling(SwissRailRaptorConfigGroup.IntermodalLegOnlyHandling.avoid); + legs = raptor.calcRoute(DefaultRoutingRequest.withoutAttributes(fromFac, toFac, 7*3600, f.dummyPerson)); + Assert.assertNotNull("The router should find a pt route and not return null, but did return null", legs); + Assert.assertTrue( legs.stream().filter(Leg.class::isInstance).anyMatch(planElement -> ((Leg) planElement).getMode().equals(TransportMode.pt))); + + legs = raptor.calcRoute(DefaultRoutingRequest.withoutAttributes(fromFac2, toFac2, 7*3600, f.dummyPerson)); + Assert.assertNotNull("The router should find a pt route and not return null, but did return null", legs); + Assert.assertFalse( legs.stream().filter(Leg.class::isInstance).anyMatch(planElement -> ((Leg) planElement).getMode().equals(TransportMode.pt))); + + //allow + data.config.setIntermodalLegOnlyHandling(SwissRailRaptorConfigGroup.IntermodalLegOnlyHandling.allow); + legs = raptor.calcRoute(DefaultRoutingRequest.withoutAttributes(fromFac, toFac, 7*3600, f.dummyPerson)); + Assert.assertFalse( legs.stream().filter(Leg.class::isInstance).anyMatch(planElement -> ((Leg) planElement).getMode().equals(TransportMode.pt))); + Assert.assertNotNull("The router should find a pt route and not return null, but did return something else.", legs); + + legs = raptor.calcRoute(DefaultRoutingRequest.withoutAttributes(fromFac2, toFac2, 7*3600, f.dummyPerson)); + Assert.assertNotNull("The router should find a pt route and not return null, but did return null", legs); + Assert.assertFalse( legs.stream().filter(Leg.class::isInstance).anyMatch(planElement -> ((Leg) planElement).getMode().equals(TransportMode.pt))); + + } + + @Test public void testIntermodalTrip_competingAccess() { @@ -623,7 +659,7 @@ else if ((((Leg)(legs.get(0))).getMode().equals(TransportMode.bike)) && (((Leg)l Assert.assertTrue(numWalkBike > 0); Assert.assertTrue(numBikeWalk > 0); Assert.assertTrue(numBikeBike > 0); - Assert.assertTrue(numOther == 0); + Assert.assertEquals(0, numOther); } } @@ -844,8 +880,8 @@ public void testIntermodalTrip_accessModeRouterReturnsNull() { Assert.assertEquals(TransportMode.walk, legAccess.getMode()); Assert.assertEquals("AA", legAccess.getRoute().getStartLinkId().toString()); Assert.assertEquals("to", legAccess.getRoute().getEndLinkId().toString()); - - + + // Part 2: Change bike router to return null. f.routingModules.remove(TransportMode.bike); f.routingModules.put(TransportMode.bike, @@ -855,7 +891,7 @@ public void testIntermodalTrip_accessModeRouterReturnsNull() { public List calcRoute(RoutingRequest request) { return null; } - + }); SwissRailRaptorData data2 = SwissRailRaptorData.create(f.scenario.getTransitSchedule(), null, RaptorUtils.createStaticConfig(f.config), f.scenario.getNetwork(), null); @@ -863,17 +899,17 @@ public List calcRoute(RoutingRequest request) { SwissRailRaptor raptor2 = new SwissRailRaptor.Builder(data2, f.scenario.getConfig()).with(stopFinder2).build(); List legs2 = raptor2.calcRoute(DefaultRoutingRequest.withoutAttributes(fromFac, toFac, 8 * 3600 - 900, f.dummyPerson)); - - Assert.assertNull("The router should not find a route and return null, but did return something else.", legs2); + + Assert.assertNull("The router should not find a route and return null, but did return something else.", legs2); } /** - * + * * The agent has a super-fast bike. So in theory it is faster to travel * from stop_3 to the destination. However, with the introduced trip share * constraint it will still take the closest stop accessible by the bike. - * If this constraint is not used the agent will take pt_3 stop as an + * If this constraint is not used the agent will take pt_3 stop as an * access stop to his final destination. - * + * */ @Test public void testIntermodalTrip_tripLengthShare() { @@ -941,7 +977,7 @@ public void testIntermodalTrip_tripLengthShare() { Assert.assertEquals(Id.create("bike_5", Link.class), leg.getRoute().getStartLinkId()); Assert.assertEquals(Id.create("to", Link.class), leg.getRoute().getEndLinkId()); } - + @Test public void testIntermodalTrip_activityInteraction() { double bikeInteractionDuration = 1.0; @@ -956,31 +992,31 @@ public void testIntermodalTrip_activityInteraction() { Map routingModules = new HashMap<>(); routingModules.put(TransportMode.walk, new TeleportationRoutingModule(TransportMode.walk, f.scenario, walkSpeed, 1.3)); - - + + routingModules.put(TransportMode.bike, new RoutingModule() { - + @Override public List calcRoute(RoutingRequest request) { final Facility fromFacility = request.getFromFacility(); final Facility toFacility = request.getToFacility(); final double departureTime = request.getDepartureTime(); - + Coord bikeCoord = CoordUtils.createCoord(9500, 10000); - + List allElements = new LinkedList<>(); // Create walk-out-of-building stage - + Leg leg = populationFactory.createLeg("walk"); leg.setDepartureTime(departureTime); double walkDistance = CoordUtils.calcEuclideanDistance(fromFacility.getCoord(), bikeCoord); - + leg.setTravelTime(walkDistance/walkSpeed); - + leg.setRoute(new GenericRouteImpl(fromFacility.getLinkId(), Id.createLinkId("pt_1"))); allElements.add(leg); - + // Create activity where the bike is pickedup Activity activity = populationFactory.createActivityFromLinkId("bike interaction", Id.createLinkId("pt_1")); activity.setStartTime(departureTime + walkDistance/walkSpeed); @@ -989,7 +1025,7 @@ public List calcRoute(RoutingRequest request) { // Route bike stage double distance = CoordUtils.calcEuclideanDistance(bikeCoord, toFacility.getCoord()); - + Leg bikeLeg = populationFactory.createLeg("bike"); bikeLeg.setDepartureTime(departureTime + bikeInteractionDuration + walkDistance/walkSpeed); bikeLeg.setTravelTime(distance/60.0); @@ -998,7 +1034,7 @@ public List calcRoute(RoutingRequest request) { return allElements; } }); - + f.srrConfig.setUseIntermodalAccessEgress(true); IntermodalAccessEgressParameterSet walkAccess = new IntermodalAccessEgressParameterSet(); @@ -1056,13 +1092,13 @@ public List calcRoute(RoutingRequest request) { Assert.assertEquals(Id.create("pt_5", Link.class), leg.getRoute().getStartLinkId()); Assert.assertEquals(Id.create("to", Link.class), leg.getRoute().getEndLinkId()); } - + /** - * + * * This test tests the intermodal router when access modes - * have interaction activities and it tests the inclusion of the + * have interaction activities and it tests the inclusion of the * pt interaction activities by the SwissRailRaptorRoutingModule - */ + */ @Test public void testIntermodalTrip_activityInteractionAdd() { double bikeInteractionDuration = 1.0; @@ -1077,31 +1113,31 @@ public void testIntermodalTrip_activityInteractionAdd() { Map routingModules = new HashMap<>(); routingModules.put(TransportMode.walk, new TeleportationRoutingModule(TransportMode.walk, f.scenario, walkSpeed, 1.3)); - - + + routingModules.put(TransportMode.bike, new RoutingModule() { - + @Override public List calcRoute(RoutingRequest request) { final Facility fromFacility = request.getFromFacility(); final Facility toFacility = request.getToFacility(); final double departureTime = request.getDepartureTime(); - + Coord bikeCoord = CoordUtils.createCoord(9500, 10000); - + List allElements = new LinkedList<>(); // Create walk-out-of-building stage - + Leg leg = populationFactory.createLeg("walk"); leg.setDepartureTime(departureTime); double walkDistance = CoordUtils.calcEuclideanDistance(fromFacility.getCoord(), bikeCoord); - + leg.setTravelTime(walkDistance/walkSpeed); - + leg.setRoute(new GenericRouteImpl(fromFacility.getLinkId(), Id.createLinkId("pt_1"))); allElements.add(leg); - + // Create activity where the bike is pickedup Activity activity = populationFactory.createActivityFromLinkId("bike interaction", Id.createLinkId("pt_1")); activity.setStartTime(departureTime + walkDistance/walkSpeed); @@ -1110,7 +1146,7 @@ public List calcRoute(RoutingRequest request) { // Route bike stage double distance = CoordUtils.calcEuclideanDistance(bikeCoord, toFacility.getCoord()); - + Leg bikeLeg = populationFactory.createLeg("bike"); bikeLeg.setDepartureTime(departureTime + bikeInteractionDuration + walkDistance/walkSpeed); bikeLeg.setTravelTime(distance/60.0); @@ -1119,7 +1155,7 @@ public List calcRoute(RoutingRequest request) { return allElements; } }); - + f.srrConfig.setUseIntermodalAccessEgress(true); IntermodalAccessEgressParameterSet walkAccess = new IntermodalAccessEgressParameterSet(); @@ -1183,8 +1219,8 @@ public List calcRoute(RoutingRequest request) { Assert.assertEquals(Id.create("pt_5", Link.class), leg.getRoute().getStartLinkId()); Assert.assertEquals(Id.create("to", Link.class), leg.getRoute().getEndLinkId()); } - - + + /* for test of intermodal routing requiring transfers at the beginning or end of the pt trip, * the normal IntermodalFixture does not work, so create a special mini scenario here. @@ -1371,12 +1407,12 @@ public IntermodalTransferFixture() { this.config.planCalcScore().getModes().get(TransportMode.bike).setMarginalUtilityOfTraveling(-8); this.config.transitRouter().setMaxBeelineWalkConnectionDistance(150); - + /* * Prior to non_network_walk the utilities of access_walk and egress_walk were set to 0 here. * non_network_walk replaced access_walk and egress_walk, so one might assume that now egress_walk should * have marginalUtilityOfTraveling = 0. - * + * * However, non_network_walk also replaces walk, so the alternative access leg by *_walk without any bike * leg is calculated based on marginalUtilityOfTraveling of non_network_walk. Setting * marginalUtilityOfTraveling = 0 obviously makes that alternative more attractive than any option with bike @@ -1385,8 +1421,8 @@ public IntermodalTransferFixture() { * bike (and access / egress transfer) are rather short and thereby have little influence on the total cost. * Furthermore, this is additional cost for the path including bike, so we are on the safe side with that * change. - gleich aug'19 - * - * Instead of TransportMode.non_network_walk we are now (after the introduction of routing mode) using + * + * Instead of TransportMode.non_network_walk we are now (after the introduction of routing mode) using * TransportMode.walk for access and egress to pt. */ PlanCalcScoreConfigGroup.ModeParams walk = new PlanCalcScoreConfigGroup.ModeParams(TransportMode.walk); diff --git a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorTest.java b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorTest.java index 08b16d83972..4eb2d0f01c5 100644 --- a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorTest.java +++ b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorTest.java @@ -202,7 +202,10 @@ public void testFromToSameStop() { public void testDirectWalkCheaper() { Fixture f = new Fixture(); f.init(); + SwissRailRaptorConfigGroup srrConfig = ConfigUtils.addOrGetModule(f.config,SwissRailRaptorConfigGroup.class); + srrConfig.setIntermodalLegOnlyHandling(SwissRailRaptorConfigGroup.IntermodalLegOnlyHandling.avoid); RaptorParameters raptorParams = RaptorUtils.createParameters(f.config); + TransitRouter router = createTransitRouter(f.schedule, f.config, f.network); Coord fromCoord = new Coord(4000, 3000); Coord toCoord = new Coord(8000, 3000); @@ -595,15 +598,13 @@ public void testLongTransferTime_withTransitRouterWrapper() { private static double calcTripDuration(List planElements) { double duration = 0.0; for (PlanElement pe : planElements) { - if (pe instanceof Activity) { - Activity act = (Activity)pe; + if (pe instanceof Activity act) { if (act.getStartTime().isDefined() && act.getEndTime().isDefined()) { double startTime = act.getStartTime().seconds(); double endTime = act.getEndTime().seconds(); duration += (endTime - startTime); } - } else if (pe instanceof Leg) { - Leg leg = (Leg) pe; + } else if (pe instanceof Leg leg) { duration += leg.getTravelTime().seconds(); } } From b0f87375716ee9090ea0b93c55f6a52d7e70e583 Mon Sep 17 00:00:00 2001 From: u229187 Date: Wed, 11 Oct 2023 14:14:32 +0200 Subject: [PATCH 03/25] rename variable --- .../routing/pt/raptor/SwissRailRaptorCore.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorCore.java b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorCore.java index fa8ebb19a04..fd7d0e5d0d6 100644 --- a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorCore.java +++ b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorCore.java @@ -772,9 +772,9 @@ private void handleTransfers(boolean strict, RaptorParameters raptorParams) { private PathElement findLeastCostArrival(Map destinationStops) { double leastCost = Double.POSITIVE_INFINITY; - double leastCostFeederFeederOnly = Double.POSITIVE_INFINITY; + double leastCostFeederOnly = Double.POSITIVE_INFINITY; PathElement leastCostPath = null; - PathElement leastCostPathFeederFeederOnly = null; + PathElement leastCostPathFeederOnly = null; SwissRailRaptorConfigGroup.IntermodalLegOnlyHandling intermodalLegOnlyHandling = data.config.getIntermodalLegOnlyHandling(); boolean checkBothPtAndPurelyIntermodalRoutes = intermodalLegOnlyHandling.equals(SwissRailRaptorConfigGroup.IntermodalLegOnlyHandling.avoid) || intermodalLegOnlyHandling.equals(SwissRailRaptorConfigGroup.IntermodalLegOnlyHandling.forbid); @@ -791,9 +791,9 @@ private PathElement findLeastCostArrival(Map d PathElement egressLegCandidate = new PathElement(pe, null, pe.firstDepartureTime, TIME_UNDEFINED, arrivalTime, arrivalTravelCost, pe.arrivalTransferCost, egressStop.distance, pe.transferCount, true, null, egressStop); if (pe.comingFrom == null && checkBothPtAndPurelyIntermodalRoutes) { - if (totalCost < leastCostFeederFeederOnly) { - leastCostFeederFeederOnly = totalCost; - leastCostPathFeederFeederOnly = egressLegCandidate; + if (totalCost < leastCostFeederOnly) { + leastCostFeederOnly = totalCost; + leastCostPathFeederOnly = egressLegCandidate; } } else { // this is the egress leg @@ -808,7 +808,7 @@ private PathElement findLeastCostArrival(Map d if (checkBothPtAndPurelyIntermodalRoutes){ if (Double.isInfinite(leastCost)){ - return leastCostPathFeederFeederOnly; + return leastCostPathFeederOnly; } } return leastCostPath; From 990e21d973eb0ec1241f961750c0976ed946dd8f Mon Sep 17 00:00:00 2001 From: u229187 Date: Wed, 11 Oct 2023 14:16:52 +0200 Subject: [PATCH 04/25] removing comment block --- .../routing/pt/raptor/SwissRailRaptor.java | 25 ------------------- 1 file changed, 25 deletions(-) diff --git a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptor.java b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptor.java index 284126758df..4686b88bdb7 100644 --- a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptor.java +++ b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptor.java @@ -79,31 +79,6 @@ public List calcRoute(RoutingRequest request) { RaptorRoute directWalk = createDirectWalk(fromFacility, toFacility, departureTime, person, parameters); /* - * The pt trip is compared with a direct walk from trip origin to trip destination. This is useful for backwards - * compatibility, but leads to many trips with only a single "transit_walk" leg which are then considered pt - * trips by the main mode identifier even though they do not contain any pt leg and should rather be considered - * "walk" trips. - * - * That problem can be avoided by setting a very high direct walk factor in TransitRouterConfigGroup. However - * this should be combined with enabling mode choice for pt and walk trips such that slow pt trips can be - * replaced by (faster) walk trips by mode choice. Otherwise agents can be stuck with very slow pt trips. - * - * Comparison is only made between a pt trip and a direct walk trip, other modes (e.g. intermodal access/egress - * modes) are not considered. If they had been considered here, the router would effectively be a mode choice - * module although it is supposed not to change mode choice but rather to simply return a route for a given - * mode. Furthermore there is the problem that the generalized cost calculated by the router can be different - * from the cost the agent will be exposed to in scoring, because the mode performed differently in mobsim than - * anticipated by the router (e.g. the drt travel time turns out to be higher than expected, but the router will - * always chose a direct drt trip over the pt trip, because the router might consistently underestimate drt - * travel time). So it seems a bad idea to compare other modes than walk here. Walk is usually teleported at a - * fixed speed, so it is usually completely deterministic whereas other modes are not. - * - * Overall enabling mode choice and setting a very high direct walk factor (e.g. Double.POSITIVE_INFINITY which - * effectively excludes all direct walks) seems cleaner and better. - * - * vsp-gleich sep'19 (after talking with KN) - * - * * foundRoute.parts.size() == 0 can happen if SwissRasilRaptorCore.createRaptorRoute() finds a trip made up of, * only 2 parts which consists only of an access and an egress leg without any pt leg inbetween. */ From de1ead539b8a9f695799c8701b7774c019df9785 Mon Sep 17 00:00:00 2001 From: u229187 Date: Wed, 11 Oct 2023 15:13:17 +0200 Subject: [PATCH 05/25] change SBB copyright header to standard matsim copyright header. --- .../zone/skims/TravelTimeMatrices.java | 23 +++- .../java/ch/sbb/matsim/RunSBBExtension.java | 23 +++- .../analysis/skims/BeelineDistanceMatrix.java | 23 +++- .../analysis/skims/CalculateSkimMatrices.java | 25 +++- .../matsim/analysis/skims/FloatMatrix.java | 23 +++- .../matsim/analysis/skims/FloatMatrixIO.java | 23 +++- .../matsim/analysis/skims/MatricesToXY.java | 23 +++- .../analysis/skims/NetworkSkimMatrices.java | 23 +++- .../matsim/config/SBBTransitConfigGroup.java | 25 +++- .../qsim/pt/SBBPassengerAccessEgress.java | 23 +++- .../mobsim/qsim/pt/SBBTransitDriverAgent.java | 23 +++- .../qsim/pt/SBBTransitDriverAgentFactory.java | 23 +++- .../mobsim/qsim/pt/SBBTransitQSimEngine.java | 23 +++- .../analysis/skims/FloatMatrixIOTest.java | 25 +++- .../config/SBBTransitConfigGroupTest.java | 23 +++- .../matsim/mobsim/qsim/SBBQSimModuleTest.java | 25 +++- .../SBBTransitQSimEngineIntegrationTest.java | 23 +++- .../qsim/pt/SBBTransitQSimEngineTest.java | 23 +++- .../matsim/mobsim/qsim/pt/TestFixture.java | 23 +++- .../matsim/mobsim/qsim/pt/TestQSimModule.java | 23 +++- .../sbb/matsim/RunSwissRailRaptorExample.java | 23 +++- .../config/SwissRailRaptorConfigGroup.java | 23 +++- .../ConfigurableRaptorRouteSelector.java | 23 +++- .../DefaultRaptorIntermodalAccessEgress.java | 23 +++- .../DefaultRaptorParametersForPerson.java | 23 +++- .../matsim/routing/pt/raptor/InitialStop.java | 22 +++- .../raptor/LeastCostRaptorRouteSelector.java | 23 +++- .../raptor/RaptorIntermodalAccessEgress.java | 23 +++- .../routing/pt/raptor/RaptorParameters.java | 28 ++++- .../pt/raptor/RaptorParametersForPerson.java | 23 +++- .../matsim/routing/pt/raptor/RaptorRoute.java | 24 +++- .../pt/raptor/RaptorRouteSelector.java | 23 +++- .../routing/pt/raptor/RaptorStaticConfig.java | 23 +++- .../matsim/routing/pt/raptor/RaptorUtils.java | 23 +++- .../routing/pt/raptor/SwissRailRaptor.java | 22 +++- .../pt/raptor/SwissRailRaptorCore.java | 23 +++- .../pt/raptor/SwissRailRaptorData.java | 36 ++++-- .../pt/raptor/SwissRailRaptorFactory.java | 22 +++- .../pt/raptor/SwissRailRaptorModule.java | 28 ++++- .../raptor/SwissRailRaptorRoutingModule.java | 23 +++- .../SwissRailRaptorRoutingModuleProvider.java | 26 +++- .../SwissRailRaptorConfigGroupTest.java | 27 ++++- .../routing/pt/raptor/FakeFacility.java | 32 +++-- .../sbb/matsim/routing/pt/raptor/Fixture.java | 111 ++++++++++-------- .../routing/pt/raptor/IntermodalFixture.java | 23 +++- .../routing/pt/raptor/RaptorUtilsTest.java | 25 +++- .../pt/raptor/SwissRailRaptorDataTest.java | 25 +++- .../raptor/SwissRailRaptorIntermodalTest.java | 23 +++- .../pt/raptor/SwissRailRaptorModuleTest.java | 39 ++++-- .../pt/raptor/SwissRailRaptorTest.java | 23 +++- .../pt/raptor/SwissRailRaptorTreeTest.java | 23 +++- 51 files changed, 1050 insertions(+), 276 deletions(-) diff --git a/contribs/dvrp/src/main/java/org/matsim/contrib/zone/skims/TravelTimeMatrices.java b/contribs/dvrp/src/main/java/org/matsim/contrib/zone/skims/TravelTimeMatrices.java index 38e5709b173..792140c173d 100644 --- a/contribs/dvrp/src/main/java/org/matsim/contrib/zone/skims/TravelTimeMatrices.java +++ b/contribs/dvrp/src/main/java/org/matsim/contrib/zone/skims/TravelTimeMatrices.java @@ -1,7 +1,22 @@ -/* - * Copyright (C) Schweizerische Bundesbahnen SBB, 2018. - */ - +/* *********************************************************************** * + * project: org.matsim.* * + * + * * + * *********************************************************************** * + * * + * copyright : (C) 2023 by the members listed in the COPYING, * + * LICENSE and WARRANTY file. * + * email : info at matsim dot org * + * * + * *********************************************************************** * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * See also COPYING, LICENSE and WARRANTY file * + * * + * *********************************************************************** */ package org.matsim.contrib.zone.skims; import java.util.ArrayList; diff --git a/contribs/sbb-extensions/src/main/java/ch/sbb/matsim/RunSBBExtension.java b/contribs/sbb-extensions/src/main/java/ch/sbb/matsim/RunSBBExtension.java index dc0163d4b5a..9176cb181fc 100644 --- a/contribs/sbb-extensions/src/main/java/ch/sbb/matsim/RunSBBExtension.java +++ b/contribs/sbb-extensions/src/main/java/ch/sbb/matsim/RunSBBExtension.java @@ -1,7 +1,22 @@ -/* - * Copyright (C) Schweizerische Bundesbahnen SBB, 2018. - */ - +/* *********************************************************************** * + * project: org.matsim.* * + * + * * + * *********************************************************************** * + * * + * copyright : (C) 2023 by the members listed in the COPYING, * + * LICENSE and WARRANTY file. * + * email : info at matsim dot org * + * * + * *********************************************************************** * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * See also COPYING, LICENSE and WARRANTY file * + * * + * *********************************************************************** */ package ch.sbb.matsim; import ch.sbb.matsim.mobsim.qsim.SBBTransitModule; diff --git a/contribs/sbb-extensions/src/main/java/ch/sbb/matsim/analysis/skims/BeelineDistanceMatrix.java b/contribs/sbb-extensions/src/main/java/ch/sbb/matsim/analysis/skims/BeelineDistanceMatrix.java index aaf9a280f9c..a665bff984d 100644 --- a/contribs/sbb-extensions/src/main/java/ch/sbb/matsim/analysis/skims/BeelineDistanceMatrix.java +++ b/contribs/sbb-extensions/src/main/java/ch/sbb/matsim/analysis/skims/BeelineDistanceMatrix.java @@ -1,7 +1,22 @@ -/* - * Copyright (C) Schweizerische Bundesbahnen SBB, 2018. - */ - +/* *********************************************************************** * + * project: org.matsim.* * + * + * * + * *********************************************************************** * + * * + * copyright : (C) 2023 by the members listed in the COPYING, * + * LICENSE and WARRANTY file. * + * email : info at matsim dot org * + * * + * *********************************************************************** * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * See also COPYING, LICENSE and WARRANTY file * + * * + * *********************************************************************** */ package ch.sbb.matsim.analysis.skims; import java.util.Map; diff --git a/contribs/sbb-extensions/src/main/java/ch/sbb/matsim/analysis/skims/CalculateSkimMatrices.java b/contribs/sbb-extensions/src/main/java/ch/sbb/matsim/analysis/skims/CalculateSkimMatrices.java index c3ec95d33aa..f4d8494dbed 100644 --- a/contribs/sbb-extensions/src/main/java/ch/sbb/matsim/analysis/skims/CalculateSkimMatrices.java +++ b/contribs/sbb-extensions/src/main/java/ch/sbb/matsim/analysis/skims/CalculateSkimMatrices.java @@ -1,7 +1,22 @@ -/* - * Copyright (C) Schweizerische Bundesbahnen SBB, 2018. - */ - +/* *********************************************************************** * + * project: org.matsim.* * + * + * * + * *********************************************************************** * + * * + * copyright : (C) 2023 by the members listed in the COPYING, * + * LICENSE and WARRANTY file. * + * email : info at matsim dot org * + * * + * *********************************************************************** * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * See also COPYING, LICENSE and WARRANTY file * + * * + * *********************************************************************** */ package ch.sbb.matsim.analysis.skims; import ch.sbb.matsim.analysis.skims.NetworkSkimMatrices.NetworkIndicators; @@ -175,7 +190,7 @@ public static void main(String[] args) throws IOException { "", (line, route) -> route.getTransportMode().equals("train")); } - + skims.calculateAndWriteBeelineMatrix(); } diff --git a/contribs/sbb-extensions/src/main/java/ch/sbb/matsim/analysis/skims/FloatMatrix.java b/contribs/sbb-extensions/src/main/java/ch/sbb/matsim/analysis/skims/FloatMatrix.java index a8c79473186..9ed2b13025b 100644 --- a/contribs/sbb-extensions/src/main/java/ch/sbb/matsim/analysis/skims/FloatMatrix.java +++ b/contribs/sbb-extensions/src/main/java/ch/sbb/matsim/analysis/skims/FloatMatrix.java @@ -1,7 +1,22 @@ -/* - * Copyright (C) Schweizerische Bundesbahnen SBB, 2018. - */ - +/* *********************************************************************** * + * project: org.matsim.* * + * + * * + * *********************************************************************** * + * * + * copyright : (C) 2023 by the members listed in the COPYING, * + * LICENSE and WARRANTY file. * + * email : info at matsim dot org * + * * + * *********************************************************************** * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * See also COPYING, LICENSE and WARRANTY file * + * * + * *********************************************************************** */ package ch.sbb.matsim.analysis.skims; import java.util.Arrays; diff --git a/contribs/sbb-extensions/src/main/java/ch/sbb/matsim/analysis/skims/FloatMatrixIO.java b/contribs/sbb-extensions/src/main/java/ch/sbb/matsim/analysis/skims/FloatMatrixIO.java index bfb6ce901a4..936b3d68122 100644 --- a/contribs/sbb-extensions/src/main/java/ch/sbb/matsim/analysis/skims/FloatMatrixIO.java +++ b/contribs/sbb-extensions/src/main/java/ch/sbb/matsim/analysis/skims/FloatMatrixIO.java @@ -1,7 +1,22 @@ -/* - * Copyright (C) Schweizerische Bundesbahnen SBB, 2018. - */ - +/* *********************************************************************** * + * project: org.matsim.* * + * + * * + * *********************************************************************** * + * * + * copyright : (C) 2023 by the members listed in the COPYING, * + * LICENSE and WARRANTY file. * + * email : info at matsim dot org * + * * + * *********************************************************************** * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * See also COPYING, LICENSE and WARRANTY file * + * * + * *********************************************************************** */ package ch.sbb.matsim.analysis.skims; import java.io.BufferedReader; diff --git a/contribs/sbb-extensions/src/main/java/ch/sbb/matsim/analysis/skims/MatricesToXY.java b/contribs/sbb-extensions/src/main/java/ch/sbb/matsim/analysis/skims/MatricesToXY.java index 7d42ac60c4e..1facd37be1e 100644 --- a/contribs/sbb-extensions/src/main/java/ch/sbb/matsim/analysis/skims/MatricesToXY.java +++ b/contribs/sbb-extensions/src/main/java/ch/sbb/matsim/analysis/skims/MatricesToXY.java @@ -1,7 +1,22 @@ -/* - * Copyright (C) Schweizerische Bundesbahnen SBB, 2018. - */ - +/* *********************************************************************** * + * project: org.matsim.* * + * + * * + * *********************************************************************** * + * * + * copyright : (C) 2023 by the members listed in the COPYING, * + * LICENSE and WARRANTY file. * + * email : info at matsim dot org * + * * + * *********************************************************************** * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * See also COPYING, LICENSE and WARRANTY file * + * * + * *********************************************************************** */ package ch.sbb.matsim.analysis.skims; import java.io.BufferedWriter; diff --git a/contribs/sbb-extensions/src/main/java/ch/sbb/matsim/analysis/skims/NetworkSkimMatrices.java b/contribs/sbb-extensions/src/main/java/ch/sbb/matsim/analysis/skims/NetworkSkimMatrices.java index 6470e231043..afc16f51ec0 100644 --- a/contribs/sbb-extensions/src/main/java/ch/sbb/matsim/analysis/skims/NetworkSkimMatrices.java +++ b/contribs/sbb-extensions/src/main/java/ch/sbb/matsim/analysis/skims/NetworkSkimMatrices.java @@ -1,7 +1,22 @@ -/* - * Copyright (C) Schweizerische Bundesbahnen SBB, 2018. - */ - +/* *********************************************************************** * + * project: org.matsim.* * + * + * * + * *********************************************************************** * + * * + * copyright : (C) 2023 by the members listed in the COPYING, * + * LICENSE and WARRANTY file. * + * email : info at matsim dot org * + * * + * *********************************************************************** * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * See also COPYING, LICENSE and WARRANTY file * + * * + * *********************************************************************** */ package ch.sbb.matsim.analysis.skims; import org.matsim.core.router.speedy.SpeedyGraph; diff --git a/contribs/sbb-extensions/src/main/java/ch/sbb/matsim/config/SBBTransitConfigGroup.java b/contribs/sbb-extensions/src/main/java/ch/sbb/matsim/config/SBBTransitConfigGroup.java index 24abf75a992..f78b3caaf93 100644 --- a/contribs/sbb-extensions/src/main/java/ch/sbb/matsim/config/SBBTransitConfigGroup.java +++ b/contribs/sbb-extensions/src/main/java/ch/sbb/matsim/config/SBBTransitConfigGroup.java @@ -1,7 +1,22 @@ -/* - * Copyright (C) Schweizerische Bundesbahnen SBB, 2018. - */ - +/* *********************************************************************** * + * project: org.matsim.* * + * + * * + * *********************************************************************** * + * * + * copyright : (C) 2023 by the members listed in the COPYING, * + * LICENSE and WARRANTY file. * + * email : info at matsim dot org * + * * + * *********************************************************************** * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * See also COPYING, LICENSE and WARRANTY file * + * * + * *********************************************************************** */ package ch.sbb.matsim.config; import java.util.HashSet; @@ -20,7 +35,7 @@ public class SBBTransitConfigGroup extends ReflectiveConfigGroup { static private final String PARAM_DETERMINISTIC_SERVICE_MODES = "deterministicServiceModes"; static private final String PARAM_CREATE_LINK_EVENTS_INTERVAL = "createLinkEventsInterval"; - private Set deterministicServiceModes = new HashSet<>(); + private final Set deterministicServiceModes = new HashSet<>(); private int createLinkEventsInterval = 0; public SBBTransitConfigGroup() { diff --git a/contribs/sbb-extensions/src/main/java/ch/sbb/matsim/mobsim/qsim/pt/SBBPassengerAccessEgress.java b/contribs/sbb-extensions/src/main/java/ch/sbb/matsim/mobsim/qsim/pt/SBBPassengerAccessEgress.java index bb67c1ee09e..d7c0f0ffc9e 100644 --- a/contribs/sbb-extensions/src/main/java/ch/sbb/matsim/mobsim/qsim/pt/SBBPassengerAccessEgress.java +++ b/contribs/sbb-extensions/src/main/java/ch/sbb/matsim/mobsim/qsim/pt/SBBPassengerAccessEgress.java @@ -1,7 +1,22 @@ -/* - * Copyright (C) Schweizerische Bundesbahnen SBB, 2018. - */ - +/* *********************************************************************** * + * project: org.matsim.* * + * + * * + * *********************************************************************** * + * * + * copyright : (C) 2023 by the members listed in the COPYING, * + * LICENSE and WARRANTY file. * + * email : info at matsim dot org * + * * + * *********************************************************************** * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * See also COPYING, LICENSE and WARRANTY file * + * * + * *********************************************************************** */ package ch.sbb.matsim.mobsim.qsim.pt; import java.util.ArrayList; diff --git a/contribs/sbb-extensions/src/main/java/ch/sbb/matsim/mobsim/qsim/pt/SBBTransitDriverAgent.java b/contribs/sbb-extensions/src/main/java/ch/sbb/matsim/mobsim/qsim/pt/SBBTransitDriverAgent.java index 4b1ce4be675..7674797dd28 100644 --- a/contribs/sbb-extensions/src/main/java/ch/sbb/matsim/mobsim/qsim/pt/SBBTransitDriverAgent.java +++ b/contribs/sbb-extensions/src/main/java/ch/sbb/matsim/mobsim/qsim/pt/SBBTransitDriverAgent.java @@ -1,7 +1,22 @@ -/* - * Copyright (C) Schweizerische Bundesbahnen SBB, 2018. - */ - +/* *********************************************************************** * + * project: org.matsim.* * + * + * * + * *********************************************************************** * + * * + * copyright : (C) 2023 by the members listed in the COPYING, * + * LICENSE and WARRANTY file. * + * email : info at matsim dot org * + * * + * *********************************************************************** * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * See also COPYING, LICENSE and WARRANTY file * + * * + * *********************************************************************** */ package ch.sbb.matsim.mobsim.qsim.pt; import java.util.LinkedList; diff --git a/contribs/sbb-extensions/src/main/java/ch/sbb/matsim/mobsim/qsim/pt/SBBTransitDriverAgentFactory.java b/contribs/sbb-extensions/src/main/java/ch/sbb/matsim/mobsim/qsim/pt/SBBTransitDriverAgentFactory.java index 665e6f50e0c..bf4e3c6d719 100644 --- a/contribs/sbb-extensions/src/main/java/ch/sbb/matsim/mobsim/qsim/pt/SBBTransitDriverAgentFactory.java +++ b/contribs/sbb-extensions/src/main/java/ch/sbb/matsim/mobsim/qsim/pt/SBBTransitDriverAgentFactory.java @@ -1,7 +1,22 @@ -/* - * Copyright (C) Schweizerische Bundesbahnen SBB, 2018. - */ - +/* *********************************************************************** * + * project: org.matsim.* * + * + * * + * *********************************************************************** * + * * + * copyright : (C) 2023 by the members listed in the COPYING, * + * LICENSE and WARRANTY file. * + * email : info at matsim dot org * + * * + * *********************************************************************** * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * See also COPYING, LICENSE and WARRANTY file * + * * + * *********************************************************************** */ package ch.sbb.matsim.mobsim.qsim.pt; import java.util.Set; diff --git a/contribs/sbb-extensions/src/main/java/ch/sbb/matsim/mobsim/qsim/pt/SBBTransitQSimEngine.java b/contribs/sbb-extensions/src/main/java/ch/sbb/matsim/mobsim/qsim/pt/SBBTransitQSimEngine.java index 643dfef1950..9e8ccf83ee6 100644 --- a/contribs/sbb-extensions/src/main/java/ch/sbb/matsim/mobsim/qsim/pt/SBBTransitQSimEngine.java +++ b/contribs/sbb-extensions/src/main/java/ch/sbb/matsim/mobsim/qsim/pt/SBBTransitQSimEngine.java @@ -1,7 +1,22 @@ -/* - * Copyright (C) Schweizerische Bundesbahnen SBB, 2018. - */ - +/* *********************************************************************** * + * project: org.matsim.* * + * + * * + * *********************************************************************** * + * * + * copyright : (C) 2023 by the members listed in the COPYING, * + * LICENSE and WARRANTY file. * + * email : info at matsim dot org * + * * + * *********************************************************************** * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * See also COPYING, LICENSE and WARRANTY file * + * * + * *********************************************************************** */ package ch.sbb.matsim.mobsim.qsim.pt; import ch.sbb.matsim.config.SBBTransitConfigGroup; diff --git a/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/analysis/skims/FloatMatrixIOTest.java b/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/analysis/skims/FloatMatrixIOTest.java index a3f0ff2e822..1eb96dd4e35 100644 --- a/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/analysis/skims/FloatMatrixIOTest.java +++ b/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/analysis/skims/FloatMatrixIOTest.java @@ -1,7 +1,22 @@ -/* - * Copyright (C) Schweizerische Bundesbahnen SBB, 2018. - */ - +/* *********************************************************************** * + * project: org.matsim.* * + * + * * + * *********************************************************************** * + * * + * copyright : (C) 2023 by the members listed in the COPYING, * + * LICENSE and WARRANTY file. * + * email : info at matsim dot org * + * * + * *********************************************************************** * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * See also COPYING, LICENSE and WARRANTY file * + * * + * *********************************************************************** */ package ch.sbb.matsim.analysis.skims; import java.io.ByteArrayInputStream; @@ -55,4 +70,4 @@ public void testIO() throws IOException { Assert.assertEquals(27.0f, matrix2.get("tres", "dos"), epsilon); Assert.assertEquals(64.0f, matrix2.get("tres", "tres"), epsilon); } -} \ No newline at end of file +} diff --git a/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/config/SBBTransitConfigGroupTest.java b/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/config/SBBTransitConfigGroupTest.java index 49e81b819a0..5624833ef10 100644 --- a/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/config/SBBTransitConfigGroupTest.java +++ b/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/config/SBBTransitConfigGroupTest.java @@ -1,7 +1,22 @@ -/* - * Copyright (C) Schweizerische Bundesbahnen SBB, 2018. - */ - +/* *********************************************************************** * + * project: org.matsim.* * + * + * * + * *********************************************************************** * + * * + * copyright : (C) 2023 by the members listed in the COPYING, * + * LICENSE and WARRANTY file. * + * email : info at matsim dot org * + * * + * *********************************************************************** * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * See also COPYING, LICENSE and WARRANTY file * + * * + * *********************************************************************** */ package ch.sbb.matsim.config; import java.io.ByteArrayInputStream; diff --git a/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/mobsim/qsim/SBBQSimModuleTest.java b/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/mobsim/qsim/SBBQSimModuleTest.java index f647d8449a1..cd3d30f3243 100644 --- a/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/mobsim/qsim/SBBQSimModuleTest.java +++ b/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/mobsim/qsim/SBBQSimModuleTest.java @@ -1,7 +1,22 @@ -/* - * Copyright (C) Schweizerische Bundesbahnen SBB, 2018. - */ - +/* *********************************************************************** * + * project: org.matsim.* * + * + * * + * *********************************************************************** * + * * + * copyright : (C) 2023 by the members listed in the COPYING, * + * LICENSE and WARRANTY file. * + * email : info at matsim dot org * + * * + * *********************************************************************** * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * See also COPYING, LICENSE and WARRANTY file * + * * + * *********************************************************************** */ package ch.sbb.matsim.mobsim.qsim; import ch.sbb.matsim.config.SBBTransitConfigGroup; @@ -83,4 +98,4 @@ QSimComponentsConfig provideQSimComponentsConfig() { Assert.assertTrue(config.getModules().get(SBBTransitConfigGroup.GROUP_NAME) instanceof SBBTransitConfigGroup); } -} \ No newline at end of file +} diff --git a/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/mobsim/qsim/pt/SBBTransitQSimEngineIntegrationTest.java b/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/mobsim/qsim/pt/SBBTransitQSimEngineIntegrationTest.java index ee97222a5a2..8dbf3583a19 100644 --- a/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/mobsim/qsim/pt/SBBTransitQSimEngineIntegrationTest.java +++ b/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/mobsim/qsim/pt/SBBTransitQSimEngineIntegrationTest.java @@ -1,7 +1,22 @@ -/* - * Copyright (C) Schweizerische Bundesbahnen SBB, 2018. - */ - +/* *********************************************************************** * + * project: org.matsim.* * + * + * * + * *********************************************************************** * + * * + * copyright : (C) 2023 by the members listed in the COPYING, * + * LICENSE and WARRANTY file. * + * email : info at matsim dot org * + * * + * *********************************************************************** * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * See also COPYING, LICENSE and WARRANTY file * + * * + * *********************************************************************** */ package ch.sbb.matsim.mobsim.qsim.pt; import ch.sbb.matsim.mobsim.qsim.SBBTransitModule; diff --git a/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/mobsim/qsim/pt/SBBTransitQSimEngineTest.java b/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/mobsim/qsim/pt/SBBTransitQSimEngineTest.java index a3c596481a3..d80dc5793d5 100644 --- a/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/mobsim/qsim/pt/SBBTransitQSimEngineTest.java +++ b/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/mobsim/qsim/pt/SBBTransitQSimEngineTest.java @@ -1,7 +1,22 @@ -/* - * Copyright (C) Schweizerische Bundesbahnen SBB, 2018. - */ - +/* *********************************************************************** * + * project: org.matsim.* * + * + * * + * *********************************************************************** * + * * + * copyright : (C) 2023 by the members listed in the COPYING, * + * LICENSE and WARRANTY file. * + * email : info at matsim dot org * + * * + * *********************************************************************** * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * See also COPYING, LICENSE and WARRANTY file * + * * + * *********************************************************************** */ package ch.sbb.matsim.mobsim.qsim.pt; import java.util.List; diff --git a/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/mobsim/qsim/pt/TestFixture.java b/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/mobsim/qsim/pt/TestFixture.java index 030d3cc43b8..5e497fe5165 100644 --- a/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/mobsim/qsim/pt/TestFixture.java +++ b/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/mobsim/qsim/pt/TestFixture.java @@ -1,7 +1,22 @@ -/* - * Copyright (C) Schweizerische Bundesbahnen SBB, 2018. - */ - +/* *********************************************************************** * + * project: org.matsim.* * + * + * * + * *********************************************************************** * + * * + * copyright : (C) 2023 by the members listed in the COPYING, * + * LICENSE and WARRANTY file. * + * email : info at matsim dot org * + * * + * *********************************************************************** * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * See also COPYING, LICENSE and WARRANTY file * + * * + * *********************************************************************** */ package ch.sbb.matsim.mobsim.qsim.pt; import ch.sbb.matsim.config.SBBTransitConfigGroup; diff --git a/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/mobsim/qsim/pt/TestQSimModule.java b/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/mobsim/qsim/pt/TestQSimModule.java index 14d2c36a06a..668b6662288 100644 --- a/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/mobsim/qsim/pt/TestQSimModule.java +++ b/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/mobsim/qsim/pt/TestQSimModule.java @@ -1,7 +1,22 @@ -/* - * Copyright (C) Schweizerische Bundesbahnen SBB, 2018. - */ - +/* *********************************************************************** * + * project: org.matsim.* * + * + * * + * *********************************************************************** * + * * + * copyright : (C) 2023 by the members listed in the COPYING, * + * LICENSE and WARRANTY file. * + * email : info at matsim dot org * + * * + * *********************************************************************** * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * See also COPYING, LICENSE and WARRANTY file * + * * + * *********************************************************************** */ package ch.sbb.matsim.mobsim.qsim.pt; import com.google.inject.Provides; diff --git a/matsim/src/main/java/ch/sbb/matsim/RunSwissRailRaptorExample.java b/matsim/src/main/java/ch/sbb/matsim/RunSwissRailRaptorExample.java index 8d4cd0a7e36..ead8406f0c6 100644 --- a/matsim/src/main/java/ch/sbb/matsim/RunSwissRailRaptorExample.java +++ b/matsim/src/main/java/ch/sbb/matsim/RunSwissRailRaptorExample.java @@ -1,7 +1,22 @@ -/* - * Copyright (C) Schweizerische Bundesbahnen SBB, 2018. - */ - +/* *********************************************************************** * + * project: org.matsim.* * + * + * * + * *********************************************************************** * + * * + * copyright : (C) 2023 by the members listed in the COPYING, * + * LICENSE and WARRANTY file. * + * email : info at matsim dot org * + * * + * *********************************************************************** * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * See also COPYING, LICENSE and WARRANTY file * + * * + * *********************************************************************** */ package ch.sbb.matsim; import ch.sbb.matsim.routing.pt.raptor.SwissRailRaptorModule; diff --git a/matsim/src/main/java/ch/sbb/matsim/config/SwissRailRaptorConfigGroup.java b/matsim/src/main/java/ch/sbb/matsim/config/SwissRailRaptorConfigGroup.java index f0e18a1e410..2473517c9d1 100644 --- a/matsim/src/main/java/ch/sbb/matsim/config/SwissRailRaptorConfigGroup.java +++ b/matsim/src/main/java/ch/sbb/matsim/config/SwissRailRaptorConfigGroup.java @@ -1,7 +1,22 @@ -/* - * Copyright (C) Schweizerische Bundesbahnen SBB, 2018. - */ - +/* *********************************************************************** * + * project: org.matsim.* * + * + * * + * *********************************************************************** * + * * + * copyright : (C) 2023 by the members listed in the COPYING, * + * LICENSE and WARRANTY file. * + * email : info at matsim dot org * + * * + * *********************************************************************** * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * See also COPYING, LICENSE and WARRANTY file * + * * + * *********************************************************************** */ package ch.sbb.matsim.config; import com.google.common.base.Verify; diff --git a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/ConfigurableRaptorRouteSelector.java b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/ConfigurableRaptorRouteSelector.java index f3c75972829..80d3be07024 100644 --- a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/ConfigurableRaptorRouteSelector.java +++ b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/ConfigurableRaptorRouteSelector.java @@ -1,7 +1,22 @@ -/* - * Copyright (C) Schweizerische Bundesbahnen SBB, 2018. - */ - +/* *********************************************************************** * + * project: org.matsim.* * + * + * * + * *********************************************************************** * + * * + * copyright : (C) 2023 by the members listed in the COPYING, * + * LICENSE and WARRANTY file. * + * email : info at matsim dot org * + * * + * *********************************************************************** * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * See also COPYING, LICENSE and WARRANTY file * + * * + * *********************************************************************** */ package ch.sbb.matsim.routing.pt.raptor; import org.matsim.core.gbl.MatsimRandom; diff --git a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/DefaultRaptorIntermodalAccessEgress.java b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/DefaultRaptorIntermodalAccessEgress.java index 8908831b1bd..a900e79e945 100644 --- a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/DefaultRaptorIntermodalAccessEgress.java +++ b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/DefaultRaptorIntermodalAccessEgress.java @@ -1,7 +1,22 @@ -/* - * Copyright (C) Schweizerische Bundesbahnen SBB, 2018. - */ - +/* *********************************************************************** * + * project: org.matsim.* * + * + * * + * *********************************************************************** * + * * + * copyright : (C) 2023 by the members listed in the COPYING, * + * LICENSE and WARRANTY file. * + * email : info at matsim dot org * + * * + * *********************************************************************** * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * See also COPYING, LICENSE and WARRANTY file * + * * + * *********************************************************************** */ package ch.sbb.matsim.routing.pt.raptor; import java.util.List; diff --git a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/DefaultRaptorParametersForPerson.java b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/DefaultRaptorParametersForPerson.java index a83e951789b..be18feaffa2 100644 --- a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/DefaultRaptorParametersForPerson.java +++ b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/DefaultRaptorParametersForPerson.java @@ -1,7 +1,22 @@ -/* - * Copyright (C) Schweizerische Bundesbahnen SBB, 2018. - */ - +/* *********************************************************************** * + * project: org.matsim.* * + * + * * + * *********************************************************************** * + * * + * copyright : (C) 2023 by the members listed in the COPYING, * + * LICENSE and WARRANTY file. * + * email : info at matsim dot org * + * * + * *********************************************************************** * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * See also COPYING, LICENSE and WARRANTY file * + * * + * *********************************************************************** */ package ch.sbb.matsim.routing.pt.raptor; import org.matsim.api.core.v01.population.Person; diff --git a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/InitialStop.java b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/InitialStop.java index ab39246b16e..822c5a0cab6 100644 --- a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/InitialStop.java +++ b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/InitialStop.java @@ -1,6 +1,22 @@ -/* - * Copyright (C) Schweizerische Bundesbahnen SBB, 2017. - */ +/* *********************************************************************** * + * project: org.matsim.* * + * + * * + * *********************************************************************** * + * * + * copyright : (C) 2023 by the members listed in the COPYING, * + * LICENSE and WARRANTY file. * + * email : info at matsim dot org * + * * + * *********************************************************************** * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * See also COPYING, LICENSE and WARRANTY file * + * * + * *********************************************************************** */ package ch.sbb.matsim.routing.pt.raptor; diff --git a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/LeastCostRaptorRouteSelector.java b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/LeastCostRaptorRouteSelector.java index 363d3bc2e6f..4af1ba1df93 100644 --- a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/LeastCostRaptorRouteSelector.java +++ b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/LeastCostRaptorRouteSelector.java @@ -1,7 +1,22 @@ -/* - * Copyright (C) Schweizerische Bundesbahnen SBB, 2018. - */ - +/* *********************************************************************** * + * project: org.matsim.* * + * + * * + * *********************************************************************** * + * * + * copyright : (C) 2023 by the members listed in the COPYING, * + * LICENSE and WARRANTY file. * + * email : info at matsim dot org * + * * + * *********************************************************************** * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * See also COPYING, LICENSE and WARRANTY file * + * * + * *********************************************************************** */ package ch.sbb.matsim.routing.pt.raptor; import java.util.List; diff --git a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/RaptorIntermodalAccessEgress.java b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/RaptorIntermodalAccessEgress.java index 75142910a90..6630d6225df 100644 --- a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/RaptorIntermodalAccessEgress.java +++ b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/RaptorIntermodalAccessEgress.java @@ -1,7 +1,22 @@ -/* - * Copyright (C) Schweizerische Bundesbahnen SBB, 2018. - */ - +/* *********************************************************************** * + * project: org.matsim.* * + * + * * + * *********************************************************************** * + * * + * copyright : (C) 2023 by the members listed in the COPYING, * + * LICENSE and WARRANTY file. * + * email : info at matsim dot org * + * * + * *********************************************************************** * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * See also COPYING, LICENSE and WARRANTY file * + * * + * *********************************************************************** */ package ch.sbb.matsim.routing.pt.raptor; import org.matsim.api.core.v01.population.Person; diff --git a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/RaptorParameters.java b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/RaptorParameters.java index aa8ce2abfeb..ba79214ff73 100644 --- a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/RaptorParameters.java +++ b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/RaptorParameters.java @@ -1,6 +1,22 @@ -/* - * Copyright (C) Schweizerische Bundesbahnen SBB, 2017. - */ +/* *********************************************************************** * + * project: org.matsim.* * + * + * * + * *********************************************************************** * + * * + * copyright : (C) 2023 by the members listed in the COPYING, * + * LICENSE and WARRANTY file. * + * email : info at matsim dot org * + * * + * *********************************************************************** * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * See also COPYING, LICENSE and WARRANTY file * + * * + * *********************************************************************** */ package ch.sbb.matsim.routing.pt.raptor; @@ -33,8 +49,8 @@ public class RaptorParameters { private double extensionRadius = 200.0; /** - * Factor with which direct walk generalized cost is multiplied before - * it is compared to the pt generalized cost. + * Factor with which direct walk generalized cost is multiplied before + * it is compared to the pt generalized cost. * Set to a very high value to reduce direct walk results. */ private double directWalkFactor = 1.0; @@ -75,7 +91,7 @@ public double getExtensionRadius() { public void setExtensionRadius(double extensionRadius) { this.extensionRadius = extensionRadius; } - + public double getDirectWalkFactor() { return this.directWalkFactor; } diff --git a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/RaptorParametersForPerson.java b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/RaptorParametersForPerson.java index cbff35ed095..b280c40e527 100644 --- a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/RaptorParametersForPerson.java +++ b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/RaptorParametersForPerson.java @@ -1,7 +1,22 @@ -/* - * Copyright (C) Schweizerische Bundesbahnen SBB, 2018. - */ - +/* *********************************************************************** * + * project: org.matsim.* * + * + * * + * *********************************************************************** * + * * + * copyright : (C) 2023 by the members listed in the COPYING, * + * LICENSE and WARRANTY file. * + * email : info at matsim dot org * + * * + * *********************************************************************** * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * See also COPYING, LICENSE and WARRANTY file * + * * + * *********************************************************************** */ package ch.sbb.matsim.routing.pt.raptor; import org.matsim.api.core.v01.population.Person; diff --git a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/RaptorRoute.java b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/RaptorRoute.java index 1c7d3e510f4..ab4c991d99c 100644 --- a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/RaptorRoute.java +++ b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/RaptorRoute.java @@ -1,6 +1,22 @@ -/* - * Copyright (C) Schweizerische Bundesbahnen SBB, 2017. - */ +/* *********************************************************************** * + * project: org.matsim.* * + * + * * + * *********************************************************************** * + * * + * copyright : (C) 2023 by the members listed in the COPYING, * + * LICENSE and WARRANTY file. * + * email : info at matsim dot org * + * * + * *********************************************************************** * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * See also COPYING, LICENSE and WARRANTY file * + * * + * *********************************************************************** */ package ch.sbb.matsim.routing.pt.raptor; @@ -25,7 +41,7 @@ public class RaptorRoute { private double departureTime = Double.NaN; private double travelTime = 0; private int ptLegCount = 0; - private List editableParts = new ArrayList<>(); + private final List editableParts = new ArrayList<>(); final List parts = Collections.unmodifiableList(this.editableParts); RaptorRoute(Facility fromFacility, Facility toFacility, double totalCosts) { diff --git a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/RaptorRouteSelector.java b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/RaptorRouteSelector.java index 1d5ee7d7543..1ef288c03cc 100644 --- a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/RaptorRouteSelector.java +++ b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/RaptorRouteSelector.java @@ -1,7 +1,22 @@ -/* - * Copyright (C) Schweizerische Bundesbahnen SBB, 2018. - */ - +/* *********************************************************************** * + * project: org.matsim.* * + * + * * + * *********************************************************************** * + * * + * copyright : (C) 2023 by the members listed in the COPYING, * + * LICENSE and WARRANTY file. * + * email : info at matsim dot org * + * * + * *********************************************************************** * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * See also COPYING, LICENSE and WARRANTY file * + * * + * *********************************************************************** */ package ch.sbb.matsim.routing.pt.raptor; import java.util.List; diff --git a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/RaptorStaticConfig.java b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/RaptorStaticConfig.java index 162ac694962..e80561feea5 100644 --- a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/RaptorStaticConfig.java +++ b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/RaptorStaticConfig.java @@ -1,7 +1,22 @@ -/* - * Copyright (C) Schweizerische Bundesbahnen SBB, 2018. - */ - +/* *********************************************************************** * + * project: org.matsim.* * + * + * * + * *********************************************************************** * + * * + * copyright : (C) 2023 by the members listed in the COPYING, * + * LICENSE and WARRANTY file. * + * email : info at matsim dot org * + * * + * *********************************************************************** * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * See also COPYING, LICENSE and WARRANTY file * + * * + * *********************************************************************** */ package ch.sbb.matsim.routing.pt.raptor; import ch.sbb.matsim.config.SwissRailRaptorConfigGroup; diff --git a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/RaptorUtils.java b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/RaptorUtils.java index 5dbe0c60bd5..f653faaf627 100644 --- a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/RaptorUtils.java +++ b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/RaptorUtils.java @@ -1,7 +1,22 @@ -/* - * Copyright (C) Schweizerische Bundesbahnen SBB, 2018. - */ - +/* *********************************************************************** * + * project: org.matsim.* * + * + * * + * *********************************************************************** * + * * + * copyright : (C) 2023 by the members listed in the COPYING, * + * LICENSE and WARRANTY file. * + * email : info at matsim dot org * + * * + * *********************************************************************** * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * See also COPYING, LICENSE and WARRANTY file * + * * + * *********************************************************************** */ package ch.sbb.matsim.routing.pt.raptor; import java.util.ArrayList; diff --git a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptor.java b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptor.java index 4686b88bdb7..2808064eb1f 100644 --- a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptor.java +++ b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptor.java @@ -1,6 +1,22 @@ -/* - * Copyright (C) Schweizerische Bundesbahnen SBB, 2017. - */ +/* *********************************************************************** * + * project: org.matsim.* * + * + * * + * *********************************************************************** * + * * + * copyright : (C) 2023 by the members listed in the COPYING, * + * LICENSE and WARRANTY file. * + * email : info at matsim dot org * + * * + * *********************************************************************** * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * See also COPYING, LICENSE and WARRANTY file * + * * + * *********************************************************************** */ package ch.sbb.matsim.routing.pt.raptor; diff --git a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorCore.java b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorCore.java index fd7d0e5d0d6..c0cfeb893bc 100644 --- a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorCore.java +++ b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorCore.java @@ -1,7 +1,22 @@ -/* - * Copyright (C) Schweizerische Bundesbahnen SBB, 2018. - */ - +/* *********************************************************************** * + * project: org.matsim.* * + * + * * + * *********************************************************************** * + * * + * copyright : (C) 2023 by the members listed in the COPYING, * + * LICENSE and WARRANTY file. * + * email : info at matsim dot org * + * * + * *********************************************************************** * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * See also COPYING, LICENSE and WARRANTY file * + * * + * *********************************************************************** */ package ch.sbb.matsim.routing.pt.raptor; import ch.sbb.matsim.config.SwissRailRaptorConfigGroup; diff --git a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorData.java b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorData.java index 1fdb7882f15..5abe7fb49e0 100644 --- a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorData.java +++ b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorData.java @@ -1,6 +1,22 @@ -/* - * Copyright (C) Schweizerische Bundesbahnen SBB, 2017. - */ +/* *********************************************************************** * + * project: org.matsim.* * + * + * * + * *********************************************************************** * + * * + * copyright : (C) 2023 by the members listed in the COPYING, * + * LICENSE and WARRANTY file. * + * email : info at matsim dot org * + * * + * *********************************************************************** * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * See also COPYING, LICENSE and WARRANTY file * + * * + * *********************************************************************** */ package ch.sbb.matsim.routing.pt.raptor; @@ -329,9 +345,7 @@ private static boolean isUsefulTransfer(RRouteStop fromRouteStop, RRouteStop toR // e.g. when starting at a single stop, users would expect that the stop facility // in the opposite direction could be reached within a minute or so by walk. But the algorithm // would find this if the transfers are missing. - if (couldHaveTransferredOneStopEarlierInOppositeDirection(fromRouteStop, toRouteStop, maxBeelineWalkConnectionDistance)) { - return false; - } + return !couldHaveTransferredOneStopEarlierInOppositeDirection(fromRouteStop, toRouteStop, maxBeelineWalkConnectionDistance); } // if we failed all other checks, it looks like this transfer is useful return true; @@ -542,18 +556,18 @@ public static final class RTransfer { this.transferDistance = (int) Math.ceil(transferDistance); } } - + /* - * synchronized in order to avoid that multiple quad trees for the very same stop filter attribute/value combination are prepared at the same time + * synchronized in order to avoid that multiple quad trees for the very same stop filter attribute/value combination are prepared at the same time */ public synchronized void prepareStopFilterQuadTreeIfNotExistent(String stopFilterAttribute, String stopFilterValue) { // if stopFilterAttribute/stopFilterValue combination exists // we do not have to do anything - Map> filteredQTs = + Map> filteredQTs = this.stopFilterAttribute2Value2StopsQT.computeIfAbsent(stopFilterAttribute, key -> new HashMap<>()); if (filteredQTs.containsKey(stopFilterValue)) return; - + Set stops = routeStopsPerStopFacility.keySet(); QuadTree stopsQTFiltered = new QuadTree<>(stopsQT.getMinEasting(), stopsQT.getMinNorthing(), stopsQT.getMaxEasting(), stopsQT.getMaxNorthing()); for (TransitStopFacility stopFacility : stops) { @@ -571,7 +585,7 @@ public synchronized void prepareStopFilterQuadTreeIfNotExistent(String stopFilte public class CachingTransferProvider implements Supplier { private RTransfer raptorTransfer = null; - private Transfer transfer = new Transfer(); + private final Transfer transfer = new Transfer(); public CachingTransferProvider() { } diff --git a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorFactory.java b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorFactory.java index ba79d4ff291..51c740ebb98 100644 --- a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorFactory.java +++ b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorFactory.java @@ -1,6 +1,22 @@ -/* - * Copyright (C) Schweizerische Bundesbahnen SBB, 2017. - */ +/* *********************************************************************** * + * project: org.matsim.* * + * + * * + * *********************************************************************** * + * * + * copyright : (C) 2023 by the members listed in the COPYING, * + * LICENSE and WARRANTY file. * + * email : info at matsim dot org * + * * + * *********************************************************************** * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * See also COPYING, LICENSE and WARRANTY file * + * * + * *********************************************************************** */ package ch.sbb.matsim.routing.pt.raptor; diff --git a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorModule.java b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorModule.java index 350caf37441..9389dc5469a 100644 --- a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorModule.java +++ b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorModule.java @@ -1,6 +1,22 @@ -/* - * Copyright (C) Schweizerische Bundesbahnen SBB, 2017. - */ +/* *********************************************************************** * + * project: org.matsim.* * + * + * * + * *********************************************************************** * + * * + * copyright : (C) 2023 by the members listed in the COPYING, * + * LICENSE and WARRANTY file. * + * email : info at matsim dot org * + * * + * *********************************************************************** * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * See also COPYING, LICENSE and WARRANTY file * + * * + * *********************************************************************** */ package ch.sbb.matsim.routing.pt.raptor; @@ -29,7 +45,7 @@ public void install() { for (String mode : getConfig().transit().getTransitModes()) { addRoutingModuleBinding(mode).toProvider(SwissRailRaptorRoutingModuleProvider.class); } - + SwissRailRaptorConfigGroup srrConfig = ConfigUtils.addOrGetModule(getConfig(), SwissRailRaptorConfigGroup.class); if (srrConfig.isUseRangeQuery()) { @@ -37,7 +53,7 @@ public void install() { } else { bind(RaptorRouteSelector.class).to(LeastCostRaptorRouteSelector.class); // just a simple default in case it ever gets used. } - + switch (srrConfig.getScoringParameters()) { case Default: bind(RaptorParametersForPerson.class).to(DefaultRaptorParametersForPerson.class); @@ -54,7 +70,7 @@ public void install() { if (useCapacityConstraints) { addEventHandlerBinding().to(OccupancyTracker.class); } - + bind(RaptorIntermodalAccessEgress.class).to(DefaultRaptorIntermodalAccessEgress.class); bind(RaptorInVehicleCostCalculator.class).to(DefaultRaptorInVehicleCostCalculator.class); bind(RaptorTransferCostCalculator.class).to(DefaultRaptorTransferCostCalculator.class); diff --git a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorRoutingModule.java b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorRoutingModule.java index e9cf7f4961c..94c346b120b 100644 --- a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorRoutingModule.java +++ b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorRoutingModule.java @@ -1,7 +1,22 @@ -/* - * Copyright (C) Schweizerische Bundesbahnen SBB, 2018. - */ - +/* *********************************************************************** * + * project: org.matsim.* * + * + * * + * *********************************************************************** * + * * + * copyright : (C) 2023 by the members listed in the COPYING, * + * LICENSE and WARRANTY file. * + * email : info at matsim dot org * + * * + * *********************************************************************** * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * See also COPYING, LICENSE and WARRANTY file * + * * + * *********************************************************************** */ package ch.sbb.matsim.routing.pt.raptor; import java.util.ArrayList; diff --git a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorRoutingModuleProvider.java b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorRoutingModuleProvider.java index 5a9b5b45be9..c6c23184169 100644 --- a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorRoutingModuleProvider.java +++ b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorRoutingModuleProvider.java @@ -1,7 +1,22 @@ -/* - * Copyright (C) Schweizerische Bundesbahnen SBB, 2018. - */ - +/* *********************************************************************** * + * project: org.matsim.* * + * + * * + * *********************************************************************** * + * * + * copyright : (C) 2023 by the members listed in the COPYING, * + * LICENSE and WARRANTY file. * + * email : info at matsim dot org * + * * + * *********************************************************************** * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * See also COPYING, LICENSE and WARRANTY file * + * * + * *********************************************************************** */ package ch.sbb.matsim.routing.pt.raptor; import com.google.inject.name.Named; @@ -31,7 +46,8 @@ public class SwissRailRaptorRoutingModuleProvider implements Provider getCustomAttributes() { + @Override + public Map getCustomAttributes() { throw new RuntimeException("not implemented"); } - public Id getLinkId() { + @Override + public Id getLinkId() { return this.linkId; } } diff --git a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/Fixture.java b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/Fixture.java index b098fd5b318..97bdc02747a 100644 --- a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/Fixture.java +++ b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/Fixture.java @@ -1,7 +1,22 @@ -/* - * Copyright (C) Schweizerische Bundesbahnen SBB, 2018. - */ - +/* *********************************************************************** * + * project: org.matsim.* * + * + * * + * *********************************************************************** * + * * + * copyright : (C) 2023 by the members listed in the COPYING, * + * LICENSE and WARRANTY file. * + * email : info at matsim dot org * + * * + * *********************************************************************** * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * See also COPYING, LICENSE and WARRANTY file * + * * + * *********************************************************************** */ package ch.sbb.matsim.routing.pt.raptor; import java.util.ArrayList; @@ -85,7 +100,7 @@ public Fixture() { this.config = ConfigUtils.createConfig(); this.config.transit().setUseTransit(true); - + ScenarioBuilder scBuilder = new ScenarioBuilder(config) ; this.scenario = (MutableScenario) scBuilder.build() ; @@ -104,23 +119,23 @@ protected void init() { } protected void buildNetwork() { - this.nodes[0] = this.network.getFactory().createNode(Id.create("0", Node.class), new Coord((double) 0, (double) 5000)); - this.nodes[1] = this.network.getFactory().createNode(Id.create("1", Node.class), new Coord((double) 4000, (double) 5000)); - this.nodes[2] = this.network.getFactory().createNode(Id.create("2", Node.class), new Coord((double) 8000, (double) 5000)); - this.nodes[3] = this.network.getFactory().createNode(Id.create("3", Node.class), new Coord((double) 12000, (double) 5000)); - this.nodes[4] = this.network.getFactory().createNode(Id.create("4", Node.class), new Coord((double) 16000, (double) 5000)); - this.nodes[5] = this.network.getFactory().createNode(Id.create("5", Node.class), new Coord((double) 20000, (double) 5000)); - this.nodes[6] = this.network.getFactory().createNode(Id.create("6", Node.class), new Coord((double) 24000, (double) 5000)); - this.nodes[7] = this.network.getFactory().createNode(Id.create("7", Node.class), new Coord((double) 28000, (double) 5000)); - this.nodes[8] = this.network.getFactory().createNode(Id.create("8", Node.class), new Coord((double) 32000, (double) 5000)); - this.nodes[9] = this.network.getFactory().createNode(Id.create("9", Node.class), new Coord((double) 36000, (double) 5000)); - this.nodes[10] = this.network.getFactory().createNode(Id.create("10", Node.class), new Coord((double) 40000, (double) 5000)); - this.nodes[11] = this.network.getFactory().createNode(Id.create("11", Node.class), new Coord((double) 12000, (double) 5000)); - this.nodes[12] = this.network.getFactory().createNode(Id.create("12", Node.class), new Coord((double) 16000, (double) 10000)); - this.nodes[13] = this.network.getFactory().createNode(Id.create("13", Node.class), new Coord((double) 24000, (double) 10000)); - this.nodes[14] = this.network.getFactory().createNode(Id.create("14", Node.class), new Coord((double) 28000, (double) 5000)); - this.nodes[15] = this.network.getFactory().createNode(Id.create("15", Node.class), new Coord((double) 24000, (double) 0)); - this.nodes[16] = this.network.getFactory().createNode(Id.create("16", Node.class), new Coord((double) 16000, (double) 0)); + this.nodes[0] = this.network.getFactory().createNode(Id.create("0", Node.class), new Coord(0, 5000)); + this.nodes[1] = this.network.getFactory().createNode(Id.create("1", Node.class), new Coord(4000, 5000)); + this.nodes[2] = this.network.getFactory().createNode(Id.create("2", Node.class), new Coord(8000, 5000)); + this.nodes[3] = this.network.getFactory().createNode(Id.create("3", Node.class), new Coord(12000, 5000)); + this.nodes[4] = this.network.getFactory().createNode(Id.create("4", Node.class), new Coord(16000, 5000)); + this.nodes[5] = this.network.getFactory().createNode(Id.create("5", Node.class), new Coord(20000, 5000)); + this.nodes[6] = this.network.getFactory().createNode(Id.create("6", Node.class), new Coord(24000, 5000)); + this.nodes[7] = this.network.getFactory().createNode(Id.create("7", Node.class), new Coord(28000, 5000)); + this.nodes[8] = this.network.getFactory().createNode(Id.create("8", Node.class), new Coord(32000, 5000)); + this.nodes[9] = this.network.getFactory().createNode(Id.create("9", Node.class), new Coord(36000, 5000)); + this.nodes[10] = this.network.getFactory().createNode(Id.create("10", Node.class), new Coord(40000, 5000)); + this.nodes[11] = this.network.getFactory().createNode(Id.create("11", Node.class), new Coord(12000, 5000)); + this.nodes[12] = this.network.getFactory().createNode(Id.create("12", Node.class), new Coord(16000, 10000)); + this.nodes[13] = this.network.getFactory().createNode(Id.create("13", Node.class), new Coord(24000, 10000)); + this.nodes[14] = this.network.getFactory().createNode(Id.create("14", Node.class), new Coord(28000, 5000)); + this.nodes[15] = this.network.getFactory().createNode(Id.create("15", Node.class), new Coord(24000, 0)); + this.nodes[16] = this.network.getFactory().createNode(Id.create("16", Node.class), new Coord(16000, 0)); for (int i = 0; i < 17; i++) { this.network.addNode(this.nodes[i]); } @@ -167,30 +182,30 @@ protected void buildNetwork() { } protected void buildStops() { - this.stopFacilities[ 0] = this.builder.createTransitStopFacility(Id.create( "0", TransitStopFacility.class), new Coord((double) 4000, (double) 5002), true); - this.stopFacilities[ 1] = this.builder.createTransitStopFacility(Id.create( "1", TransitStopFacility.class), new Coord((double) 4000, (double) 4998), true); - this.stopFacilities[ 2] = this.builder.createTransitStopFacility(Id.create( "2", TransitStopFacility.class), new Coord((double) 8000, (double) 5002), true); - this.stopFacilities[ 3] = this.builder.createTransitStopFacility(Id.create( "3", TransitStopFacility.class), new Coord((double) 8000, (double) 4998), true); - this.stopFacilities[ 4] = this.builder.createTransitStopFacility(Id.create( "4", TransitStopFacility.class), new Coord((double) 12000, (double) 5002), true); - this.stopFacilities[ 5] = this.builder.createTransitStopFacility(Id.create( "5", TransitStopFacility.class), new Coord((double) 12000, (double) 4998), true); - this.stopFacilities[ 6] = this.builder.createTransitStopFacility(Id.create( "6", TransitStopFacility.class), new Coord((double) 16000, (double) 5002), true); - this.stopFacilities[ 7] = this.builder.createTransitStopFacility(Id.create( "7", TransitStopFacility.class), new Coord((double) 16000, (double) 4998), true); - this.stopFacilities[ 8] = this.builder.createTransitStopFacility(Id.create( "8", TransitStopFacility.class), new Coord((double) 20000, (double) 5002), true); - this.stopFacilities[ 9] = this.builder.createTransitStopFacility(Id.create( "9", TransitStopFacility.class), new Coord((double) 20000, (double) 4998), true); - this.stopFacilities[10] = this.builder.createTransitStopFacility(Id.create("10", TransitStopFacility.class), new Coord((double) 24000, (double) 5002), true); - this.stopFacilities[11] = this.builder.createTransitStopFacility(Id.create("11", TransitStopFacility.class), new Coord((double) 24000, (double) 4998), true); - this.stopFacilities[12] = this.builder.createTransitStopFacility(Id.create("12", TransitStopFacility.class), new Coord((double) 28000, (double) 5002), true); - this.stopFacilities[13] = this.builder.createTransitStopFacility(Id.create("13", TransitStopFacility.class), new Coord((double) 28000, (double) 4998), true); - this.stopFacilities[14] = this.builder.createTransitStopFacility(Id.create("14", TransitStopFacility.class), new Coord((double) 32000, (double) 5002), true); - this.stopFacilities[15] = this.builder.createTransitStopFacility(Id.create("15", TransitStopFacility.class), new Coord((double) 32000, (double) 4998), true); - this.stopFacilities[16] = this.builder.createTransitStopFacility(Id.create("16", TransitStopFacility.class), new Coord((double) 36000, (double) 5002), true); - this.stopFacilities[17] = this.builder.createTransitStopFacility(Id.create("17", TransitStopFacility.class), new Coord((double) 36000, (double) 4998), true); - this.stopFacilities[18] = this.builder.createTransitStopFacility(Id.create("18", TransitStopFacility.class), new Coord((double) 12000, (double) 5000), true); - this.stopFacilities[19] = this.builder.createTransitStopFacility(Id.create("19", TransitStopFacility.class), new Coord((double) 16000, (double) 10000), true); - this.stopFacilities[20] = this.builder.createTransitStopFacility(Id.create("20", TransitStopFacility.class), new Coord((double) 24000, (double) 10000), true); - this.stopFacilities[21] = this.builder.createTransitStopFacility(Id.create("21", TransitStopFacility.class), new Coord((double) 28000, (double) 5000), true); - this.stopFacilities[22] = this.builder.createTransitStopFacility(Id.create("22", TransitStopFacility.class), new Coord((double) 24000, (double) 0), true); - this.stopFacilities[23] = this.builder.createTransitStopFacility(Id.create("23", TransitStopFacility.class), new Coord((double) 16000, (double) 0), true); + this.stopFacilities[ 0] = this.builder.createTransitStopFacility(Id.create( "0", TransitStopFacility.class), new Coord(4000, 5002), true); + this.stopFacilities[ 1] = this.builder.createTransitStopFacility(Id.create( "1", TransitStopFacility.class), new Coord(4000, 4998), true); + this.stopFacilities[ 2] = this.builder.createTransitStopFacility(Id.create( "2", TransitStopFacility.class), new Coord(8000, 5002), true); + this.stopFacilities[ 3] = this.builder.createTransitStopFacility(Id.create( "3", TransitStopFacility.class), new Coord(8000, 4998), true); + this.stopFacilities[ 4] = this.builder.createTransitStopFacility(Id.create( "4", TransitStopFacility.class), new Coord(12000, 5002), true); + this.stopFacilities[ 5] = this.builder.createTransitStopFacility(Id.create( "5", TransitStopFacility.class), new Coord(12000, 4998), true); + this.stopFacilities[ 6] = this.builder.createTransitStopFacility(Id.create( "6", TransitStopFacility.class), new Coord(16000, 5002), true); + this.stopFacilities[ 7] = this.builder.createTransitStopFacility(Id.create( "7", TransitStopFacility.class), new Coord(16000, 4998), true); + this.stopFacilities[ 8] = this.builder.createTransitStopFacility(Id.create( "8", TransitStopFacility.class), new Coord(20000, 5002), true); + this.stopFacilities[ 9] = this.builder.createTransitStopFacility(Id.create( "9", TransitStopFacility.class), new Coord(20000, 4998), true); + this.stopFacilities[10] = this.builder.createTransitStopFacility(Id.create("10", TransitStopFacility.class), new Coord(24000, 5002), true); + this.stopFacilities[11] = this.builder.createTransitStopFacility(Id.create("11", TransitStopFacility.class), new Coord(24000, 4998), true); + this.stopFacilities[12] = this.builder.createTransitStopFacility(Id.create("12", TransitStopFacility.class), new Coord(28000, 5002), true); + this.stopFacilities[13] = this.builder.createTransitStopFacility(Id.create("13", TransitStopFacility.class), new Coord(28000, 4998), true); + this.stopFacilities[14] = this.builder.createTransitStopFacility(Id.create("14", TransitStopFacility.class), new Coord(32000, 5002), true); + this.stopFacilities[15] = this.builder.createTransitStopFacility(Id.create("15", TransitStopFacility.class), new Coord(32000, 4998), true); + this.stopFacilities[16] = this.builder.createTransitStopFacility(Id.create("16", TransitStopFacility.class), new Coord(36000, 5002), true); + this.stopFacilities[17] = this.builder.createTransitStopFacility(Id.create("17", TransitStopFacility.class), new Coord(36000, 4998), true); + this.stopFacilities[18] = this.builder.createTransitStopFacility(Id.create("18", TransitStopFacility.class), new Coord(12000, 5000), true); + this.stopFacilities[19] = this.builder.createTransitStopFacility(Id.create("19", TransitStopFacility.class), new Coord(16000, 10000), true); + this.stopFacilities[20] = this.builder.createTransitStopFacility(Id.create("20", TransitStopFacility.class), new Coord(24000, 10000), true); + this.stopFacilities[21] = this.builder.createTransitStopFacility(Id.create("21", TransitStopFacility.class), new Coord(28000, 5000), true); + this.stopFacilities[22] = this.builder.createTransitStopFacility(Id.create("22", TransitStopFacility.class), new Coord(24000, 0), true); + this.stopFacilities[23] = this.builder.createTransitStopFacility(Id.create("23", TransitStopFacility.class), new Coord(16000, 0), true); this.stopFacilities[ 0].setName("A"); this.stopFacilities[ 1].setName("A"); this.stopFacilities[ 2].setName("B"); @@ -445,14 +460,14 @@ protected void buildGreenLine() { route.addDeparture(this.builder.createDeparture(Id.create("g>18", Departure.class), 7.0*3600 + 51.0*60)); } } - + protected void addVehicles() { VehiclesFactory vf = transitVehicles.getFactory(); VehicleType trainType = vf.createVehicleType(Id.create("train", VehicleType.class)); trainType.getCapacity().setSeats(200); trainType.getCapacity().setStandingRoom(100); transitVehicles.addVehicleType(trainType); - + for (TransitLine line: schedule.getTransitLines().values()) { for (TransitRoute route: line.getRoutes().values()) { for (Departure dep: route.getDepartures().values()) { diff --git a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/IntermodalFixture.java b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/IntermodalFixture.java index 74a25a2ecee..495868e6991 100644 --- a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/IntermodalFixture.java +++ b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/IntermodalFixture.java @@ -1,7 +1,22 @@ -/* - * Copyright (C) Schweizerische Bundesbahnen SBB, 2018. - */ - +/* *********************************************************************** * + * project: org.matsim.* * + * + * * + * *********************************************************************** * + * * + * copyright : (C) 2023 by the members listed in the COPYING, * + * LICENSE and WARRANTY file. * + * email : info at matsim dot org * + * * + * *********************************************************************** * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * See also COPYING, LICENSE and WARRANTY file * + * * + * *********************************************************************** */ package ch.sbb.matsim.routing.pt.raptor; import ch.sbb.matsim.config.SwissRailRaptorConfigGroup; diff --git a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/RaptorUtilsTest.java b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/RaptorUtilsTest.java index 89fb2dd8a4c..2a6ee7b9abc 100644 --- a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/RaptorUtilsTest.java +++ b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/RaptorUtilsTest.java @@ -1,7 +1,22 @@ -/* - * Copyright (C) Schweizerische Bundesbahnen SBB, 2018. - */ - +/* *********************************************************************** * + * project: org.matsim.* * + * + * * + * *********************************************************************** * + * * + * copyright : (C) 2023 by the members listed in the COPYING, * + * LICENSE and WARRANTY file. * + * email : info at matsim dot org * + * * + * *********************************************************************** * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * See also COPYING, LICENSE and WARRANTY file * + * * + * *********************************************************************** */ package ch.sbb.matsim.routing.pt.raptor; import ch.sbb.matsim.config.SwissRailRaptorConfigGroup; @@ -68,4 +83,4 @@ public void testConfigLoading() { Assert.assertTrue(raptorParams2.getConfig().isUseIntermodalAccessEgress()); Assert.assertFalse(raptorParams2.getConfig().isUseModeMappingForPassengers()); } -} \ No newline at end of file +} diff --git a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorDataTest.java b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorDataTest.java index d00dae0f9f5..5a0a4711a2f 100644 --- a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorDataTest.java +++ b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorDataTest.java @@ -1,7 +1,22 @@ -/* - * Copyright (C) Schweizerische Bundesbahnen SBB, 2018. - */ - +/* *********************************************************************** * + * project: org.matsim.* * + * + * * + * *********************************************************************** * + * * + * copyright : (C) 2023 by the members listed in the COPYING, * + * LICENSE and WARRANTY file. * + * email : info at matsim dot org * + * * + * *********************************************************************** * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * See also COPYING, LICENSE and WARRANTY file * + * * + * *********************************************************************** */ package ch.sbb.matsim.routing.pt.raptor; import org.junit.Assert; @@ -82,4 +97,4 @@ public void testTransfersFromSchedule() { Assert.assertEquals("number of transfers should have stayed the same.", data2.transfers.length, data4.transfers.length); } -} \ No newline at end of file +} diff --git a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorIntermodalTest.java b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorIntermodalTest.java index 7ec0a2f552c..22024c0ccb8 100644 --- a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorIntermodalTest.java +++ b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorIntermodalTest.java @@ -1,7 +1,22 @@ -/* - * Copyright (C) Schweizerische Bundesbahnen SBB, 2018. - */ - +/* *********************************************************************** * + * project: org.matsim.* * + * + * * + * *********************************************************************** * + * * + * copyright : (C) 2023 by the members listed in the COPYING, * + * LICENSE and WARRANTY file. * + * email : info at matsim dot org * + * * + * *********************************************************************** * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * See also COPYING, LICENSE and WARRANTY file * + * * + * *********************************************************************** */ package ch.sbb.matsim.routing.pt.raptor; import ch.sbb.matsim.config.SwissRailRaptorConfigGroup; diff --git a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorModuleTest.java b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorModuleTest.java index c2a85b66d35..f276b6e2f57 100644 --- a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorModuleTest.java +++ b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorModuleTest.java @@ -1,7 +1,22 @@ -/* - * Copyright (C) Schweizerische Bundesbahnen SBB, 2018. - */ - +/* *********************************************************************** * + * project: org.matsim.* * + * + * * + * *********************************************************************** * + * * + * copyright : (C) 2023 by the members listed in the COPYING, * + * LICENSE and WARRANTY file. * + * email : info at matsim dot org * + * * + * *********************************************************************** * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * See also COPYING, LICENSE and WARRANTY file * + * * + * *********************************************************************** */ package ch.sbb.matsim.routing.pt.raptor; import java.util.ArrayList; @@ -231,7 +246,7 @@ public void install() { // :-( :-( kai, mar'20) } - + /** * Test update of SwissRailRaptorData after TransitScheduleChangedEvent */ @@ -252,7 +267,7 @@ public void testTransitScheduleUpdate() { plan.addActivity(homeAct); plan.addLeg(pf.createLeg(TransportMode.pt)); plan.addActivity(pf.createActivityFromCoord("work", new Coord(24010, 10000))); - + // prepare scoring Config config = f.config; PlanCalcScoreConfigGroup.ActivityParams homeScoring = new PlanCalcScoreConfigGroup.ActivityParams("home"); @@ -288,12 +303,12 @@ public void install() { }); controler.run(); - + // test that swiss rail raptor was used TripRouter tripRouter = controler.getInjector().getInstance(TripRouter.class); RoutingModule module = tripRouter.getRoutingModule(TransportMode.pt); Assert.assertTrue(module instanceof SwissRailRaptorRoutingModule); - + // Check routed plan List planElements = p1.getSelectedPlan().getPlanElements(); for (PlanElement pe : planElements) { @@ -317,13 +332,13 @@ public void install() { Assert.assertEquals(TransportMode.walk, ((Leg) planElements.get(1)).getMode()); Assert.assertEquals(TransportMode.pt, ((Leg) planElements.get(3)).getMode()); Assert.assertEquals(TransportMode.walk, ((Leg) planElements.get(5)).getMode()); - + // Check route: should return one of the added lines although the removed green line would be faster Leg ptLeg = (Leg) planElements.get(3); TransitPassengerRoute ptRoute = (TransitPassengerRoute) ptLeg.getRoute(); - Assert.assertEquals(Id.create("AddedLine" + 1, TransitLine.class), ptRoute.getLineId()); + Assert.assertEquals(Id.create("AddedLine" + 1, TransitLine.class), ptRoute.getLineId()); } - + /** * Test individual scoring parameters for agents */ @@ -431,5 +446,5 @@ private void removeGreenLineAndStop(ControlerEvent event) { } } - + } diff --git a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorTest.java b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorTest.java index 4eb2d0f01c5..a410dd33f6a 100644 --- a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorTest.java +++ b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorTest.java @@ -1,7 +1,22 @@ -/* - * Copyright (C) Schweizerische Bundesbahnen SBB, 2018. - */ - +/* *********************************************************************** * + * project: org.matsim.* * + * + * * + * *********************************************************************** * + * * + * copyright : (C) 2023 by the members listed in the COPYING, * + * LICENSE and WARRANTY file. * + * email : info at matsim dot org * + * * + * *********************************************************************** * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * See also COPYING, LICENSE and WARRANTY file * + * * + * *********************************************************************** */ package ch.sbb.matsim.routing.pt.raptor; import ch.sbb.matsim.config.SwissRailRaptorConfigGroup; diff --git a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorTreeTest.java b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorTreeTest.java index f1932f29f52..05ad518af21 100644 --- a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorTreeTest.java +++ b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorTreeTest.java @@ -1,7 +1,22 @@ -/* - * Copyright (C) Schweizerische Bundesbahnen SBB, 2018. - */ - +/* *********************************************************************** * + * project: org.matsim.* * + * + * * + * *********************************************************************** * + * * + * copyright : (C) 2023 by the members listed in the COPYING, * + * LICENSE and WARRANTY file. * + * email : info at matsim dot org * + * * + * *********************************************************************** * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * See also COPYING, LICENSE and WARRANTY file * + * * + * *********************************************************************** */ package ch.sbb.matsim.routing.pt.raptor; import ch.sbb.matsim.routing.pt.raptor.SwissRailRaptorCore.TravelInfo; From 4121b59dde69275f57614b18ef89489ad6254fc8 Mon Sep 17 00:00:00 2001 From: u229187 Date: Wed, 11 Oct 2023 15:23:29 +0200 Subject: [PATCH 06/25] add GPL Header to all classes in ch.sbb.matsim.* --- ...acityDependentInVehicleCostCalculator.java | 19 ++++++++ .../DefaultRaptorInVehicleCostCalculator.java | 19 ++++++++ .../pt/raptor/DefaultRaptorStopFinder.java | 19 ++++++++ .../DefaultRaptorTransferCostCalculator.java | 19 ++++++++ .../IndividualRaptorParametersForPerson.java | 19 ++++++++ .../routing/pt/raptor/OccupancyData.java | 19 ++++++++ .../routing/pt/raptor/OccupancyTracker.java | 24 ++++++++-- .../raptor/RaptorInVehicleCostCalculator.java | 19 ++++++++ .../routing/pt/raptor/RaptorStopFinder.java | 21 ++++++++- .../raptor/RaptorTransferCostCalculator.java | 19 ++++++++ .../matsim/routing/pt/raptor/Transfer.java | 19 ++++++++ .../raptor/CapacityDependentScoringTest.java | 19 ++++++++ .../pt/raptor/OccupancyTrackerTest.java | 21 ++++++++- .../pt/raptor/RaptorStopFinderTest.java | 47 +++++++++++++------ .../raptor/SwissRailRaptorCapacitiesTest.java | 19 ++++++++ .../SwissRailRaptorInVehicleCostTest.java | 19 ++++++++ 16 files changed, 321 insertions(+), 20 deletions(-) diff --git a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/CapacityDependentInVehicleCostCalculator.java b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/CapacityDependentInVehicleCostCalculator.java index 5736b305ea6..00cc019b720 100644 --- a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/CapacityDependentInVehicleCostCalculator.java +++ b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/CapacityDependentInVehicleCostCalculator.java @@ -1,3 +1,22 @@ +/* *********************************************************************** * + * project: org.matsim.* * + * + * * + * *********************************************************************** * + * * + * copyright : (C) 2023 by the members listed in the COPYING, * + * LICENSE and WARRANTY file. * + * email : info at matsim dot org * + * * + * *********************************************************************** * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * See also COPYING, LICENSE and WARRANTY file * + * * + * *********************************************************************** */ package ch.sbb.matsim.routing.pt.raptor; import org.matsim.api.core.v01.population.Person; diff --git a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/DefaultRaptorInVehicleCostCalculator.java b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/DefaultRaptorInVehicleCostCalculator.java index 17b6dfb50de..bb684485e41 100644 --- a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/DefaultRaptorInVehicleCostCalculator.java +++ b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/DefaultRaptorInVehicleCostCalculator.java @@ -1,3 +1,22 @@ +/* *********************************************************************** * + * project: org.matsim.* * + * + * * + * *********************************************************************** * + * * + * copyright : (C) 2023 by the members listed in the COPYING, * + * LICENSE and WARRANTY file. * + * email : info at matsim dot org * + * * + * *********************************************************************** * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * See also COPYING, LICENSE and WARRANTY file * + * * + * *********************************************************************** */ package ch.sbb.matsim.routing.pt.raptor; import org.matsim.api.core.v01.population.Person; diff --git a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/DefaultRaptorStopFinder.java b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/DefaultRaptorStopFinder.java index 71a0d2bbff9..7592094f139 100644 --- a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/DefaultRaptorStopFinder.java +++ b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/DefaultRaptorStopFinder.java @@ -1,3 +1,22 @@ +/* *********************************************************************** * + * project: org.matsim.* * + * + * * + * *********************************************************************** * + * * + * copyright : (C) 2023 by the members listed in the COPYING, * + * LICENSE and WARRANTY file. * + * email : info at matsim dot org * + * * + * *********************************************************************** * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * See also COPYING, LICENSE and WARRANTY file * + * * + * *********************************************************************** */ package ch.sbb.matsim.routing.pt.raptor; import java.util.ArrayList; diff --git a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/DefaultRaptorTransferCostCalculator.java b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/DefaultRaptorTransferCostCalculator.java index 3e7578e0e81..5522400f8cb 100644 --- a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/DefaultRaptorTransferCostCalculator.java +++ b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/DefaultRaptorTransferCostCalculator.java @@ -1,3 +1,22 @@ +/* *********************************************************************** * + * project: org.matsim.* * + * + * * + * *********************************************************************** * + * * + * copyright : (C) 2023 by the members listed in the COPYING, * + * LICENSE and WARRANTY file. * + * email : info at matsim dot org * + * * + * *********************************************************************** * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * See also COPYING, LICENSE and WARRANTY file * + * * + * *********************************************************************** */ package ch.sbb.matsim.routing.pt.raptor; import java.util.function.Supplier; diff --git a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/IndividualRaptorParametersForPerson.java b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/IndividualRaptorParametersForPerson.java index 26e95cb0a7b..58e4ff37fa0 100644 --- a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/IndividualRaptorParametersForPerson.java +++ b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/IndividualRaptorParametersForPerson.java @@ -1,3 +1,22 @@ +/* *********************************************************************** * + * project: org.matsim.* * + * + * * + * *********************************************************************** * + * * + * copyright : (C) 2023 by the members listed in the COPYING, * + * LICENSE and WARRANTY file. * + * email : info at matsim dot org * + * * + * *********************************************************************** * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * See also COPYING, LICENSE and WARRANTY file * + * * + * *********************************************************************** */ package ch.sbb.matsim.routing.pt.raptor; import ch.sbb.matsim.config.SwissRailRaptorConfigGroup; diff --git a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/OccupancyData.java b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/OccupancyData.java index 629f8476bfa..2de04efdcde 100644 --- a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/OccupancyData.java +++ b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/OccupancyData.java @@ -1,3 +1,22 @@ +/* *********************************************************************** * + * project: org.matsim.* * + * + * * + * *********************************************************************** * + * * + * copyright : (C) 2023 by the members listed in the COPYING, * + * LICENSE and WARRANTY file. * + * email : info at matsim dot org * + * * + * *********************************************************************** * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * See also COPYING, LICENSE and WARRANTY file * + * * + * *********************************************************************** */ package ch.sbb.matsim.routing.pt.raptor; import org.apache.logging.log4j.LogManager; diff --git a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/OccupancyTracker.java b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/OccupancyTracker.java index b407efadd07..8051b09d842 100644 --- a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/OccupancyTracker.java +++ b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/OccupancyTracker.java @@ -1,3 +1,22 @@ +/* *********************************************************************** * + * project: org.matsim.* * + * + * * + * *********************************************************************** * + * * + * copyright : (C) 2023 by the members listed in the COPYING, * + * LICENSE and WARRANTY file. * + * email : info at matsim dot org * + * * + * *********************************************************************** * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * See also COPYING, LICENSE and WARRANTY file * + * * + * *********************************************************************** */ package ch.sbb.matsim.routing.pt.raptor; import ch.sbb.matsim.routing.pt.raptor.OccupancyData.DepartureData; @@ -226,10 +245,7 @@ public void next() { break; } if (!searchStart) { - this.hasNext = true; - if (this.nextFromStop.getStopFacility().getId().equals(alightingStopId)) { - this.hasNext = false; - } + this.hasNext = !this.nextFromStop.getStopFacility().getId().equals(alightingStopId); break; } this.nextFromStop = this.nextToStop; diff --git a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/RaptorInVehicleCostCalculator.java b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/RaptorInVehicleCostCalculator.java index f23f8e918b8..cc34dcda6d7 100644 --- a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/RaptorInVehicleCostCalculator.java +++ b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/RaptorInVehicleCostCalculator.java @@ -1,3 +1,22 @@ +/* *********************************************************************** * + * project: org.matsim.* * + * + * * + * *********************************************************************** * + * * + * copyright : (C) 2023 by the members listed in the COPYING, * + * LICENSE and WARRANTY file. * + * email : info at matsim dot org * + * * + * *********************************************************************** * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * See also COPYING, LICENSE and WARRANTY file * + * * + * *********************************************************************** */ package ch.sbb.matsim.routing.pt.raptor; import org.matsim.api.core.v01.population.Person; diff --git a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/RaptorStopFinder.java b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/RaptorStopFinder.java index 78e42955fd8..e2ea7ef7edc 100644 --- a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/RaptorStopFinder.java +++ b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/RaptorStopFinder.java @@ -1,3 +1,22 @@ +/* *********************************************************************** * + * project: org.matsim.* * + * + * * + * *********************************************************************** * + * * + * copyright : (C) 2023 by the members listed in the COPYING, * + * LICENSE and WARRANTY file. * + * email : info at matsim dot org * + * * + * *********************************************************************** * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * See also COPYING, LICENSE and WARRANTY file * + * * + * *********************************************************************** */ package ch.sbb.matsim.routing.pt.raptor; import org.matsim.api.core.v01.population.Person; @@ -14,7 +33,7 @@ @FunctionalInterface public interface RaptorStopFinder { - public enum Direction { ACCESS, EGRESS } + enum Direction { ACCESS, EGRESS } List findStops(Facility fromFacility, Facility toFacility, Person person, double departureTime, Attributes routingAttributes, RaptorParameters parameters, SwissRailRaptorData data, Direction type); diff --git a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/RaptorTransferCostCalculator.java b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/RaptorTransferCostCalculator.java index 402a1c83b5a..1a114db0a61 100644 --- a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/RaptorTransferCostCalculator.java +++ b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/RaptorTransferCostCalculator.java @@ -1,3 +1,22 @@ +/* *********************************************************************** * + * project: org.matsim.* * + * + * * + * *********************************************************************** * + * * + * copyright : (C) 2023 by the members listed in the COPYING, * + * LICENSE and WARRANTY file. * + * email : info at matsim dot org * + * * + * *********************************************************************** * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * See also COPYING, LICENSE and WARRANTY file * + * * + * *********************************************************************** */ package ch.sbb.matsim.routing.pt.raptor; import java.util.function.Supplier; diff --git a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/Transfer.java b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/Transfer.java index 52a091d7834..8a3dc0e588b 100644 --- a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/Transfer.java +++ b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/Transfer.java @@ -1,3 +1,22 @@ +/* *********************************************************************** * + * project: org.matsim.* * + * + * * + * *********************************************************************** * + * * + * copyright : (C) 2023 by the members listed in the COPYING, * + * LICENSE and WARRANTY file. * + * email : info at matsim dot org * + * * + * *********************************************************************** * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * See also COPYING, LICENSE and WARRANTY file * + * * + * *********************************************************************** */ package ch.sbb.matsim.routing.pt.raptor; import ch.sbb.matsim.routing.pt.raptor.SwissRailRaptorData.RRouteStop; diff --git a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/CapacityDependentScoringTest.java b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/CapacityDependentScoringTest.java index 30839b65d84..31ebe0fa112 100644 --- a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/CapacityDependentScoringTest.java +++ b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/CapacityDependentScoringTest.java @@ -1,3 +1,22 @@ +/* *********************************************************************** * + * project: org.matsim.* * + * + * * + * *********************************************************************** * + * * + * copyright : (C) 2023 by the members listed in the COPYING, * + * LICENSE and WARRANTY file. * + * email : info at matsim dot org * + * * + * *********************************************************************** * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * See also COPYING, LICENSE and WARRANTY file * + * * + * *********************************************************************** */ package ch.sbb.matsim.routing.pt.raptor; import org.junit.Assert; diff --git a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/OccupancyTrackerTest.java b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/OccupancyTrackerTest.java index 734c40cd43f..4e9b916dde4 100644 --- a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/OccupancyTrackerTest.java +++ b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/OccupancyTrackerTest.java @@ -1,3 +1,22 @@ +/* *********************************************************************** * + * project: org.matsim.* * + * + * * + * *********************************************************************** * + * * + * copyright : (C) 2023 by the members listed in the COPYING, * + * LICENSE and WARRANTY file. * + * email : info at matsim dot org * + * * + * *********************************************************************** * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * See also COPYING, LICENSE and WARRANTY file * + * * + * *********************************************************************** */ package ch.sbb.matsim.routing.pt.raptor; import ch.sbb.matsim.routing.pt.raptor.OccupancyData.DepartureData; @@ -114,7 +133,7 @@ public void testGetNextDeparture() { @Test public void testGetDepartureData() { Fixture f = new Fixture(); - + EventsManager events = EventsUtils.createEventsManager(); OccupancyData occData = new OccupancyData(); OccupancyTracker tracker = new OccupancyTracker(occData, f.scenario, new DefaultRaptorInVehicleCostCalculator(), events, new SubpopulationScoringParameters(f.scenario)); diff --git a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/RaptorStopFinderTest.java b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/RaptorStopFinderTest.java index ff34ae992b9..28914b2fee4 100644 --- a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/RaptorStopFinderTest.java +++ b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/RaptorStopFinderTest.java @@ -1,3 +1,22 @@ +/* *********************************************************************** * + * project: org.matsim.* * + * + * * + * *********************************************************************** * + * * + * copyright : (C) 2023 by the members listed in the COPYING, * + * LICENSE and WARRANTY file. * + * email : info at matsim dot org * + * * + * *********************************************************************** * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * See also COPYING, LICENSE and WARRANTY file * + * * + * *********************************************************************** */ package ch.sbb.matsim.routing.pt.raptor; import ch.sbb.matsim.config.SwissRailRaptorConfigGroup; @@ -43,8 +62,8 @@ public class RaptorStopFinderTest { - private Facility fromFac = new FakeFacility(new Coord(0, 0), Id.create("AA", Link.class)); // stop A - private Facility toFac = new FakeFacility(new Coord(100000, 0), Id.create("XX", Link.class)); // stop X + private final Facility fromFac = new FakeFacility(new Coord(0, 0), Id.create("AA", Link.class)); // stop A + private final Facility toFac = new FakeFacility(new Coord(100000, 0), Id.create("XX", Link.class)); // stop X /** Empty Initial Search Radius @@ -56,10 +75,10 @@ public class RaptorStopFinderTest { * * This functionality is tested for the two RaptorStopFinders: 1) DefaultStopFinder and 2) RandomAccessEgressModeRaptorStopFinder * For each RaptorStopFinder there is one test where StopFilterAttributes are not used to exlclude stops, and one test - * where StopFilterAttributes are used. + * where StopFilterAttributes are used. */ - - + + @Test public void testDefaultStopFinder_EmptyInitialSearchRadius() { /* General Radius includes no stops. Search_Extension_Radius is 0 @@ -88,9 +107,9 @@ public void testDefaultStopFinder_EmptyInitialSearchRadius() { List legs = raptor.calcRoute(DefaultRoutingRequest.withoutAttributes(this.fromFac, this.toFac, 7 * 3600, f0.dummyPerson)); Assert.assertNull("The router should not find a route and return null, but did return something else.", legs); - + } - + /* General Radius includes stop B. Search_Extension_Radius is 0. Expected: Stop Finder will only find stop B. Lines C, D, and E are set to very fast, so as to check that only stop B is included. @@ -215,9 +234,9 @@ public void testDefaultStopFinder_EmptyInitialSearchRadius_StopFilterAttributes( SwissRailRaptor raptor = new SwissRailRaptor.Builder(data, f0.scenario.getConfig()).with(stopFinder).build(); List legs = raptor.calcRoute(DefaultRoutingRequest.withoutAttributes(this.fromFac, this.toFac, 7 * 3600, f0.dummyPerson)); - + Assert.assertNull("The router should not find a route and return null, but did return something else.", legs); - + } /* General Radius includes stop B. Search_Extension_Radius is 0. @@ -405,9 +424,9 @@ public void testRandomAccessEgressModeRaptorStopFinder_EmptyInitialSearchRadius( List legs = raptor.calcRoute(DefaultRoutingRequest.withoutAttributes(this.fromFac, this.toFac, 7 * 3600, f0.dummyPerson)); Assert.assertNull("The router should not find a route and return null, but did return something else.", legs); - + } - + /* General Radius includes stop B. Search_Extension_Radius is 0. Expected: Stop Finder will only find stop B. Lines C, D, and E are set to very fast, so as to check that only stop B is included. @@ -535,7 +554,7 @@ public void testRandomAccessEgressModeRaptorStopFinder_EmptyInitialSearchRadius_ List legs = raptor.calcRoute(DefaultRoutingRequest.withoutAttributes(this.fromFac, this.toFac, 7 * 3600, f0.dummyPerson)); Assert.assertNull("The router should not find a route and return null, but did return something else.", legs); - + } /* General Radius includes stop B. Search_Extension_Radius is 0. @@ -709,7 +728,7 @@ Initial_Search_Radius includes B (not "walkAccessible") * * This functionality is tested for the two RaptorStopFinders: 1) DefaultStopFinder and 2) RandomAccessEgressModeRaptorStopFinder * For each RaptorStopFinder there is one test where StopFilterAttributes are not used to exlclude stops, and one test - * where StopFilterAttributes are used. + * where StopFilterAttributes are used. */ @Test public void testDefaultStopFinder_HalfFullInitialSearchRadius() { @@ -1213,7 +1232,7 @@ public void testRandomAccessEgressModeRaptorStopFinder_HalfFullInitialSearchRadi * * This functionality is tested for the two RaptorStopFinders: 1) DefaultStopFinder and 2) RandomAccessEgressModeRaptorStopFinder * For each RaptorStopFinder there is one test where StopFilterAttributes are not used to exlclude stops, and one test - * where StopFilterAttributes are used. + * where StopFilterAttributes are used. */ @Test public void testDefaultStopFinder_FullInitialSearchRadius() { diff --git a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorCapacitiesTest.java b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorCapacitiesTest.java index 2a836468cb4..a986cb26763 100644 --- a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorCapacitiesTest.java +++ b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorCapacitiesTest.java @@ -1,3 +1,22 @@ +/* *********************************************************************** * + * project: org.matsim.* * + * + * * + * *********************************************************************** * + * * + * copyright : (C) 2023 by the members listed in the COPYING, * + * LICENSE and WARRANTY file. * + * email : info at matsim dot org * + * * + * *********************************************************************** * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * See also COPYING, LICENSE and WARRANTY file * + * * + * *********************************************************************** */ package ch.sbb.matsim.routing.pt.raptor; import ch.sbb.matsim.config.SwissRailRaptorConfigGroup; diff --git a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorInVehicleCostTest.java b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorInVehicleCostTest.java index 3ee20ba0de2..76b098fa73f 100644 --- a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorInVehicleCostTest.java +++ b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorInVehicleCostTest.java @@ -1,3 +1,22 @@ +/* *********************************************************************** * + * project: org.matsim.* * + * + * * + * *********************************************************************** * + * * + * copyright : (C) 2023 by the members listed in the COPYING, * + * LICENSE and WARRANTY file. * + * email : info at matsim dot org * + * * + * *********************************************************************** * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * See also COPYING, LICENSE and WARRANTY file * + * * + * *********************************************************************** */ package ch.sbb.matsim.routing.pt.raptor; import org.junit.Assert; From d7c32fe2bb5e445f3462f379e58de139deeec532 Mon Sep 17 00:00:00 2001 From: u229187 Date: Wed, 11 Oct 2023 15:26:02 +0200 Subject: [PATCH 07/25] add GPL Header to all classes in sbb extensions --- .../matsim/analysis/skims/PTSkimMatrices.java | 19 +++++++++++++++++ .../matsim/analysis/skims/RooftopUtils.java | 19 +++++++++++++++++ .../analysis/skims/StreamingFacilities.java | 19 +++++++++++++++++ .../matsim/mobsim/qsim/SBBTransitModule.java | 19 +++++++++++++++++ .../qsim/pt/SBBTransitEngineQSimModule.java | 19 +++++++++++++++++ .../analysis/skims/RooftopUtilsTest.java | 21 ++++++++++++++++++- 6 files changed, 115 insertions(+), 1 deletion(-) diff --git a/contribs/sbb-extensions/src/main/java/ch/sbb/matsim/analysis/skims/PTSkimMatrices.java b/contribs/sbb-extensions/src/main/java/ch/sbb/matsim/analysis/skims/PTSkimMatrices.java index 1916ddbd263..56121f8558a 100644 --- a/contribs/sbb-extensions/src/main/java/ch/sbb/matsim/analysis/skims/PTSkimMatrices.java +++ b/contribs/sbb-extensions/src/main/java/ch/sbb/matsim/analysis/skims/PTSkimMatrices.java @@ -1,3 +1,22 @@ +/* *********************************************************************** * + * project: org.matsim.* * + * + * * + * *********************************************************************** * + * * + * copyright : (C) 2023 by the members listed in the COPYING, * + * LICENSE and WARRANTY file. * + * email : info at matsim dot org * + * * + * *********************************************************************** * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * See also COPYING, LICENSE and WARRANTY file * + * * + * *********************************************************************** */ package ch.sbb.matsim.analysis.skims; import ch.sbb.matsim.analysis.skims.RooftopUtils.ODConnection; diff --git a/contribs/sbb-extensions/src/main/java/ch/sbb/matsim/analysis/skims/RooftopUtils.java b/contribs/sbb-extensions/src/main/java/ch/sbb/matsim/analysis/skims/RooftopUtils.java index f7937b6d763..809f4582a65 100644 --- a/contribs/sbb-extensions/src/main/java/ch/sbb/matsim/analysis/skims/RooftopUtils.java +++ b/contribs/sbb-extensions/src/main/java/ch/sbb/matsim/analysis/skims/RooftopUtils.java @@ -1,3 +1,22 @@ +/* *********************************************************************** * + * project: org.matsim.* * + * + * * + * *********************************************************************** * + * * + * copyright : (C) 2023 by the members listed in the COPYING, * + * LICENSE and WARRANTY file. * + * email : info at matsim dot org * + * * + * *********************************************************************** * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * See also COPYING, LICENSE and WARRANTY file * + * * + * *********************************************************************** */ package ch.sbb.matsim.analysis.skims; import ch.sbb.matsim.routing.pt.raptor.SwissRailRaptorCore.TravelInfo; diff --git a/contribs/sbb-extensions/src/main/java/ch/sbb/matsim/analysis/skims/StreamingFacilities.java b/contribs/sbb-extensions/src/main/java/ch/sbb/matsim/analysis/skims/StreamingFacilities.java index a2e9833d342..d75de1a5080 100644 --- a/contribs/sbb-extensions/src/main/java/ch/sbb/matsim/analysis/skims/StreamingFacilities.java +++ b/contribs/sbb-extensions/src/main/java/ch/sbb/matsim/analysis/skims/StreamingFacilities.java @@ -1,3 +1,22 @@ +/* *********************************************************************** * + * project: org.matsim.* * + * + * * + * *********************************************************************** * + * * + * copyright : (C) 2023 by the members listed in the COPYING, * + * LICENSE and WARRANTY file. * + * email : info at matsim dot org * + * * + * *********************************************************************** * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * See also COPYING, LICENSE and WARRANTY file * + * * + * *********************************************************************** */ package ch.sbb.matsim.analysis.skims; import org.matsim.api.core.v01.Id; diff --git a/contribs/sbb-extensions/src/main/java/ch/sbb/matsim/mobsim/qsim/SBBTransitModule.java b/contribs/sbb-extensions/src/main/java/ch/sbb/matsim/mobsim/qsim/SBBTransitModule.java index 81fd1456970..8b43874f104 100644 --- a/contribs/sbb-extensions/src/main/java/ch/sbb/matsim/mobsim/qsim/SBBTransitModule.java +++ b/contribs/sbb-extensions/src/main/java/ch/sbb/matsim/mobsim/qsim/SBBTransitModule.java @@ -1,3 +1,22 @@ +/* *********************************************************************** * + * project: org.matsim.* * + * + * * + * *********************************************************************** * + * * + * copyright : (C) 2023 by the members listed in the COPYING, * + * LICENSE and WARRANTY file. * + * email : info at matsim dot org * + * * + * *********************************************************************** * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * See also COPYING, LICENSE and WARRANTY file * + * * + * *********************************************************************** */ package ch.sbb.matsim.mobsim.qsim; import ch.sbb.matsim.config.SBBTransitConfigGroup; diff --git a/contribs/sbb-extensions/src/main/java/ch/sbb/matsim/mobsim/qsim/pt/SBBTransitEngineQSimModule.java b/contribs/sbb-extensions/src/main/java/ch/sbb/matsim/mobsim/qsim/pt/SBBTransitEngineQSimModule.java index 30753a4a576..c05b7852bab 100644 --- a/contribs/sbb-extensions/src/main/java/ch/sbb/matsim/mobsim/qsim/pt/SBBTransitEngineQSimModule.java +++ b/contribs/sbb-extensions/src/main/java/ch/sbb/matsim/mobsim/qsim/pt/SBBTransitEngineQSimModule.java @@ -1,3 +1,22 @@ +/* *********************************************************************** * + * project: org.matsim.* * + * + * * + * *********************************************************************** * + * * + * copyright : (C) 2023 by the members listed in the COPYING, * + * LICENSE and WARRANTY file. * + * email : info at matsim dot org * + * * + * *********************************************************************** * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * See also COPYING, LICENSE and WARRANTY file * + * * + * *********************************************************************** */ package ch.sbb.matsim.mobsim.qsim.pt; import org.matsim.core.mobsim.qsim.AbstractQSimModule; diff --git a/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/analysis/skims/RooftopUtilsTest.java b/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/analysis/skims/RooftopUtilsTest.java index 560ff62468c..7f42f0b8f0b 100644 --- a/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/analysis/skims/RooftopUtilsTest.java +++ b/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/analysis/skims/RooftopUtilsTest.java @@ -1,3 +1,22 @@ +/* *********************************************************************** * + * project: org.matsim.* * + * + * * + * *********************************************************************** * + * * + * copyright : (C) 2023 by the members listed in the COPYING, * + * LICENSE and WARRANTY file. * + * email : info at matsim dot org * + * * + * *********************************************************************** * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * See also COPYING, LICENSE and WARRANTY file * + * * + * *********************************************************************** */ package ch.sbb.matsim.analysis.skims; import ch.sbb.matsim.analysis.skims.RooftopUtils.ODConnection; @@ -410,4 +429,4 @@ public void testCalculationShares_singleDepartureLate() { Map shares = RooftopUtils.calcConnectionShares(connections, Time.parseTime("07:00:00"), Time.parseTime("08:00:00")); Assert.assertEquals(1.0, shares.get(c0), 1e-7); } -} \ No newline at end of file +} From be3cd5a2796aa664b02d349270618adcda1a3b2e Mon Sep 17 00:00:00 2001 From: u229187 Date: Wed, 11 Oct 2023 15:41:35 +0200 Subject: [PATCH 08/25] remove old Attribute reference in TransitScheduleUtils --- .../transitSchedule/TransitScheduleUtils.java | 33 +++---------------- .../core/scenario/ScenarioLoaderImplTest.java | 27 --------------- 2 files changed, 5 insertions(+), 55 deletions(-) diff --git a/matsim/src/main/java/org/matsim/pt/transitSchedule/TransitScheduleUtils.java b/matsim/src/main/java/org/matsim/pt/transitSchedule/TransitScheduleUtils.java index dca8c47a25b..5e59637bed3 100644 --- a/matsim/src/main/java/org/matsim/pt/transitSchedule/TransitScheduleUtils.java +++ b/matsim/src/main/java/org/matsim/pt/transitSchedule/TransitScheduleUtils.java @@ -29,43 +29,20 @@ /** * Helper class for commonly used operations on TransitSchedules - * + * * @author Thibaut Dubernet, gleich * */ public final class TransitScheduleUtils { - // Logic gotten from PopulationUtils, but I am actually a bit unsure about the value of those methods now that - // attributable is the only way to get attributes... - - public static Object getStopFacilityAttribute(TransitStopFacility facility, String key) { - return facility.getAttributes().getAttribute( key ); - } - public static void putStopFacilityAttribute(TransitStopFacility facility, String key, Object value ) { - facility.getAttributes().putAttribute( key, value ) ; + private TransitScheduleUtils() { } - public static Object removeStopFacilityAttribute( TransitStopFacility facility, String key ) { - return facility.getAttributes().removeAttribute( key ); - } - - public static Object getLineAttribute(TransitLine facility, String key) { - return facility.getAttributes().getAttribute( key ); - } - - public static void putLineAttribute(TransitLine facility, String key, Object value ) { - facility.getAttributes().putAttribute( key, value ) ; - } - - public static Object removeLineAttribute( TransitLine facility, String key ) { - return facility.getAttributes().removeAttribute( key ); - } - - public final static QuadTree createQuadTreeOfTransitStopFacilities(TransitSchedule transitSchedule) { + public static QuadTree createQuadTreeOfTransitStopFacilities(TransitSchedule transitSchedule) { return createQuadTreeOfTransitStopFacilities(transitSchedule.getFacilities().values()); } - - public final static QuadTree createQuadTreeOfTransitStopFacilities(Collection transitStopFacilities) { + + public static QuadTree createQuadTreeOfTransitStopFacilities(Collection transitStopFacilities) { double minX = Double.POSITIVE_INFINITY; double minY = Double.POSITIVE_INFINITY; double maxX = Double.NEGATIVE_INFINITY; diff --git a/matsim/src/test/java/org/matsim/core/scenario/ScenarioLoaderImplTest.java b/matsim/src/test/java/org/matsim/core/scenario/ScenarioLoaderImplTest.java index 5004d9aa606..ed651429022 100644 --- a/matsim/src/test/java/org/matsim/core/scenario/ScenarioLoaderImplTest.java +++ b/matsim/src/test/java/org/matsim/core/scenario/ScenarioLoaderImplTest.java @@ -97,33 +97,6 @@ public void testLoadScenario_loadPersonAttributes() { Assert.assertTrue( caughtException ); } - @Test - public void testLoadScenario_loadTransitLinesAttributes() { - Config config = ConfigUtils.loadConfig(IOUtils.extendUrl(this.util.classInputResourcePath(), "transitConfig.xml")); - config.transit().setTransitLinesAttributesFile("transitLinesAttributes.xml"); - config.transit().setInsistingOnUsingDeprecatedAttributeFiles(true); - Scenario scenario = ScenarioUtils.loadScenario(config); - Assert.assertEquals( - "unexpected attribute value", - "world", - TransitScheduleUtils.getLineAttribute( - scenario.getTransitSchedule().getTransitLines().get(Id.create("Blue Line", TransitLine.class)), - "hello")); - } - - @Test - public void testLoadScenario_loadTransitStopsAttributes() { - Config config = ConfigUtils.loadConfig(IOUtils.extendUrl(this.util.classInputResourcePath(), "transitConfig.xml")); - config.transit().setTransitStopsAttributesFile("transitStopsAttributes.xml"); - config.transit().setInsistingOnUsingDeprecatedAttributeFiles(true); - Scenario scenario = ScenarioUtils.loadScenario(config); - Assert.assertEquals( - "unexpected attribute value", - Boolean.TRUE, - TransitScheduleUtils.getStopFacilityAttribute( - scenario.getTransitSchedule().getFacilities().get(Id.create(1, TransitStopFacility.class)), - "hasP+R")); - } @Test public void testLoadScenario_loadFacilitiesAttributes() { From f742646629ef017646918e9aac996f3343bf5390 Mon Sep 17 00:00:00 2001 From: u229187 Date: Wed, 11 Oct 2023 16:11:20 +0200 Subject: [PATCH 09/25] add optional access and egresstimes to pt stops --- .../pt/raptor/DefaultRaptorStopFinder.java | 17 +++++++++++------ .../transitSchedule/TransitScheduleUtils.java | 12 ++++++++++++ 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/DefaultRaptorStopFinder.java b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/DefaultRaptorStopFinder.java index 71a0d2bbff9..073d6955b91 100644 --- a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/DefaultRaptorStopFinder.java +++ b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/DefaultRaptorStopFinder.java @@ -31,6 +31,7 @@ import org.matsim.core.utils.collections.QuadTree; import org.matsim.core.utils.geometry.CoordUtils; import org.matsim.facilities.Facility; +import org.matsim.pt.transitSchedule.TransitScheduleUtils; import org.matsim.pt.transitSchedule.api.TransitStopFacility; import org.matsim.utils.objectattributes.attributable.Attributes; @@ -86,7 +87,8 @@ private List findAccessStops(Facility fromFacility, Facility toFaci List stops = findNearbyStops(fromFacility, parameters, data); List initialStops = stops.stream().map(stop -> { double beelineDistance = CoordUtils.calcEuclideanDistance(stop.getCoord(), fromFacility.getCoord()); - double travelTime = Math.ceil(beelineDistance / parameters.getBeelineWalkSpeed()); + double accessTime = TransitScheduleUtils.getStopAccessTime(stop); + double travelTime = Math.ceil(beelineDistance / parameters.getBeelineWalkSpeed()) + accessTime; double disutility = travelTime * -parameters.getMarginalUtilityOfTravelTime_utl_s(TransportMode.walk); return new InitialStop(stop, disutility, travelTime, beelineDistance * distanceFactor, TransportMode.walk); }).collect(Collectors.toList()); @@ -103,7 +105,8 @@ private List findEgressStops(Facility fromFacility, Facility toFaci List stops = findNearbyStops(toFacility, parameters, data); List initialStops = stops.stream().map(stop -> { double beelineDistance = CoordUtils.calcEuclideanDistance(stop.getCoord(), toFacility.getCoord()); - double travelTime = Math.ceil(beelineDistance / parameters.getBeelineWalkSpeed()); + double egressTime = TransitScheduleUtils.getStopEgressTime(stop); + double travelTime = Math.ceil(beelineDistance / parameters.getBeelineWalkSpeed()) + egressTime; double disutility = travelTime * -parameters.getMarginalUtilityOfTravelTime_utl_s(TransportMode.walk); return new InitialStop(stop, disutility, travelTime, beelineDistance * distanceFactor, TransportMode.walk); }).collect(Collectors.toList()); @@ -208,10 +211,11 @@ private void addInitialStopsForParamSet(Facility fromFacility, Facility toFacili if (direction == Direction.ACCESS) { Leg transferLeg = PopulationUtils.createLeg(TransportMode.walk); Route transferRoute = RouteUtils.createGenericRouteImpl(stopFacility.getLinkId(), stop.getLinkId()); - transferRoute.setTravelTime(0); + double accessTime = TransitScheduleUtils.getStopAccessTime(stop); + transferRoute.setTravelTime(accessTime); transferRoute.setDistance(0); transferLeg.setRoute(transferRoute); - transferLeg.setTravelTime(0); + transferLeg.setTravelTime(accessTime); List tmp = new ArrayList<>(routeParts.size() + 1); tmp.addAll(routeParts); @@ -220,10 +224,11 @@ private void addInitialStopsForParamSet(Facility fromFacility, Facility toFacili } else { Leg transferLeg = PopulationUtils.createLeg(TransportMode.walk); Route transferRoute = RouteUtils.createGenericRouteImpl(stop.getLinkId(), stopFacility.getLinkId()); - transferRoute.setTravelTime(0); + double egressTime = TransitScheduleUtils.getStopEgressTime(stop); + transferRoute.setTravelTime(egressTime); transferRoute.setDistance(0); transferLeg.setRoute(transferRoute); - transferLeg.setTravelTime(0); + transferLeg.setTravelTime(egressTime); List tmp = new ArrayList<>(routeParts.size() + 1); tmp.add(transferLeg); diff --git a/matsim/src/main/java/org/matsim/pt/transitSchedule/TransitScheduleUtils.java b/matsim/src/main/java/org/matsim/pt/transitSchedule/TransitScheduleUtils.java index 5e59637bed3..daa09376a11 100644 --- a/matsim/src/main/java/org/matsim/pt/transitSchedule/TransitScheduleUtils.java +++ b/matsim/src/main/java/org/matsim/pt/transitSchedule/TransitScheduleUtils.java @@ -35,9 +35,21 @@ */ public final class TransitScheduleUtils { + public final static String ACCESSTIME_ATTRIBUTE = "accessTime"; + public final static String EGRESSTIME_ATTRIBUTE = "egressTime"; private TransitScheduleUtils() { } + public static double getStopAccessTime(TransitStopFacility stopFacility){ + Object accessTime = stopFacility.getAttributes().getAttribute(ACCESSTIME_ATTRIBUTE); + return accessTime!=null?(double) accessTime:0.0; + } + + public static double getStopEgressTime(TransitStopFacility stopFacility){ + Object egressTime = stopFacility.getAttributes().getAttribute(EGRESSTIME_ATTRIBUTE); + return egressTime!=null?(double) egressTime:0.0; + } + public static QuadTree createQuadTreeOfTransitStopFacilities(TransitSchedule transitSchedule) { return createQuadTreeOfTransitStopFacilities(transitSchedule.getFacilities().values()); } From 1fdcef84091c7cfc96bf9c66f064e283cbb6311c Mon Sep 17 00:00:00 2001 From: Marcel Rieser Date: Wed, 11 Oct 2023 16:26:05 +0200 Subject: [PATCH 10/25] rename some config group according to new naming conventions See #1276 - ReplanningAnnealer --> replanningAnnealer - TimeAllocationMutator --> timeAllocationMutator - JDEQSim --> jdeqsim - controler --> controller - planCalcScore --> scoring - planscalcroute --> routing - strategy --> replanning - parallelEventHandling --> eventsManager --- ...essibilityComputationShutdownListener.java | 11 +- .../accessibility/AccessibilityUtils.java | 52 +- ...ccessibilityExpContributionCalculator.java | 26 +- ...orAccessibilityContributionCalculator.java | 12 +- ...ccessibilityExpContributionCalculator.java | 12 +- ...orAccessibilityContributionCalculator.java | 16 +- .../TravelTimeBasedTravelDisutility.java | 10 +- ...erAccessibilityContributionCalculator.java | 26 +- .../utils/LeastCostPathTreeExtended.java | 68 +- .../run/AccessibilityIntegrationTest.java | 6 +- .../matsim/application/MATSimApplication.java | 4 +- .../FreightDemandGeneration.java | 4 +- ...rateSmallScaleCommercialTrafficDemand.java | 4 +- .../application/MATSimApplicationTest.java | 6 +- .../RunTaxiPTIntermodalExample.java | 4 +- .../bicycle/BicycleTravelDisutility.java | 12 +- .../BicycleTravelDisutilityFactory.java | 20 +- .../bicycle/run/RunBicycleExample.java | 6 +- .../contrib/bicycle/run/BicycleTest.java | 6 +- .../contrib/cadyts/car/CadytsCarIT.java | 6 +- .../matsim/contrib/cadyts/pt/CadytsPtIT.java | 7 +- .../demand/VehicleChoiceAgentImpl.java | 5 +- .../scoring/CarsharingLegScoringFunction.java | 72 +- .../runExample/RunCarsharingIT.java | 4 +- .../DefaultCommercialJobGenerator.java | 2 +- .../RunJointDemandCarToggleJspritExample.java | 12 +- .../examples/RunJointDemandCarExample.java | 12 +- .../examples/RunJointDemandDRTExample.java | 12 +- .../RandomizingTransitRouterIT.java | 52 +- .../DecongestionControlerListener.java | 2 +- .../DiscreteModeChoiceConfigurator.java | 32 +- .../utils/ModeChoiceInTheLoopChecker.java | 8 +- .../drt/extension/DrtTestScenario.java | 14 +- .../extension/fiss/RunFissDrtScenarioIT.java | 20 +- .../eshifts/run/RunEShiftDrtScenarioIT.java | 20 +- .../run/RunMultiHubShiftDrtScenarioIT.java | 20 +- .../shifts/run/RunShiftDrtScenarioIT.java | 20 +- .../MultiModeDrtMainModeIdentifier.java | 4 +- .../contrib/drt/run/DrtConfigGroup.java | 6 +- .../matsim/contrib/drt/run/DrtConfigs.java | 16 +- .../contrib/drt/speedup/DrtSpeedUp.java | 8 +- .../MultiModeDrtMainModeIdentifierTest.java | 4 +- .../contrib/drt/speedup/DrtSpeedUpTest.java | 4 +- .../drt/util/DrtEventsReadersTest.java | 4 +- .../dvrp/util/DvrpEventsReadersTest.java | 2 +- .../emissions/PositionEmissionsModule.java | 4 +- .../example/CreateEmissionConfig.java | 58 +- .../emissions/TestPositionEmissionModule.java | 18 +- .../ev/charging/VehicleChargingHandler.java | 4 +- .../ev/routing/EvNetworkRoutingProvider.java | 8 +- .../RunPassengerPlansFromScratch.java | 4 +- .../freight/carrier/CarrierModuleTest.java | 6 +- .../EquilWithCarrierWithPersonsIT.java | 4 +- ...istanceConstraintFromVehiclesFileTest.java | 10 +- .../jsprit/DistanceConstraintTest.java | 22 +- .../contrib/hybridsim/run/RunExample.java | 7 +- .../modechoice/commands/StrategyOptions.java | 8 +- .../org/matsim/modechoice/TestScenario.java | 22 +- .../SelectSingleTripModeStrategyTest.java | 4 +- .../DestinationChoiceContext.java | 70 +- .../locationchoice/LocationChoiceIT.java | 8 +- .../FrozenEpsilonLocaChoiceIT.java | 8 +- .../MatrixBasedPtModule.java | 8 +- .../contrib/matrixbasedptrouter/PtMatrix.java | 64 +- .../RunMatrixBasedPTRouterExample.java | 7 +- .../contrib/multimodal/MultiModalModule.java | 14 +- .../router/util/BikeTravelTime.java | 52 +- .../router/util/BikeTravelTimeFactory.java | 18 +- .../util/MultiModalTravelTimeFactory.java | 12 +- .../util/TransitWalkTravelTimeFactory.java | 18 +- .../router/util/UnknownTravelTime.java | 22 +- .../router/util/UnknownTravelTimeFactory.java | 14 +- .../router/util/WalkTravelTime.java | 81 +- .../router/util/WalkTravelTimeFactory.java | 18 +- .../MultiModalControlerListenerTest.java | 20 +- .../multimodal/MultiModalTripRouterTest.java | 70 +- .../pt/MultiModalPTCombinationTest.java | 64 +- .../multimodal/simengine/StuckAgentTest.java | 52 +- ...llTimeDistanceTravelDisutilityFactory.java | 12 +- .../org/matsim/contrib/noise/NoiseIT.java | 816 +++++++++--------- .../otfvis/OTFVisFileWriterModule.java | 3 +- .../org/matsim/contrib/otfvis/OTFVisIT.java | 10 +- .../parkingproxy/run/RunWithParkingProxy.java | 12 +- .../distributed/MasterControler.java | 10 +- .../distributed/SlaveControler.java | 8 +- ...lanStrategyTranslationAndRegistration.java | 4 +- .../contrib/pseudosimulation/RunPSimTest.java | 5 +- .../railsim/integration/SnzActivities.java | 18 +- .../RoadPricingNetworkRouting.java | 10 +- .../PlansCalcRouteWithTollOrNotTest.java | 10 +- .../TollTravelCostCalculatorTest.java | 8 +- .../examples/RunCarsharing.java | 8 +- .../examples/RunParisVelib.java | 4 +- .../examples/RunTeleportationBikesharing.java | 10 +- .../matsim/contrib/shared_mobility/RunIT.java | 4 +- .../RunSimpleResponsiveSignalExample.java | 60 +- .../contrib/signals/builder/Fixture.java | 4 +- ...aultPlanbasedSignalSystemControllerIT.java | 288 +++---- .../controller/laemmerFix/LaemmerIT.java | 238 ++--- .../signals/controller/sylvia/SylviaIT.java | 26 +- .../contrib/signals/oneagent/Fixture.java | 24 +- ...eMoneyEventsForUtilityOfBeingTogether.java | 8 +- .../taxi/util/TaxiEventsReadersTest.java | 4 +- .../contrib/vsp/scenario/SnzActivities.java | 18 +- ...ScoringParametersFromPersonAttributes.java | 16 +- ...lityTravelDisutilityCalculatorFactory.java | 4 +- ...sionTravelDisutilityCalculatorFactory.java | 4 +- .../userBenefits/UserBenefitsCalculator.java | 32 +- .../BuildingEnergyAnalyzerMain.java | 30 +- ...LinkActivityCalculationFromEventsMain.java | 36 +- .../MultiModeCountsControlerListener.java | 13 +- .../handlers/MarginalSumScoringFunction.java | 56 +- ...llTimeDistanceTravelDisutilityFactory.java | 10 +- .../TollDisutilityCalculatorFactory.java | 10 +- .../TollTravelDisutilityCalculator.java | 28 +- .../pendlermatrix/PersonRouterFilter.java | 18 +- .../demandde/pendlermatrix/RouterFilter.java | 12 +- .../TravelTimeToWorkCalculator.java | 4 +- .../playground/vsp/ev/RunUrbanEVExample.java | 11 +- .../java/playground/vsp/ev/UrbanEVModule.java | 12 +- .../vsp/ev/UrbanEVTripsPlanner.java | 4 +- .../SplitActivityTypesBasedOnDuration.java | 38 +- .../vsp/parkAndRide/example/PRRunner.java | 24 +- .../InitialPlanKeeperPlanRemoval.java | 11 +- ...UtilityOfMoneyPersonScoringParameters.java | 14 +- ...omPersonAttributesNoSubpopulationTest.java | 14 +- ...ingParametersFromPersonAttributesTest.java | 16 +- .../drtAndPt/PtAlongALine2Test.java | 22 +- .../drtAndPt/PtAlongALineTest.java | 12 +- .../ModalDistanceAndCountsCadytsIT.java | 12 +- ...odalDistanceCadytsMultipleDistancesIT.java | 14 +- .../ModalDistanceCadytsSingleDistanceIT.java | 10 +- .../marginals/TripEventHandlerTest.java | 6 +- .../AdvancedMarginalCongestionPricingIT.java | 12 +- ...tionHandlerFlowSpillbackQueueQsimTest.java | 4 +- .../MarginalCongestionHandlerV3Test.java | 4 +- .../vsp/ev/CreateUrbanEVTestScenario.java | 10 +- .../vsp/pt/fare/PtTripFareEstimatorTest.java | 8 +- ...nScoringParametersNoSubpopulationTest.java | 10 +- ...ityOfMoneyPersonScoringParametersTest.java | 12 +- .../IndividualRaptorParametersForPerson.java | 6 +- .../routing/pt/raptor/OccupancyData.java | 1 - .../matsim/routing/pt/raptor/RaptorUtils.java | 14 +- .../matsim/analysis/LegHistogramListener.java | 7 +- .../analysis/LinkStatsControlerListener.java | 6 +- .../ModeChoiceCoverageControlerListener.java | 14 +- .../analysis/ModeStatsControlerListener.java | 23 +- .../matsim/analysis/PHbyModeCalculator.java | 7 +- .../matsim/analysis/PKMbyModeCalculator.java | 7 +- .../analysis/ScoreStatsControlerListener.java | 16 +- .../matsim/analysis/TravelDistanceStats.java | 30 +- .../org/matsim/core/config/CommandLine.java | 60 +- .../java/org/matsim/core/config/Config.java | 50 +- .../core/config/ConfigReaderMatsimV2.java | 12 +- .../org/matsim/core/config/ConfigUtils.java | 3 +- .../config/ConfigWriterHandlerImplV2.java | 58 +- .../ConfigConsistencyCheckerImpl.java | 26 +- .../VspConfigConsistencyCheckerImpl.java | 13 +- ...gGroup.java => ControllerConfigGroup.java} | 8 +- ...oup.java => EventsManagerConfigGroup.java} | 18 +- ...gGroup.java => ReplanningConfigGroup.java} | 30 +- ...nfigGroup.java => RoutingConfigGroup.java} | 62 +- ...nfigGroup.java => ScoringConfigGroup.java} | 58 +- .../TimeAllocationMutatorConfigGroup.java | 44 +- .../matsim/core/controler/NewControler.java | 10 +- .../controler/OutputDirectoryHierarchy.java | 20 +- .../TerminateAtFixedIterationNumber.java | 6 +- .../corelisteners/DumpDataAtEndImpl.java | 14 +- .../corelisteners/EventsHandlingImpl.java | 18 +- .../corelisteners/PlansDumpingImpl.java | 6 +- .../core/events/MatsimEventsReader.java | 4 +- .../SimStepParallelEventsManagerImpl.java | 4 +- .../core/mobsim/DefaultMobsimModule.java | 8 +- .../mobsim/jdeqsim/JDEQSimConfigGroup.java | 2 +- .../core/mobsim/qsim/PreplanningEngine.java | 2 +- .../core/population/PopulationUtils.java | 26 +- .../core/replanning/StrategyManager.java | 22 +- .../replanning/StrategyManagerModule.java | 6 +- .../annealing/ReplanningAnnealer.java | 16 +- .../ReplanningAnnealerConfigGroup.java | 4 +- .../selectors/ExpBetaPlanSelector.java | 7 +- .../selectors/PathSizeLogitSelector.java | 28 +- .../replanning/strategies/ChangeExpBeta.java | 4 +- .../DefaultPlanStrategiesModule.java | 13 +- .../replanning/strategies/SelectExpBeta.java | 4 +- .../strategies/SelectPathSizeLogit.java | 4 +- .../router/BeelineTeleportationRouting.java | 6 +- .../core/router/DefaultRoutingModules.java | 6 +- .../FallbackRoutingModuleDefaultImpl.java | 9 +- .../core/router/FreespeedFactorRouting.java | 6 +- .../router/FreespeedFactorRoutingModule.java | 12 +- .../router/LeastCostPathCalculatorModule.java | 8 +- .../matsim/core/router/LinkToLinkRouting.java | 6 +- .../NetworkRoutingInclAccessEgressModule.java | 20 +- .../core/router/NetworkRoutingProvider.java | 7 +- .../matsim/core/router/TripRouterModule.java | 4 +- .../core/router/TripStructureUtils.java | 10 +- .../FreespeedTravelTimeAndDisutility.java | 8 +- ...ngTimeDistanceTravelDisutilityFactory.java | 14 +- .../TravelDisutilityModule.java | 4 +- .../router/util/TravelDisutilityUtils.java | 6 +- .../core/scoring/NewScoreAssignerImpl.java | 14 +- .../matsim/core/scoring/PlansScoringImpl.java | 22 +- .../ScoringFunctionsForPopulation.java | 20 +- .../functions/ActivityUtilityParameters.java | 4 +- .../functions/ModeUtilityParameters.java | 8 +- .../scoring/functions/ScoringParameters.java | 29 +- .../SubpopulationScoringParameters.java | 10 +- .../counts/CountsControlerListener.java | 10 +- .../facilities/FacilitiesFromPopulation.java | 16 +- .../DependencyGraphControlerListener.java | 4 +- .../main/java/org/matsim/pt/PtConstants.java | 10 +- .../pt/ReconstructingUmlaufBuilder.java | 8 +- .../org/matsim/pt/UmlaufInterpolator.java | 4 +- .../matsim/pt/router/TransitRouterConfig.java | 32 +- .../java/org/matsim/run/Events2Snapshot.java | 5 +- .../SnapshotWritersModule.java | 12 +- .../ExampleWithinDayController.java | 4 +- .../WithinDayTravelTimeModule.java | 4 +- .../pt/raptor/RaptorStopFinderTest.java | 30 +- .../raptor/SwissRailRaptorIntermodalTest.java | 28 +- .../pt/raptor/SwissRailRaptorModuleTest.java | 30 +- .../pt/raptor/SwissRailRaptorTest.java | 8 +- ...deChoiceCoverageControlerListenerTest.java | 26 +- .../ModeStatsControlerListenerTest.java | 25 +- .../analysis/PHbyModeCalculatorTest.java | 26 +- .../analysis/PKMbyModeCalculatorTest.java | 18 +- .../ScoreStatsControlerListenerTest.java | 14 +- .../analysis/TravelDistanceStatsTest.java | 16 +- .../core/config/ConfigReaderMatsimV2Test.java | 6 +- .../ConfigConsistencyCheckerImplTest.java | 12 +- ...st.java => ControllerConfigGroupTest.java} | 50 +- ...st.java => ReplanningConfigGroupTest.java} | 26 +- ...pTest.java => RoutingConfigGroupTest.java} | 58 +- ...pTest.java => ScoringConfigGroupTest.java} | 36 +- .../matsim/core/controler/ControlerIT.java | 70 +- .../OutputDirectoryHierarchyTest.java | 14 +- .../core/controler/TerminationTest.java | 18 +- .../TransitControlerIntegrationTest.java | 4 +- .../algorithms/EventWriterJsonTest.java | 6 +- .../mobsim/hermes/HermesRoundaboutTest.java | 16 +- .../mobsim/qsim/AgentNotificationTest.java | 4 +- .../qsim/NetsimRoutingConsistencyTest.java | 56 +- .../core/mobsim/qsim/NodeTransitionTest.java | 252 +++--- ...TeleportationEngineWDistanceCheckTest.java | 34 +- .../core/mobsim/qsim/VehicleSourceTest.java | 6 +- .../FlowEfficiencyCalculatorTest.java | 2 +- .../SimulatedLaneFlowCapacityTest.java | 2 +- .../qnetsimengine/VehicleHandlerTest.java | 2 +- .../routes/RouteFactoryIntegrationTest.java | 6 +- .../annealing/ReplanningAnnealerTest.java | 10 +- .../strategies/InnovationSwitchOffTest.java | 6 +- .../core/router/AStarEuclideanTest.java | 4 +- .../core/router/AStarLandmarksTest.java | 4 +- .../org/matsim/core/router/DijkstraTest.java | 4 +- .../router/FallbackRoutingModuleTest.java | 5 +- ...workRoutingInclAccessEgressModuleTest.java | 42 +- .../PseudoTransitRoutingModuleTest.java | 16 +- .../router/TripRouterFactoryImplTest.java | 7 +- .../core/router/TripRouterModuleTest.java | 4 +- ...izingTimeDistanceTravelDisutilityTest.java | 26 +- .../core/router/old/PlanRouterTest.java | 10 +- .../core/router/speedy/SpeedyALTTest.java | 4 +- .../router/speedy/SpeedyDijkstraTest.java | 4 +- ...ScoringFunctionsForPopulationStressIT.java | 30 +- ...yparNagelLegScoringDailyConstantsTest.java | 32 +- .../CharyparNagelLegScoringPtChangeTest.java | 4 +- .../CharyparNagelScoringFunctionTest.java | 64 +- .../CharyparNagelWithSubpopulationsTest.java | 8 +- .../utils/timing/TimeInterpretationTest.java | 2 +- .../matsim/examples/simple/PtScoringTest.java | 94 +- .../FacilitiesFromPopulationTest.java | 64 +- .../integration/EquilTwoAgentsTest.java | 6 +- .../integration/SimulateAndScoreTest.java | 12 +- .../events/PersonScoreEventTest.java | 2 +- .../InvertedNetworkRoutingTestFixture.java | 6 +- .../integration/invertednetworks/LanesIT.java | 4 +- .../pt/TransitIntegrationTest.java | 14 +- .../ChangeTripModeIntegrationTest.java | 2 +- .../integration/replanning/ReRoutingIT.java | 4 +- .../matsim/modules/ScoreStatsModuleTest.java | 2 +- .../pt/router/TransitRouterConfigTest.java | 30 +- .../ExampleWithinDayControllerTest.java | 5 +- .../ExperiencedPlansWriterTest.java | 6 +- .../tools/ActivityReplanningMapTest.java | 4 +- .../tools/LinkReplanningMapTest.java | 4 +- .../WithinDayTravelTimeTest.java | 5 +- ...TravelTimeWithNetworkChangeEventsTest.java | 68 +- .../withinday/utils/EditRoutesTest.java | 18 +- 289 files changed, 3140 insertions(+), 3187 deletions(-) rename matsim/src/main/java/org/matsim/core/config/groups/{ControlerConfigGroup.java => ControllerConfigGroup.java} (98%) rename matsim/src/main/java/org/matsim/core/config/groups/{ParallelEventHandlingConfigGroup.java => EventsManagerConfigGroup.java} (95%) rename matsim/src/main/java/org/matsim/core/config/groups/{StrategyConfigGroup.java => ReplanningConfigGroup.java} (98%) rename matsim/src/main/java/org/matsim/core/config/groups/{PlansCalcRouteConfigGroup.java => RoutingConfigGroup.java} (98%) rename matsim/src/main/java/org/matsim/core/config/groups/{PlanCalcScoreConfigGroup.java => ScoringConfigGroup.java} (99%) rename matsim/src/test/java/org/matsim/core/config/groups/{ControlerConfigGroupTest.java => ControllerConfigGroupTest.java} (77%) rename matsim/src/test/java/org/matsim/core/config/groups/{StrategyConfigGroupTest.java => ReplanningConfigGroupTest.java} (92%) rename matsim/src/test/java/org/matsim/core/config/groups/{PlansCalcRouteConfigGroupTest.java => RoutingConfigGroupTest.java} (88%) rename matsim/src/test/java/org/matsim/core/config/groups/{PlanCalcScoreConfigGroupTest.java => ScoringConfigGroupTest.java} (93%) diff --git a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/AccessibilityComputationShutdownListener.java b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/AccessibilityComputationShutdownListener.java index a3f82abfa44..d0c887adcc3 100644 --- a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/AccessibilityComputationShutdownListener.java +++ b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/AccessibilityComputationShutdownListener.java @@ -30,11 +30,10 @@ import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.TransportMode; -import org.matsim.api.core.v01.network.Node; import org.matsim.contrib.accessibility.utils.AggregationObject; import org.matsim.contrib.accessibility.utils.ProgressBar; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; import org.matsim.core.controler.events.ShutdownEvent; import org.matsim.core.controler.listener.ShutdownListener; import org.matsim.core.gbl.Gbl; @@ -58,9 +57,9 @@ final class AccessibilityComputationShutdownListener implements ShutdownListener private final ArrayList zoneDataExchangeListeners = new ArrayList<>(); private AccessibilityConfigGroup acg; - private final PlanCalcScoreConfigGroup cnScoringGroup; + private final ScoringConfigGroup cnScoringGroup; + - public AccessibilityComputationShutdownListener(Scenario scenario, ActivityFacilities measuringPoints, ActivityFacilities opportunities, String outputDirectory) { this.measuringPoints = measuringPoints; @@ -241,10 +240,10 @@ private void writeCSVFile(String adaptedOutputDirectory) { writer.writeField(facility.getCoord().getX()); writer.writeField(facility.getCoord().getY()); writer.writeField(tuple.getSecond()); - + for (String mode : getModes() ) { final double value = accessibilitiesMap.get(tuple).get(mode); - if (!Double.isNaN(value)) { + if (!Double.isNaN(value)) { writer.writeField(value) ; } else { writer.writeField(Double.NaN) ; diff --git a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/AccessibilityUtils.java b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/AccessibilityUtils.java index 0de040c489c..ffbecca870f 100644 --- a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/AccessibilityUtils.java +++ b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/AccessibilityUtils.java @@ -34,7 +34,7 @@ import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; import org.matsim.core.config.groups.NetworkConfigGroup; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; import org.matsim.core.gbl.Gbl; import org.matsim.core.network.NetworkUtils; import org.matsim.core.network.algorithms.TransportModeNetworkFilter; @@ -142,16 +142,16 @@ public static Network createModeSpecificSubNetwork(Network network, String mode, } - public static double getModeSpecificConstantForAccessibilities(String mode, PlanCalcScoreConfigGroup planCalcScoreConfigGroup) { + public static double getModeSpecificConstantForAccessibilities(String mode, ScoringConfigGroup scoringConfigGroup) { double modeSpecificConstant; if (mode.equals(Modes4Accessibility.freespeed.name())) { - modeSpecificConstant = planCalcScoreConfigGroup.getModes().get(TransportMode.car).getConstant(); + modeSpecificConstant = scoringConfigGroup.getModes().get(TransportMode.car).getConstant(); } else { - modeSpecificConstant = planCalcScoreConfigGroup.getModes().get(mode).getConstant(); + modeSpecificConstant = scoringConfigGroup.getModes().get(mode).getConstant(); } return modeSpecificConstant; } - + /** * Collects all facilities of a given type that have been loaded to the sceanrio. */ @@ -191,8 +191,8 @@ public static List collectAllFacilityOptionTypes(Scenario scenario) { public static void combineDifferentActivityOptionTypes(final Scenario scenario, String combinedType, final List activityOptionsToBeIncluded) { - ActivityOption markerOption = new ActivityOptionImpl(combinedType); - + ActivityOption markerOption = new ActivityOptionImpl(combinedType); + // Memorize all facilities that have certain activity options in a activity facilities container final ActivityFacilities consideredFacilities = FacilitiesUtils.createActivityFacilities(); for (ActivityFacility facility : scenario.getActivityFacilities().getFacilities().values()) { @@ -205,7 +205,7 @@ public static void combineDifferentActivityOptionTypes(final Scenario scenario, } } } - + // Add marker option to facilities to be considered for (ActivityFacility facility : consideredFacilities.getFacilities().values()) { facility.addActivityOption(markerOption); @@ -227,16 +227,16 @@ public static final ActivityFacilities createFacilityForEachLink(String facility public static final ActivityFacilities createFacilityFromBuildingShapefile(String shapeFileName, String identifierCaption, String numberOfHouseholdsCaption) { ShapeFileReader shapeFileReader = new ShapeFileReader(); Collection features = shapeFileReader.readFileAndInitialize(shapeFileName); - + ActivityFacilities facilities = FacilitiesUtils.createActivityFacilities("DensitiyFacilities"); ActivityFacilitiesFactory aff = facilities.getFactory(); - + for (SimpleFeature feature : features) { String featureId = (String) feature.getAttribute(identifierCaption); Integer numberOfHouseholds = Integer.parseInt((String) feature.getAttribute(numberOfHouseholdsCaption)); Geometry geometry = (Geometry) feature.getDefaultGeometry(); Coord coord = CoordUtils.createCoord(geometry.getCentroid().getX(), geometry.getCentroid().getY()); - + for (int i = 0; i < numberOfHouseholds; i++) { ActivityFacility facility = aff.createActivityFacility(Id.create(featureId + "_" + i, ActivityFacility.class), coord); facilities.addActivityFacility(facility); @@ -255,7 +255,7 @@ public static ActivityFacilities createMeasuringPointsFromNetworkBounds(Network double xMax = boundingBox.getXMax(); double yMin = boundingBox.getYMin(); double yMax = boundingBox.getYMax(); - + ActivityFacilities measuringPoints = GridUtils.createGridLayerByGridSizeByBoundingBoxV2(xMin, yMin, xMax, yMax, cellSize); return measuringPoints; } @@ -263,7 +263,7 @@ public static ActivityFacilities createMeasuringPointsFromNetworkBounds(Network /** * Calculates the sum of the values of a given list. - * + * * @param valueList * @return sum */ @@ -279,7 +279,7 @@ public static double calculateSum(List valueList) { /** * Calculates Gini coefficient of the values of a given values. The Gini Coefficient is equals to the half of * the relative mean absolute difference (RMD). - * + * * @see * @see * @param valueList @@ -289,7 +289,7 @@ public static double calculateGiniCoefficient(List valueList) { int numberOfValues = valueList.size(); double sumOfValues = calculateSum(valueList); double arithmeticMean = sumOfValues / numberOfValues; - + double sumOfAbsoluteDifferences = 0.; for (double i : valueList) { for (double j : valueList) { @@ -310,24 +310,24 @@ public static double calculateGiniCoefficient(List valueList) { public static ActivityFacilities createFacilitiesFromPlans(Population population) { ActivityFacilitiesFactory aff = new ActivityFacilitiesFactoryImpl(); ActivityFacilities facilities = FacilitiesUtils.createActivityFacilities(); - + for(Person person : population.getPersons().values()) { for(Plan plan : person.getPlans()) { Id personId = person.getId(); - + for (PlanElement planElement : plan.getPlanElements()) { if (planElement instanceof Activity) { Activity activity = (Activity) planElement; - + Coord coord= activity.getCoord(); if (coord == null) { throw new NullPointerException("Activity does not have any coordinates."); } - + String activityType = activity.getType(); - + // In case an agent visits the same activity location twice, create another activity facility with a modified ID - Integer i = 1; + Integer i = 1; Id facilityId = Id.create(activityType + "_" + personId.toString() + "_" + i.toString(), ActivityFacility.class); while (facilities.getFacilities().containsKey(facilityId)) { i++; @@ -335,7 +335,7 @@ public static ActivityFacilities createFacilitiesFromPlans(Population population } ActivityFacility facility = aff.createActivityFacility(facilityId, activity.getCoord()); - + facility.addActivityOption(aff.createActivityOption(activityType)); facilities.addActivityFacility(facility); // log.info("Created activity with option of type " + activityType + " and ID " + facilityId + "."); @@ -353,7 +353,7 @@ public static String getDate() { String monthStr = month + ""; if (month < 10) monthStr = "0" + month; - String date = cal.get(Calendar.YEAR) + "-" + String date = cal.get(Calendar.YEAR) + "-" + monthStr + "-" + cal.get(Calendar.DAY_OF_MONTH); return date; } @@ -363,16 +363,16 @@ public static void assignAdditionalFacilitiesDataToMeasurePoint(ActivityFaciliti Map additionalFacilityData) { LOG.info("Start assigning additional facilities data to measure point."); GeometryFactory geometryFactory = new GeometryFactory(); - + for (ActivityFacilities additionalDataFacilities : additionalFacilityData.values()) { // Iterate over all additional data collections String additionalDataName = additionalDataFacilities.getName(); int additionalDataFacilitiesToAssign = additionalDataFacilities.getFacilities().size(); - + for (Id measurePointId : measurePoints.getFacilities().keySet()) { // Iterate over all measure points ActivityFacility measurePoint = measurePoints.getFacilities().get(measurePointId); measurePoint.getAttributes().putAttribute(additionalDataName, 0); Geometry geometry = measurePointGeometryMap.get(measurePointId); - + for (ActivityFacility facility : additionalDataFacilities.getFacilities().values()) { // Iterate over additional-data facilities Point point = geometryFactory.createPoint(new Coordinate(facility.getCoord().getX(), facility.getCoord().getY())); if (geometry.contains(point)) { diff --git a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/ConstantSpeedAccessibilityExpContributionCalculator.java b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/ConstantSpeedAccessibilityExpContributionCalculator.java index 329155e30e4..e950dac5b72 100644 --- a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/ConstantSpeedAccessibilityExpContributionCalculator.java +++ b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/ConstantSpeedAccessibilityExpContributionCalculator.java @@ -29,7 +29,7 @@ import org.matsim.contrib.accessibility.utils.Distances; import org.matsim.contrib.accessibility.utils.NetworkUtil; import org.matsim.core.config.Config; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; import org.matsim.core.network.NetworkUtils; import org.matsim.core.network.algorithms.TransportModeNetworkFilter; import org.matsim.core.trafficmonitoring.FreeSpeedTravelTime; @@ -54,14 +54,14 @@ final class ConstantSpeedAccessibilityExpContributionCalculator implements Acces // private Network network; private Network subNetwork; private Scenario scenario; - + private double logitScaleParameter; - + private double betaModeTT; // in MATSim this is [utils/h]: cnScoringGroup.getTravelingBike_utils_hr() - cnScoringGroup.getPerforming_utils_hr() private double betaModeTD; // in MATSim this is 0 !!! since getMonetaryDistanceCostRateBike doesn't exist: private double constMode; private double modeSpeed_m_h = -1; - + private double betaWalkTT; private double betaWalkTD; private double walkSpeed_m_h; @@ -77,26 +77,26 @@ public ConstantSpeedAccessibilityExpContributionCalculator(final String mode, fi this.scenario = scenario; this.config = scenario.getConfig(); - final PlanCalcScoreConfigGroup planCalcScoreConfigGroup = config.planCalcScore() ; + final ScoringConfigGroup scoringConfigGroup = config.planCalcScore() ; - if (planCalcScoreConfigGroup.getOrCreateModeParams(mode).getMonetaryDistanceRate() != 0.) { + if (scoringConfigGroup.getOrCreateModeParams(mode).getMonetaryDistanceRate() != 0.) { LOG.error("Monetary distance cost rate for " + mode + " different from zero, but not used in accessibility computations"); } - logitScaleParameter = planCalcScoreConfigGroup.getBrainExpBeta(); + logitScaleParameter = scoringConfigGroup.getBrainExpBeta(); if (config.plansCalcRoute().getTeleportedModeSpeeds().get(mode) == null) { LOG.error("No teleported mode speed for mode " + mode + " set."); } this.modeSpeed_m_h = config.plansCalcRoute().getTeleportedModeSpeeds().get(mode) * 3600.; - final PlanCalcScoreConfigGroup.ModeParams modeParams = planCalcScoreConfigGroup.getOrCreateModeParams(mode); - betaModeTT = modeParams.getMarginalUtilityOfTraveling() - planCalcScoreConfigGroup.getPerforming_utils_hr(); + final ScoringConfigGroup.ModeParams modeParams = scoringConfigGroup.getOrCreateModeParams(mode); + betaModeTT = modeParams.getMarginalUtilityOfTraveling() - scoringConfigGroup.getPerforming_utils_hr(); betaModeTD = modeParams.getMarginalUtilityOfDistance(); constMode = modeParams.getConstant(); - betaWalkTT = planCalcScoreConfigGroup.getModes().get(TransportMode.walk).getMarginalUtilityOfTraveling() - planCalcScoreConfigGroup.getPerforming_utils_hr(); - betaWalkTD = planCalcScoreConfigGroup.getModes().get(TransportMode.walk).getMarginalUtilityOfDistance(); + betaWalkTT = scoringConfigGroup.getModes().get(TransportMode.walk).getMarginalUtilityOfTraveling() - scoringConfigGroup.getPerforming_utils_hr(); + betaWalkTD = scoringConfigGroup.getModes().get(TransportMode.walk).getMarginalUtilityOfDistance(); this.walkSpeed_m_h = config.plansCalcRoute().getTeleportedModeSpeeds().get(TransportMode.walk) * 3600; } @@ -124,14 +124,14 @@ public void initialize(ActivityFacilities measuringPoints, ActivityFacilities op } - + @Override public void notifyNewOriginNode(Id fromNodeId, Double departureTime) { this.fromNode = subNetwork.getNodes().get(fromNodeId); this.lcptTravelDistance.calculate(subNetwork, fromNode, departureTime); } - + @Override public double computeContributionOfOpportunity(ActivityFacility origin, Map, AggregationObject> aggregatedOpportunities, Double departureTime) { diff --git a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/LeastCostPathCalculatorAccessibilityContributionCalculator.java b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/LeastCostPathCalculatorAccessibilityContributionCalculator.java index 74dbdfeffa2..ee526dafc6d 100644 --- a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/LeastCostPathCalculatorAccessibilityContributionCalculator.java +++ b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/LeastCostPathCalculatorAccessibilityContributionCalculator.java @@ -5,7 +5,7 @@ import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.network.Node; import org.matsim.contrib.accessibility.utils.AggregationObject; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; import org.matsim.core.router.util.LeastCostPathCalculator; import org.matsim.facilities.ActivityFacilities; import org.matsim.facilities.ActivityFacility; @@ -18,7 +18,7 @@ */ final class LeastCostPathCalculatorAccessibilityContributionCalculator implements AccessibilityContributionCalculator { private final LeastCostPathCalculator leastCostPathCalculator; - private final PlanCalcScoreConfigGroup planCalcScoreConfigGroup; + private final ScoringConfigGroup scoringConfigGroup; private Node fromNode; private Double departureTime; private Scenario scenario; @@ -27,8 +27,8 @@ final class LeastCostPathCalculatorAccessibilityContributionCalculator implement Map, AggregationObject> aggregatedOpportunities; - public LeastCostPathCalculatorAccessibilityContributionCalculator(PlanCalcScoreConfigGroup planCalcScoreConfigGroup, LeastCostPathCalculator leastCostPathCalculator, Scenario scenario) { - this.planCalcScoreConfigGroup = planCalcScoreConfigGroup; + public LeastCostPathCalculatorAccessibilityContributionCalculator(ScoringConfigGroup scoringConfigGroup, LeastCostPathCalculator leastCostPathCalculator, Scenario scenario) { + this.scoringConfigGroup = scoringConfigGroup; this.leastCostPathCalculator = leastCostPathCalculator; this.scenario = scenario; } @@ -55,7 +55,7 @@ public double computeContributionOfOpportunity(ActivityFacility origin, for (final AggregationObject destination : aggregatedOpportunities.values()) { LeastCostPathCalculator.Path path = leastCostPathCalculator.calcLeastCostPath(fromNode, (Node) destination.getNearestBasicLocation(), departureTime, null, null); - expSum += destination.getSum() * Math.exp(planCalcScoreConfigGroup.getBrainExpBeta() * path.travelCost); + expSum += destination.getSum() * Math.exp(scoringConfigGroup.getBrainExpBeta() * path.travelCost); } return expSum; } @@ -64,7 +64,7 @@ public double computeContributionOfOpportunity(ActivityFacility origin, @Override public LeastCostPathCalculatorAccessibilityContributionCalculator duplicate() { LeastCostPathCalculatorAccessibilityContributionCalculator leastCostPathCalculatorAccessibilityContributionCalculator = - new LeastCostPathCalculatorAccessibilityContributionCalculator(this.planCalcScoreConfigGroup, this.leastCostPathCalculator, this.scenario); + new LeastCostPathCalculatorAccessibilityContributionCalculator(this.scoringConfigGroup, this.leastCostPathCalculator, this.scenario); return leastCostPathCalculatorAccessibilityContributionCalculator; } diff --git a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/NetworkModeAccessibilityExpContributionCalculator.java b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/NetworkModeAccessibilityExpContributionCalculator.java index cfaf0906478..957fa637748 100644 --- a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/NetworkModeAccessibilityExpContributionCalculator.java +++ b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/NetworkModeAccessibilityExpContributionCalculator.java @@ -12,7 +12,7 @@ import org.matsim.contrib.accessibility.utils.*; import org.matsim.contrib.roadpricing.RoadPricingScheme; import org.matsim.core.config.groups.NetworkConfigGroup; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; import org.matsim.core.gbl.Gbl; import org.matsim.core.network.NetworkUtils; import org.matsim.core.network.algorithms.TransportModeNetworkFilter; @@ -40,7 +40,7 @@ final class NetworkModeAccessibilityExpContributionCalculator implements Accessi private final Scenario scenario; private final TravelDisutility travelDisutility; - private final PlanCalcScoreConfigGroup planCalcScoreConfigGroup; + private final ScoringConfigGroup scoringConfigGroup; private final NetworkConfigGroup networkConfigGroup; private Network subNetwork; @@ -68,7 +68,7 @@ public NetworkModeAccessibilityExpContributionCalculator(String mode, final Trav Gbl.assertNotNull(travelDisutilityFactory); this.travelDisutility = travelDisutilityFactory.createTravelDisutility(travelTime); - planCalcScoreConfigGroup = scenario.getConfig().planCalcScore(); + scoringConfigGroup = scenario.getConfig().planCalcScore(); networkConfigGroup = scenario.getConfig().network(); RoadPricingScheme scheme = (RoadPricingScheme) scenario.getScenarioElement( RoadPricingScheme.ELEMENT_NAME ); @@ -78,7 +78,7 @@ public NetworkModeAccessibilityExpContributionCalculator(String mode, final Trav //FastMultiNodeDijkstraFactory fastMultiNodeDijkstraFactory = new FastMultiNodeDijkstraFactory(true); //this.multiNodePathCalculator = (MultiNodePathCalculator) fastMultiNodeDijkstraFactory.createPathCalculator(network, travelDisutility, travelTime); - betaWalkTT = planCalcScoreConfigGroup.getModes().get(TransportMode.walk).getMarginalUtilityOfTraveling() - planCalcScoreConfigGroup.getPerforming_utils_hr(); + betaWalkTT = scoringConfigGroup.getModes().get(TransportMode.walk).getMarginalUtilityOfTraveling() - scoringConfigGroup.getPerforming_utils_hr(); this.walkSpeed_m_s = scenario.getConfig().plansCalcRoute().getTeleportedModeSpeeds().get(TransportMode.walk); } @@ -137,7 +137,7 @@ public double computeContributionOfOpportunity(ActivityFacility origin, double congestedCarUtilityRoad2Node = -travelDisutility.getLinkTravelDisutility(nearestLink, departureTime, null, null) * distanceFraction; // Combine all utility components (using the identity: exp(a+b) = exp(a) * exp(b)) - double modeSpecificConstant = AccessibilityUtils.getModeSpecificConstantForAccessibilities(mode, planCalcScoreConfigGroup); + double modeSpecificConstant = AccessibilityUtils.getModeSpecificConstantForAccessibilities(mode, scoringConfigGroup); for (final AggregationObject destination : aggregatedOpportunities.values()) { @@ -151,7 +151,7 @@ public double computeContributionOfOpportunity(ActivityFacility origin, // Pre-computed effect of all opportunities reachable from destination network node double sumExpVjkWalk = destination.getSum(); - expSum += Math.exp(this.planCalcScoreConfigGroup.getBrainExpBeta() * (walkUtilityMeasuringPoint2Road + modeSpecificConstant + expSum += Math.exp(this.scoringConfigGroup.getBrainExpBeta() * (walkUtilityMeasuringPoint2Road + modeSpecificConstant + congestedCarUtilityRoad2Node + congestedCarUtility)) * sumExpVjkWalk; } return expSum; diff --git a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/SwissRailRaptorAccessibilityContributionCalculator.java b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/SwissRailRaptorAccessibilityContributionCalculator.java index b64c6fa7b4e..2b13f5899b1 100644 --- a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/SwissRailRaptorAccessibilityContributionCalculator.java +++ b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/SwissRailRaptorAccessibilityContributionCalculator.java @@ -25,7 +25,7 @@ import org.matsim.api.core.v01.network.Network; import org.matsim.contrib.accessibility.utils.AggregationObject; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; import org.matsim.core.gbl.Gbl; import org.matsim.core.utils.geometry.CoordUtils; import org.matsim.facilities.*; @@ -44,7 +44,7 @@ class SwissRailRaptorAccessibilityContributionCalculator implements Accessibilit private static final Logger LOG = LogManager.getLogger( SwissRailRaptorAccessibilityContributionCalculator.class ); private SwissRailRaptor raptor; private String mode; - private PlanCalcScoreConfigGroup planCalcScoreConfigGroup; + private ScoringConfigGroup scoringConfigGroup; private Scenario scenario; Map, ArrayList> aggregatedMeasurePoints; @@ -58,7 +58,7 @@ class SwissRailRaptorAccessibilityContributionCalculator implements Accessibilit Map, Collection> stopsPerAggregatedOpportunity = new LinkedHashMap<>(); - public SwissRailRaptorAccessibilityContributionCalculator(String mode, PlanCalcScoreConfigGroup planCalcScoreConfigGroup, Scenario scenario) { + public SwissRailRaptorAccessibilityContributionCalculator(String mode, ScoringConfigGroup scoringConfigGroup, Scenario scenario) { this.mode = mode; TransitSchedule schedule = scenario.getTransitSchedule(); @@ -69,10 +69,10 @@ public SwissRailRaptorAccessibilityContributionCalculator(String mode, PlanCalcS this.raptorData = SwissRailRaptorData.create(schedule, null, raptorConfig, ptNetwork, null); this.raptor = new SwissRailRaptor.Builder(raptorData, scenario.getConfig()).build(); - this.planCalcScoreConfigGroup = planCalcScoreConfigGroup; + this.scoringConfigGroup = scoringConfigGroup; this.scenario = scenario; - this.betaWalkTT = planCalcScoreConfigGroup.getModes().get(TransportMode.walk).getMarginalUtilityOfTraveling() - planCalcScoreConfigGroup.getPerforming_utils_hr(); + this.betaWalkTT = scoringConfigGroup.getModes().get(TransportMode.walk).getMarginalUtilityOfTraveling() - scoringConfigGroup.getPerforming_utils_hr(); this.walkSpeed_m_h = scenario.getConfig().plansCalcRoute().getTeleportedModeSpeeds().get(TransportMode.walk) * 3600.; } @@ -167,8 +167,8 @@ public double computeContributionOfOpportunity(ActivityFacility origin, //check whether direct walk time is cheaper travelCost = Math.min(travelCost, directWalkCost); - double modeSpecificConstant = AccessibilityUtils.getModeSpecificConstantForAccessibilities(mode, planCalcScoreConfigGroup); - expSum += Math.exp(this.planCalcScoreConfigGroup.getBrainExpBeta() * (-travelCost + modeSpecificConstant)); + double modeSpecificConstant = AccessibilityUtils.getModeSpecificConstantForAccessibilities(mode, scoringConfigGroup); + expSum += Math.exp(this.scoringConfigGroup.getBrainExpBeta() * (-travelCost + modeSpecificConstant)); } return expSum; } @@ -177,7 +177,7 @@ public double computeContributionOfOpportunity(ActivityFacility origin, @Override public SwissRailRaptorAccessibilityContributionCalculator duplicate() { SwissRailRaptorAccessibilityContributionCalculator swissRailRaptorAccessibilityContributionCalculator = - new SwissRailRaptorAccessibilityContributionCalculator(this.mode, this.planCalcScoreConfigGroup, this.scenario); + new SwissRailRaptorAccessibilityContributionCalculator(this.mode, this.scoringConfigGroup, this.scenario); swissRailRaptorAccessibilityContributionCalculator.aggregatedMeasurePoints = this.aggregatedMeasurePoints; swissRailRaptorAccessibilityContributionCalculator.aggregatedOpportunities = this.aggregatedOpportunities; swissRailRaptorAccessibilityContributionCalculator.stopsPerAggregatedOpportunity = this.stopsPerAggregatedOpportunity; diff --git a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/TravelTimeBasedTravelDisutility.java b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/TravelTimeBasedTravelDisutility.java index 34ee8375753..6a70a5911fa 100644 --- a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/TravelTimeBasedTravelDisutility.java +++ b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/TravelTimeBasedTravelDisutility.java @@ -18,30 +18,30 @@ * *********************************************************************** */ /** - * + * */ package org.matsim.contrib.accessibility; import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.population.Person; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; import org.matsim.core.router.util.TravelDisutility; import org.matsim.core.router.util.TravelTime; import org.matsim.vehicles.Vehicle; /** * A simple cost calculator which only respects time to calculate generalized costs - * This is based on org.matsim.core.router.costcalculators.TravelTimeAndDistanceBasedTravelDisutility + * This is based on org.matsim.core.router.costcalculators.TravelTimeAndDistanceBasedTravelDisutility * * @author mrieser, thomas */ class TravelTimeBasedTravelDisutility implements TravelDisutility{ - + protected final TravelTime timeCalculator; private final double marginalCostOfTime; - public TravelTimeBasedTravelDisutility(final TravelTime timeCalculator, PlanCalcScoreConfigGroup cnScoringGroup) { + public TravelTimeBasedTravelDisutility(final TravelTime timeCalculator, ScoringConfigGroup cnScoringGroup) { this.timeCalculator = timeCalculator; /* Usually, the travel-utility should be negative (it's a disutility) * but the cost should be positive. Thus negate the utility. diff --git a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/TripRouterAccessibilityContributionCalculator.java b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/TripRouterAccessibilityContributionCalculator.java index 0f3dece8928..6941fb93087 100644 --- a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/TripRouterAccessibilityContributionCalculator.java +++ b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/TripRouterAccessibilityContributionCalculator.java @@ -38,7 +38,7 @@ import org.matsim.contrib.accessibility.utils.Distances; import org.matsim.contrib.accessibility.utils.NetworkUtil; import org.matsim.core.config.groups.NetworkConfigGroup; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; import org.matsim.core.gbl.Gbl; import org.matsim.core.network.NetworkUtils; import org.matsim.core.router.TripRouter; @@ -60,7 +60,7 @@ class TripRouterAccessibilityContributionCalculator implements AccessibilityCont private static final Logger LOG = LogManager.getLogger( TripRouterAccessibilityContributionCalculator.class ); private TripRouter tripRouter ; private String mode; - private PlanCalcScoreConfigGroup planCalcScoreConfigGroup; + private ScoringConfigGroup scoringConfigGroup; private NetworkConfigGroup networkConfigGroup; private Scenario scenario; @@ -79,16 +79,16 @@ class TripRouterAccessibilityContributionCalculator implements AccessibilityCont private final TravelTime travelTime; - public TripRouterAccessibilityContributionCalculator(String mode, TripRouter tripRouter, PlanCalcScoreConfigGroup planCalcScoreConfigGroup, Scenario scenario, - TravelTime travelTime, TravelDisutilityFactory travelDisutilityFactory) { + public TripRouterAccessibilityContributionCalculator(String mode, TripRouter tripRouter, ScoringConfigGroup scoringConfigGroup, Scenario scenario, + TravelTime travelTime, TravelDisutilityFactory travelDisutilityFactory) { LOG.warn("This is currently heavliy oriented on the need of car-based computatations. Revise beofre using for other modes!"); this.mode = mode; this.tripRouter = tripRouter; - this.planCalcScoreConfigGroup = planCalcScoreConfigGroup; + this.scoringConfigGroup = scoringConfigGroup; this.networkConfigGroup = scenario.getConfig().network(); this.scenario = scenario; - betaWalkTT = planCalcScoreConfigGroup.getModes().get(TransportMode.walk).getMarginalUtilityOfTraveling() - planCalcScoreConfigGroup.getPerforming_utils_hr(); + betaWalkTT = scoringConfigGroup.getModes().get(TransportMode.walk).getMarginalUtilityOfTraveling() - scoringConfigGroup.getPerforming_utils_hr(); this.walkSpeed_m_s = scenario.getConfig().plansCalcRoute().getTeleportedModeSpeeds().get(TransportMode.walk); @@ -152,21 +152,21 @@ public double computeContributionOfOpportunity(ActivityFacility origin, // Note: The following computation where the end link length is added is only correct once the end link is removed from the route // in the NetworkRoutingModule (route.setDistance(RouteUtils.calcDistance(route, 1.0, 0.0, this.network));) - if (this.planCalcScoreConfigGroup.getModes().get(leg.getMode()).getMarginalUtilityOfDistance() != 0.) { + if (this.scoringConfigGroup.getModes().get(leg.getMode()).getMarginalUtilityOfDistance() != 0.) { LOG.warn("A computation including a marginal utility of distance will only be correct if the route time/distance" + "inconsistency in the NetworkRoutingModule is solved."); } - utility += (leg.getRoute().getDistance() + endLinkLength) * this.planCalcScoreConfigGroup.getModes().get(leg.getMode()).getMarginalUtilityOfDistance(); - utility += (leg.getRoute().getTravelTime().seconds() + estimatedEndLinkTT) * this.planCalcScoreConfigGroup.getModes().get(leg.getMode()).getMarginalUtilityOfTraveling() / 3600.; - utility += -(leg.getRoute().getTravelTime().seconds() + estimatedEndLinkTT) * this.planCalcScoreConfigGroup.getPerforming_utils_hr() / 3600.; + utility += (leg.getRoute().getDistance() + endLinkLength) * this.scoringConfigGroup.getModes().get(leg.getMode()).getMarginalUtilityOfDistance(); + utility += (leg.getRoute().getTravelTime().seconds() + estimatedEndLinkTT) * this.scoringConfigGroup.getModes().get(leg.getMode()).getMarginalUtilityOfTraveling() / 3600.; + utility += -(leg.getRoute().getTravelTime().seconds() + estimatedEndLinkTT) * this.scoringConfigGroup.getPerforming_utils_hr() / 3600.; } // Utility based on opportunities that are attached to destination node double sumExpVjkWalk = destination.getSum(); // exp(beta * a) * exp(beta * b) = exp(beta * (a+b)) - double modeSpecificConstant = AccessibilityUtils.getModeSpecificConstantForAccessibilities(mode, planCalcScoreConfigGroup); - expSum += Math.exp(this.planCalcScoreConfigGroup.getBrainExpBeta() * (utility + modeSpecificConstant + walkUtilityMeasuringPoint2Road + congestedCarUtilityRoad2Node)) * sumExpVjkWalk; + double modeSpecificConstant = AccessibilityUtils.getModeSpecificConstantForAccessibilities(mode, scoringConfigGroup); + expSum += Math.exp(this.scoringConfigGroup.getBrainExpBeta() * (utility + modeSpecificConstant + walkUtilityMeasuringPoint2Road + congestedCarUtilityRoad2Node)) * sumExpVjkWalk; } return expSum; @@ -176,7 +176,7 @@ public double computeContributionOfOpportunity(ActivityFacility origin, @Override public TripRouterAccessibilityContributionCalculator duplicate() { TripRouterAccessibilityContributionCalculator tripRouterAccessibilityContributionCalculator = - new TripRouterAccessibilityContributionCalculator(this.mode, this.tripRouter, this.planCalcScoreConfigGroup, + new TripRouterAccessibilityContributionCalculator(this.mode, this.tripRouter, this.scoringConfigGroup, this.scenario, this.travelTime, this.travelDisutilityFactory); tripRouterAccessibilityContributionCalculator.subNetwork = this.subNetwork; tripRouterAccessibilityContributionCalculator.aggregatedMeasurePoints = this.aggregatedMeasurePoints; diff --git a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/utils/LeastCostPathTreeExtended.java b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/utils/LeastCostPathTreeExtended.java index 0378f9c7f71..74d2dd7d216 100644 --- a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/utils/LeastCostPathTreeExtended.java +++ b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/utils/LeastCostPathTreeExtended.java @@ -18,7 +18,7 @@ * *********************************************************************** */ /** - * + * */ package org.matsim.contrib.accessibility.utils; @@ -36,7 +36,7 @@ import org.matsim.contrib.matrixbasedptrouter.utils.TempDirectoryUtil; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.ControlerConfigGroup; +import org.matsim.core.config.groups.ControllerConfigGroup; import org.matsim.core.controler.Controler; import org.matsim.core.network.NetworkUtils; import org.matsim.core.router.util.TravelDisutility; @@ -54,17 +54,17 @@ * accumulate distance and toll separately along the route. *

* To re-iterate: This class does not lead to a different tree than the base class. - * + * * @author thomas - * + * */ public final class LeastCostPathTreeExtended extends LeastCostPathTree{ - + protected static final Logger log = LogManager.getLogger(LeastCostPathTreeExtended.class); - + private Map, NodeDataExtended> nodeDataExt = null; private RoadPricingScheme scheme = null; - + /** * constructor * @param controler Controler, to get the RoadPricingScheme if available @@ -75,13 +75,13 @@ public LeastCostPathTreeExtended(final TravelTime tt, final TravelDisutility td, } /** - * + * * @param network * @param origin * @param time */ public final void calculateExtended(final Network network, final Node origin, final double time) { - + this.nodeDataExt = new ConcurrentHashMap, NodeDataExtended>((int) (network.getNodes().size() * 1.1), 0.95f); if(this.nodeDataExt.get(origin.getId()) == null){ NodeDataExtended nde = new NodeDataExtended(); @@ -89,17 +89,17 @@ public final void calculateExtended(final Network network, final Node origin, fi nde.toll = 0.; this.nodeDataExt.put(origin.getId(), nde); } - + calculate(network, origin, time); } - + /** - * @param link - * @param currTime + * @param link + * @param currTime */ @Override protected final void additionalComputationsHook( final Link link, final double currTime ) { - + Node fromNode = link.getFromNode(); // get current distance and toll so far NodeDataExtended nde = nodeDataExt.get( fromNode.getId() ); @@ -113,10 +113,10 @@ protected final void additionalComputationsHook( final Link link, final double c if(cost != null) toll = cost.amount; } - + double visitDistance = currDistance + link.getLength(); double visitToll = currToll + toll; - + // put new nodes into nodeDataExtended Node toNode = link.getToNode(); NodeDataExtended ndeNew = this.nodeDataExt.get( toNode.getId() ); @@ -126,19 +126,19 @@ protected final void additionalComputationsHook( final Link link, final double c } ndeNew.visit(visitDistance, visitToll); } - + // //////////////////////////////////////////////////////////////////// // get methods // //////////////////////////////////////////////////////////////////// - + public final Map, NodeDataExtended> getTreeExtended() { return this.nodeDataExt; } - + // //////////////////////////////////////////////////////////////////// // inner classes // //////////////////////////////////////////////////////////////////// - + public static class NodeDataExtended { private double distance = 0.; // meter private double toll = 0.; // money @@ -161,11 +161,11 @@ public final double getToll() { return this.toll; } } - + // //////////////////////////////////////////////////////////////////// - // testing + // testing // //////////////////////////////////////////////////////////////////// - + /** * for testing * @param args @@ -173,13 +173,13 @@ public final double getToll() { public static void main(String args[]){ // create temp output dir String tmpOutputLocation = TempDirectoryUtil.createCustomTempDirectory("test"); - + // create network Network network = LeastCostPathTreeExtended.createTriangularNetwork(); // create scenario Config config = ConfigUtils.createConfig(); // set last iteration and output - ControlerConfigGroup controlerCG = (ControlerConfigGroup) config.getModule(ControlerConfigGroup.GROUP_NAME); + ControllerConfigGroup controlerCG = (ControllerConfigGroup) config.getModule(ControllerConfigGroup.GROUP_NAME); controlerCG.setLastIteration( 1 ); controlerCG.setOutputDirectory( tmpOutputLocation ); // set scenario @@ -190,7 +190,7 @@ public static void main(String args[]){ controler.run(); // init lcpte LeastCostPathTreeExtended lcpte = new LeastCostPathTreeExtended(controler.getLinkTravelTimes(), controler.createTravelDisutilityCalculator(), (RoadPricingSchemeImpl) controler.getScenario().getScenarioElement(RoadPricingScheme.ELEMENT_NAME)); - + // contains all network nodes Map, ? extends Node> networkNodesMap = network.getNodes(); Id originNodeID = Id.create(1, Node.class); @@ -201,15 +201,15 @@ public static void main(String args[]){ double disutility = lcpte.getTree().get( destinationNodeId ).getCost(); double distance = lcpte.getTreeExtended().get( destinationNodeId ).getDistance(); double toll = lcpte.getTreeExtended().get( destinationNodeId ).getToll(); - + log.info("Time = " + time); - log.info("Disutility = " + disutility); + log.info("Disutility = " + disutility); log.info("Distance = " + distance ); log.info("Toll = " + toll); - + TempDirectoryUtil.cleanUpCustomTempDirectories(); } - + /** * creating a test network * the path 1,2,4 has a total length of 1000m with a free speed travel time of 10m/s @@ -226,12 +226,12 @@ private static Network createTriangularNetwork() { * / \ * / \ *(1)-------(3)-------(4) - *(50m,0.1m/s)(50m,0.1m/s) + *(50m,0.1m/s)(50m,0.1m/s) */ MutableScenario scenario = (MutableScenario) ScenarioUtils.createScenario(ConfigUtils.createConfig()); Network network = (Network) scenario.getNetwork(); - + // add nodes Node node1 = NetworkUtils.createAndAddNode(network, Id.create(1, Node.class), new Coord(0, 0)); Node node2 = NetworkUtils.createAndAddNode(network, Id.create(2, Node.class), new Coord(50, 100)); @@ -251,8 +251,8 @@ private static Network createTriangularNetwork() { final Node fromNode3 = node3; final Node toNode3 = node4; NetworkUtils.createAndAddLink(network,Id.create(4, Link.class), fromNode3, toNode3, 50.0, 0.1, 3600.0, (double) 1 ); - + return network; } - + } diff --git a/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/run/AccessibilityIntegrationTest.java b/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/run/AccessibilityIntegrationTest.java index fa3e94febc8..6c83fe6db43 100644 --- a/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/run/AccessibilityIntegrationTest.java +++ b/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/run/AccessibilityIntegrationTest.java @@ -49,7 +49,7 @@ import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; import org.matsim.core.config.groups.FacilitiesConfigGroup; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup.ModeParams; +import org.matsim.core.config.groups.ScoringConfigGroup.ModeParams; import org.matsim.core.controler.AbstractModule; import org.matsim.core.controler.Controler; import org.matsim.core.controler.OutputDirectoryHierarchy.OverwriteFileSetting; @@ -171,7 +171,7 @@ public void testWithBoundingBox() { acg.setBoundingBoxTop(max); acg.setBoundingBoxLeft(min); acg.setBoundingBoxRight(max); - + config.plansCalcRoute().setRoutingRandomness(0.); final Scenario sc = createTestScenario(config); @@ -331,7 +331,7 @@ public void testWithPredefinedMeasuringPoints() { MatrixBasedPtRouterConfigGroup mbConfig = ConfigUtils.addOrGetModule(config, MatrixBasedPtRouterConfigGroup.class ) ; final PtMatrix ptMatrix = PtMatrix.createPtMatrix(config.plansCalcRoute(), BoundingBox.createBoundingBox(sc.getNetwork()), mbConfig) ; sc.addScenarioElement(PtMatrix.NAME, ptMatrix); - + config.plansCalcRoute().setRoutingRandomness(0.); Controler controler = new Controler(sc); diff --git a/contribs/application/src/main/java/org/matsim/application/MATSimApplication.java b/contribs/application/src/main/java/org/matsim/application/MATSimApplication.java index 85b7c057064..e1aae294638 100644 --- a/contribs/application/src/main/java/org/matsim/application/MATSimApplication.java +++ b/contribs/application/src/main/java/org/matsim/application/MATSimApplication.java @@ -13,7 +13,7 @@ import org.matsim.core.config.Config; import org.matsim.core.config.ConfigGroup; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.ControlerConfigGroup; +import org.matsim.core.config.groups.ControllerConfigGroup; import org.matsim.core.config.groups.GlobalConfigGroup; import org.matsim.core.config.groups.QSimConfigGroup; import org.matsim.core.controler.Controler; @@ -313,7 +313,7 @@ protected List getCustomModules() { */ protected List getConfigurableModules() { return Lists.newArrayList( - new ControlerConfigGroup(), + new ControllerConfigGroup(), new GlobalConfigGroup(), new QSimConfigGroup() ); diff --git a/contribs/application/src/main/java/org/matsim/freightDemandGeneration/FreightDemandGeneration.java b/contribs/application/src/main/java/org/matsim/freightDemandGeneration/FreightDemandGeneration.java index 8eabf5ddb01..43ea72bde8b 100644 --- a/contribs/application/src/main/java/org/matsim/freightDemandGeneration/FreightDemandGeneration.java +++ b/contribs/application/src/main/java/org/matsim/freightDemandGeneration/FreightDemandGeneration.java @@ -36,7 +36,7 @@ import org.matsim.contrib.freight.usecases.chessboard.CarrierScoringFunctionFactoryImpl; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.ControlerConfigGroup; +import org.matsim.core.config.groups.ControllerConfigGroup; import org.matsim.core.controler.AbstractModule; import org.matsim.core.controler.Controler; import org.matsim.core.controler.OutputDirectoryHierarchy; @@ -235,7 +235,7 @@ private Config prepareConfig(int lastMATSimIteration, String coordinateSystem) { config.controler().setOutputDirectory(outputLocation.toString()); config.controler().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); new OutputDirectoryHierarchy(config.controler().getOutputDirectory(), config.controler().getRunId(), - config.controler().getOverwriteFileSetting(), ControlerConfigGroup.CompressionType.gzip); + config.controler().getOverwriteFileSetting(), ControllerConfigGroup.CompressionType.gzip); config.controler().setOverwriteFileSetting(OverwriteFileSetting.overwriteExistingFiles); config.controler().setLastIteration(lastMATSimIteration); config.global().setRandomSeed(4177); diff --git a/contribs/application/src/main/java/org/matsim/smallScaleCommercialTrafficGeneration/GenerateSmallScaleCommercialTrafficDemand.java b/contribs/application/src/main/java/org/matsim/smallScaleCommercialTrafficGeneration/GenerateSmallScaleCommercialTrafficDemand.java index 0c72be12c3b..6fbe89f6541 100644 --- a/contribs/application/src/main/java/org/matsim/smallScaleCommercialTrafficGeneration/GenerateSmallScaleCommercialTrafficDemand.java +++ b/contribs/application/src/main/java/org/matsim/smallScaleCommercialTrafficGeneration/GenerateSmallScaleCommercialTrafficDemand.java @@ -45,7 +45,7 @@ import org.matsim.contrib.freight.usecases.chessboard.CarrierTravelDisutilities; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.ControlerConfigGroup; +import org.matsim.core.config.groups.ControllerConfigGroup; import org.matsim.core.config.groups.VspExperimentalConfigGroup; import org.matsim.core.controler.AbstractModule; import org.matsim.core.controler.Controler; @@ -440,7 +440,7 @@ private Config readAndCheckConfig(Path configPath, String modelName, String samp else config.controler().setOutputDirectory(output.toString()); new OutputDirectoryHierarchy(config.controler().getOutputDirectory(), config.controler().getRunId(), - config.controler().getOverwriteFileSetting(), ControlerConfigGroup.CompressionType.gzip); + config.controler().getOverwriteFileSetting(), ControllerConfigGroup.CompressionType.gzip); new File(Path.of(config.controler().getOutputDirectory()).resolve("calculatedData").toString()).mkdir(); rnd = new Random(config.global().getRandomSeed()); if (config.network().getInputFile() == null) diff --git a/contribs/application/src/test/java/org/matsim/application/MATSimApplicationTest.java b/contribs/application/src/test/java/org/matsim/application/MATSimApplicationTest.java index 69931f9032c..8de8410b64c 100644 --- a/contribs/application/src/test/java/org/matsim/application/MATSimApplicationTest.java +++ b/contribs/application/src/test/java/org/matsim/application/MATSimApplicationTest.java @@ -11,7 +11,7 @@ import org.matsim.application.prepare.population.TrajectoryToPlans; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; import org.matsim.core.controler.Controler; import org.matsim.core.controler.OutputDirectoryHierarchy; import org.matsim.core.utils.io.IOUtils; @@ -63,9 +63,9 @@ public void yaml() { assertThat(controler.getConfig().controler().getRunId()) .isEqualTo("567"); - PlanCalcScoreConfigGroup score = controler.getConfig().planCalcScore(); + ScoringConfigGroup score = controler.getConfig().planCalcScore(); - PlanCalcScoreConfigGroup.ScoringParameterSet params = score.getScoringParameters(null); + ScoringConfigGroup.ScoringParameterSet params = score.getScoringParameters(null); assertThat(params.getOrCreateModeParams("car").getConstant()) .isEqualTo(-1); diff --git a/contribs/av/src/main/java/org/matsim/contrib/av/intermodal/RunTaxiPTIntermodalExample.java b/contribs/av/src/main/java/org/matsim/contrib/av/intermodal/RunTaxiPTIntermodalExample.java index 95fc4ca0f07..5ae03a13b0f 100644 --- a/contribs/av/src/main/java/org/matsim/contrib/av/intermodal/RunTaxiPTIntermodalExample.java +++ b/contribs/av/src/main/java/org/matsim/contrib/av/intermodal/RunTaxiPTIntermodalExample.java @@ -36,7 +36,7 @@ import org.matsim.contrib.taxi.run.MultiModeTaxiModule; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.PlansCalcRouteConfigGroup; +import org.matsim.core.config.groups.RoutingConfigGroup; import org.matsim.core.controler.Controler; import org.matsim.core.controler.OutputDirectoryHierarchy.OverwriteFileSetting; import org.matsim.core.scenario.ScenarioUtils; @@ -55,7 +55,7 @@ public void run(URL configUrl, boolean OTFVis) { Config config = ConfigUtils.loadConfig(configUrl, new MultiModeTaxiConfigGroup(), new DvrpConfigGroup()); config.controler().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); - config.plansCalcRoute().setAccessEgressType(PlansCalcRouteConfigGroup.AccessEgressType.accessEgressModeToLink); + config.plansCalcRoute().setAccessEgressType(RoutingConfigGroup.AccessEgressType.accessEgressModeToLink); SwissRailRaptorConfigGroup srrConfig = new SwissRailRaptorConfigGroup(); diff --git a/contribs/bicycle/src/main/java/org/matsim/contrib/bicycle/BicycleTravelDisutility.java b/contribs/bicycle/src/main/java/org/matsim/contrib/bicycle/BicycleTravelDisutility.java index be8c5cca418..8632a8dcf6d 100644 --- a/contribs/bicycle/src/main/java/org/matsim/contrib/bicycle/BicycleTravelDisutility.java +++ b/contribs/bicycle/src/main/java/org/matsim/contrib/bicycle/BicycleTravelDisutility.java @@ -22,8 +22,8 @@ import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.population.Person; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; -import org.matsim.core.config.groups.PlansCalcRouteConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; +import org.matsim.core.config.groups.RoutingConfigGroup; import org.matsim.core.gbl.MatsimRandom; import org.matsim.core.network.NetworkUtils; import org.matsim.core.router.util.TravelDisutility; @@ -65,9 +65,9 @@ class BicycleTravelDisutility implements TravelDisutility { private Person prevPerson; - BicycleTravelDisutility(BicycleConfigGroup bicycleConfigGroup, PlanCalcScoreConfigGroup cnScoringGroup, - PlansCalcRouteConfigGroup plansCalcRouteConfigGroup, TravelTime timeCalculator, double normalization) { - final PlanCalcScoreConfigGroup.ModeParams bicycleParams = cnScoringGroup.getModes().get(bicycleConfigGroup.getBicycleMode()); + BicycleTravelDisutility(BicycleConfigGroup bicycleConfigGroup, ScoringConfigGroup cnScoringGroup, + RoutingConfigGroup routingConfigGroup, TravelTime timeCalculator, double normalization) { + final ScoringConfigGroup.ModeParams bicycleParams = cnScoringGroup.getModes().get(bicycleConfigGroup.getBicycleMode()); if (bicycleParams == null) { throw new NullPointerException("Mode " + bicycleConfigGroup.getBicycleMode() + " is not part of the valid mode parameters " + cnScoringGroup.getModes().keySet()); } @@ -86,7 +86,7 @@ class BicycleTravelDisutility implements TravelDisutility { this.timeCalculator = timeCalculator; this.normalization = normalization; - this.sigma = plansCalcRouteConfigGroup.getRoutingRandomness(); + this.sigma = routingConfigGroup.getRoutingRandomness(); this.random = sigma != 0 ? MatsimRandom.getLocalInstance() : null; } diff --git a/contribs/bicycle/src/main/java/org/matsim/contrib/bicycle/BicycleTravelDisutilityFactory.java b/contribs/bicycle/src/main/java/org/matsim/contrib/bicycle/BicycleTravelDisutilityFactory.java index 0bd8d6aef8c..135bc7e011f 100644 --- a/contribs/bicycle/src/main/java/org/matsim/contrib/bicycle/BicycleTravelDisutilityFactory.java +++ b/contribs/bicycle/src/main/java/org/matsim/contrib/bicycle/BicycleTravelDisutilityFactory.java @@ -21,8 +21,8 @@ import com.google.inject.Inject; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; -import org.matsim.core.config.groups.PlansCalcRouteConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; +import org.matsim.core.config.groups.RoutingConfigGroup; import org.matsim.core.router.costcalculators.TravelDisutilityFactory; import org.matsim.core.router.util.TravelDisutility; import org.matsim.core.router.util.TravelTime; @@ -39,17 +39,19 @@ public final class BicycleTravelDisutilityFactory implements TravelDisutilityFac private static final Logger LOG = LogManager.getLogger(BicycleTravelDisutilityFactory.class); @Inject BicycleConfigGroup bicycleConfigGroup; - @Inject PlanCalcScoreConfigGroup cnScoringGroup; - @Inject PlansCalcRouteConfigGroup plansCalcRouteConfigGroup; - + @Inject + ScoringConfigGroup cnScoringGroup; + @Inject + RoutingConfigGroup routingConfigGroup; + private static int normalisationWrnCnt = 0; /* package-private */ BicycleTravelDisutilityFactory(){} - + @Override public TravelDisutility createTravelDisutility(TravelTime timeCalculator) { - double sigma = plansCalcRouteConfigGroup.getRoutingRandomness(); - + double sigma = routingConfigGroup.getRoutingRandomness(); + double normalization = 1; if ( sigma != 0. ) { normalization = 1. / Math.exp(sigma * sigma / 2); @@ -58,6 +60,6 @@ public TravelDisutility createTravelDisutility(TravelTime timeCalculator) { LOG.info(" sigma: " + sigma + "; resulting normalization: " + normalization); } } - return new BicycleTravelDisutility(bicycleConfigGroup, cnScoringGroup, plansCalcRouteConfigGroup, timeCalculator, normalization); + return new BicycleTravelDisutility(bicycleConfigGroup, cnScoringGroup, routingConfigGroup, timeCalculator, normalization); } } diff --git a/contribs/bicycle/src/main/java/org/matsim/contrib/bicycle/run/RunBicycleExample.java b/contribs/bicycle/src/main/java/org/matsim/contrib/bicycle/run/RunBicycleExample.java index 134f8bf421e..37590cad7bd 100644 --- a/contribs/bicycle/src/main/java/org/matsim/contrib/bicycle/run/RunBicycleExample.java +++ b/contribs/bicycle/src/main/java/org/matsim/contrib/bicycle/run/RunBicycleExample.java @@ -31,10 +31,10 @@ import org.matsim.contrib.bicycle.BicycleUtils; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup.ActivityParams; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup.ModeParams; +import org.matsim.core.config.groups.ScoringConfigGroup.ActivityParams; +import org.matsim.core.config.groups.ScoringConfigGroup.ModeParams; import org.matsim.core.config.groups.QSimConfigGroup; -import org.matsim.core.config.groups.StrategyConfigGroup.StrategySettings; +import org.matsim.core.config.groups.ReplanningConfigGroup.StrategySettings; import org.matsim.core.controler.AbstractModule; import org.matsim.core.controler.Controler; import org.matsim.core.controler.OutputDirectoryHierarchy.OverwriteFileSetting; diff --git a/contribs/bicycle/src/test/java/org/matsim/contrib/bicycle/run/BicycleTest.java b/contribs/bicycle/src/test/java/org/matsim/contrib/bicycle/run/BicycleTest.java index 329e40cc0c5..a5aa5735779 100644 --- a/contribs/bicycle/src/test/java/org/matsim/contrib/bicycle/run/BicycleTest.java +++ b/contribs/bicycle/src/test/java/org/matsim/contrib/bicycle/run/BicycleTest.java @@ -39,10 +39,10 @@ import org.matsim.contrib.bicycle.BicycleModule; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup.ActivityParams; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup.ModeParams; +import org.matsim.core.config.groups.ScoringConfigGroup.ActivityParams; +import org.matsim.core.config.groups.ScoringConfigGroup.ModeParams; import org.matsim.core.config.groups.QSimConfigGroup.VehiclesSource; -import org.matsim.core.config.groups.StrategyConfigGroup.StrategySettings; +import org.matsim.core.config.groups.ReplanningConfigGroup.StrategySettings; import org.matsim.core.controler.AbstractModule; import org.matsim.core.controler.Controler; import org.matsim.core.controler.OutputDirectoryHierarchy.OverwriteFileSetting; diff --git a/contribs/cadytsIntegration/src/test/java/org/matsim/contrib/cadyts/car/CadytsCarIT.java b/contribs/cadytsIntegration/src/test/java/org/matsim/contrib/cadyts/car/CadytsCarIT.java index b07564f0a8f..61f6692a87a 100644 --- a/contribs/cadytsIntegration/src/test/java/org/matsim/contrib/cadyts/car/CadytsCarIT.java +++ b/contribs/cadytsIntegration/src/test/java/org/matsim/contrib/cadyts/car/CadytsCarIT.java @@ -38,9 +38,9 @@ import org.matsim.contrib.cadyts.utils.CalibrationStatReader; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.ControlerConfigGroup.MobsimType; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup.ActivityParams; -import org.matsim.core.config.groups.StrategyConfigGroup.StrategySettings; +import org.matsim.core.config.groups.ControllerConfigGroup.MobsimType; +import org.matsim.core.config.groups.ScoringConfigGroup.ActivityParams; +import org.matsim.core.config.groups.ReplanningConfigGroup.StrategySettings; import org.matsim.core.controler.AbstractModule; import org.matsim.core.controler.ControlerDefaultsModule; import org.matsim.core.controler.ControlerI; diff --git a/contribs/cadytsIntegration/src/test/java/org/matsim/contrib/cadyts/pt/CadytsPtIT.java b/contribs/cadytsIntegration/src/test/java/org/matsim/contrib/cadyts/pt/CadytsPtIT.java index 9ea725add52..f8e081505b5 100644 --- a/contribs/cadytsIntegration/src/test/java/org/matsim/contrib/cadyts/pt/CadytsPtIT.java +++ b/contribs/cadytsIntegration/src/test/java/org/matsim/contrib/cadyts/pt/CadytsPtIT.java @@ -39,12 +39,11 @@ import org.matsim.contrib.cadyts.utils.CalibrationStatReader; import org.matsim.core.api.experimental.events.EventsManager; import org.matsim.core.config.Config; -import org.matsim.core.config.ConfigGroup; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.ControlerConfigGroup.MobsimType; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup.ActivityParams; +import org.matsim.core.config.groups.ControllerConfigGroup.MobsimType; +import org.matsim.core.config.groups.ScoringConfigGroup.ActivityParams; import org.matsim.core.config.groups.PlansConfigGroup.HandlingOfPlansWithoutRoutingMode; -import org.matsim.core.config.groups.StrategyConfigGroup.StrategySettings; +import org.matsim.core.config.groups.ReplanningConfigGroup.StrategySettings; import org.matsim.core.controler.AbstractModule; import org.matsim.core.controler.Controler; import org.matsim.core.mobsim.framework.Mobsim; diff --git a/contribs/carsharing/src/main/java/org/matsim/contrib/carsharing/manager/demand/VehicleChoiceAgentImpl.java b/contribs/carsharing/src/main/java/org/matsim/contrib/carsharing/manager/demand/VehicleChoiceAgentImpl.java index 9906d235e08..455f57a72f4 100644 --- a/contribs/carsharing/src/main/java/org/matsim/contrib/carsharing/manager/demand/VehicleChoiceAgentImpl.java +++ b/contribs/carsharing/src/main/java/org/matsim/contrib/carsharing/manager/demand/VehicleChoiceAgentImpl.java @@ -2,7 +2,6 @@ import java.util.List; import java.util.Map; -import java.util.Set; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -15,7 +14,7 @@ import org.matsim.contrib.carsharing.manager.supply.CarsharingSupplyInterface; import org.matsim.contrib.carsharing.manager.supply.costs.CostsCalculatorContainer; import org.matsim.contrib.carsharing.vehicles.CSVehicle; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; import org.matsim.core.router.costcalculators.TravelDisutilityFactory; import org.matsim.core.router.util.LeastCostPathCalculator; import org.matsim.core.router.util.LeastCostPathCalculator.Path; @@ -72,7 +71,7 @@ public CSVehicle chooseVehicleActivityTimeIncluded(List vehicleOption CSVehicle chosenVehicle = null; double maxUtility = Integer.MIN_VALUE; - double marginalUtilityOfMoney = ((PlanCalcScoreConfigGroup) scenario.getConfig().getModule("planCalcScore")) + double marginalUtilityOfMoney = ((ScoringConfigGroup) scenario.getConfig().getModule("planCalcScore")) .getMarginalUtilityOfMoney(); for (CSVehicle vehicle : vehicleOptions) { Link vehicleLocation = this.carsharingSupply.getCompany(vehicle.getCompanyId()) diff --git a/contribs/carsharing/src/main/java/org/matsim/contrib/carsharing/scoring/CarsharingLegScoringFunction.java b/contribs/carsharing/src/main/java/org/matsim/contrib/carsharing/scoring/CarsharingLegScoringFunction.java index 4c41d77c15e..d7d8fdc0c34 100644 --- a/contribs/carsharing/src/main/java/org/matsim/contrib/carsharing/scoring/CarsharingLegScoringFunction.java +++ b/contribs/carsharing/src/main/java/org/matsim/contrib/carsharing/scoring/CarsharingLegScoringFunction.java @@ -11,15 +11,15 @@ import org.matsim.contrib.carsharing.manager.supply.costs.CostsCalculatorContainer; import org.matsim.contrib.carsharing.vehicles.CSVehicle; import org.matsim.core.config.Config; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; import org.matsim.core.scoring.functions.ScoringParameters; public class CarsharingLegScoringFunction extends org.matsim.core.scoring.functions.CharyparNagelLegScoring { - - private Config config; - + + private Config config; + private CostsCalculatorContainer costsCalculatorContainer; private DemandHandler demandHandler; private Person person; @@ -27,11 +27,11 @@ public class CarsharingLegScoringFunction extends org.matsim.core.scoring.functi /* private static final Set walkingLegs = ImmutableSet.of("egress_walk_ow", "access_walk_ow", "egress_walk_tw", "access_walk_tw", "egress_walk_ff", "access_walk_ff"); - + private static final Set carsharingLegs = ImmutableSet.of("oneway_vehicle", "twoway_vehicle", "freefloating_vehicle");*/ - - public CarsharingLegScoringFunction(ScoringParameters params, + + public CarsharingLegScoringFunction(ScoringParameters params, Config config, Network network, DemandHandler demandHandler, CostsCalculatorContainer costsCalculatorContainer, CarsharingSupplyInterface carsharingSupplyContainer, Person person) @@ -41,62 +41,62 @@ public CarsharingLegScoringFunction(ScoringParameters params, this.demandHandler = demandHandler; this.carsharingSupplyContainer = carsharingSupplyContainer; this.costsCalculatorContainer = costsCalculatorContainer; - this.person = person; + this.person = person; } @Override public void handleEvent(Event event) { - super.handleEvent(event); - } - + super.handleEvent(event); + } + @Override - public void finish() { - super.finish(); - + public void finish() { + super.finish(); + AgentRentals agentRentals = this.demandHandler.getAgentRentalsMap().get(person.getId()); if (agentRentals != null) { - double marginalUtilityOfMoney = ((PlanCalcScoreConfigGroup)this.config.getModule("planCalcScore")).getMarginalUtilityOfMoney(); + double marginalUtilityOfMoney = ((ScoringConfigGroup)this.config.getModule("planCalcScore")).getMarginalUtilityOfMoney(); for(RentalInfo rentalInfo : agentRentals.getArr()) { CSVehicle vehicle = this.carsharingSupplyContainer.getAllVehicles().get(rentalInfo.getVehId().toString()); if (marginalUtilityOfMoney != 0.0) - score += -1 * this.costsCalculatorContainer.getCost(vehicle.getCompanyId(), + score += -1 * this.costsCalculatorContainer.getCost(vehicle.getCompanyId(), rentalInfo.getCarsharingType(), rentalInfo) * marginalUtilityOfMoney; - } - } - } - + } + } + } + @Override protected double calcLegScore(double departureTime, double arrivalTime, Leg leg) { - - + + double tmpScore = 0.0D; /*double travelTime = arrivalTime - departureTime; String mode = leg.getMode(); if (carsharingLegs.contains(mode)) { - - if (("oneway_vehicle").equals(mode)) { + + if (("oneway_vehicle").equals(mode)) { tmpScore += Double.parseDouble(this.config.getModule("OneWayCarsharing").getParams().get("constantOneWayCarsharing")); tmpScore += travelTime * Double.parseDouble(this.config.getModule("OneWayCarsharing").getParams().get("travelingOneWayCarsharing")) / 3600.0; - } - - else if (("freefloating_vehicle").equals(mode)) { - + } + + else if (("freefloating_vehicle").equals(mode)) { + tmpScore += Double.parseDouble(this.config.getModule("FreeFloating").getParams().get("constantFreeFloating")); tmpScore += travelTime * Double.parseDouble(this.config.getModule("FreeFloating").getParams().get("travelingFreeFloating")) / 3600.0; - } - - else if (("twoway_vehicle").equals(mode)) { - + } + + else if (("twoway_vehicle").equals(mode)) { + tmpScore += Double.parseDouble(this.config.getModule("TwoWayCarsharing").getParams().get("constantTwoWayCarsharing")); tmpScore += travelTime * Double.parseDouble(this.config.getModule("TwoWayCarsharing").getParams().get("travelingTwoWayCarsharing")) / 3600.0; } } - + else if (walkingLegs.contains(mode)) { - + tmpScore += getWalkScore(leg.getRoute().getDistance(), travelTime); - - }*/ + + }*/ return tmpScore; } diff --git a/contribs/carsharing/src/test/java/org/matsim/contrib/carsharing/runExample/RunCarsharingIT.java b/contribs/carsharing/src/test/java/org/matsim/contrib/carsharing/runExample/RunCarsharingIT.java index a73015e0dd5..ea7dd5f4dfa 100644 --- a/contribs/carsharing/src/test/java/org/matsim/contrib/carsharing/runExample/RunCarsharingIT.java +++ b/contribs/carsharing/src/test/java/org/matsim/contrib/carsharing/runExample/RunCarsharingIT.java @@ -19,8 +19,8 @@ package org.matsim.contrib.carsharing.runExample; -import static org.matsim.core.config.groups.PlansCalcRouteConfigGroup.AccessEgressType; -import static org.matsim.core.config.groups.PlansCalcRouteConfigGroup.TeleportedModeParams; +import static org.matsim.core.config.groups.RoutingConfigGroup.AccessEgressType; +import static org.matsim.core.config.groups.RoutingConfigGroup.TeleportedModeParams; import com.google.inject.Inject; import org.apache.logging.log4j.LogManager; diff --git a/contribs/commercialTrafficApplications/src/main/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/DefaultCommercialJobGenerator.java b/contribs/commercialTrafficApplications/src/main/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/DefaultCommercialJobGenerator.java index 657770b272b..f38e91f70e4 100644 --- a/contribs/commercialTrafficApplications/src/main/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/DefaultCommercialJobGenerator.java +++ b/contribs/commercialTrafficApplications/src/main/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/DefaultCommercialJobGenerator.java @@ -49,7 +49,7 @@ import org.matsim.contrib.freight.carrier.Tour; import org.matsim.contrib.freight.jsprit.VRPTransportCostsFactory; import org.matsim.core.config.Config; -import org.matsim.core.config.groups.StrategyConfigGroup.StrategySettings; +import org.matsim.core.config.groups.ReplanningConfigGroup.StrategySettings; import org.matsim.core.controler.events.AfterMobsimEvent; import org.matsim.core.controler.events.BeforeMobsimEvent; import org.matsim.core.population.PopulationUtils; diff --git a/contribs/commercialTrafficApplications/src/main/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/RunJointDemandCarToggleJspritExample.java b/contribs/commercialTrafficApplications/src/main/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/RunJointDemandCarToggleJspritExample.java index 9a0df38130b..1e71f4b5373 100644 --- a/contribs/commercialTrafficApplications/src/main/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/RunJointDemandCarToggleJspritExample.java +++ b/contribs/commercialTrafficApplications/src/main/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/RunJointDemandCarToggleJspritExample.java @@ -26,8 +26,8 @@ import org.matsim.contrib.freight.controler.FreightUtils; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; -import org.matsim.core.config.groups.StrategyConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; +import org.matsim.core.config.groups.ReplanningConfigGroup; import org.matsim.core.controler.Controler; import org.matsim.core.controler.OutputDirectoryHierarchy; import org.matsim.core.replanning.strategies.DefaultPlanStrategiesModule; @@ -88,21 +88,21 @@ public void run(URL configUrl){ } private static void prepareConfig(Config config) { - StrategyConfigGroup.StrategySettings changeExpBeta = new StrategyConfigGroup.StrategySettings(); + ReplanningConfigGroup.StrategySettings changeExpBeta = new ReplanningConfigGroup.StrategySettings(); changeExpBeta.setStrategyName(DefaultPlanStrategiesModule.DefaultSelector.ChangeExpBeta); changeExpBeta.setWeight(0.5); config.strategy().addStrategySettings(changeExpBeta); - StrategyConfigGroup.StrategySettings changeJobOperator = new StrategyConfigGroup.StrategySettings(); + ReplanningConfigGroup.StrategySettings changeJobOperator = new ReplanningConfigGroup.StrategySettings(); changeJobOperator.setStrategyName(ChangeCommercialJobOperator.SELECTOR_NAME); changeJobOperator.setWeight(0.5); config.strategy().addStrategySettings(changeJobOperator); config.strategy().setFractionOfIterationsToDisableInnovation(.8); - PlanCalcScoreConfigGroup.ActivityParams home = new PlanCalcScoreConfigGroup.ActivityParams("home"); + ScoringConfigGroup.ActivityParams home = new ScoringConfigGroup.ActivityParams("home"); home.setTypicalDuration(14 * 3600); config.planCalcScore().addActivityParams(home); - PlanCalcScoreConfigGroup.ActivityParams work = new PlanCalcScoreConfigGroup.ActivityParams("work"); + ScoringConfigGroup.ActivityParams work = new ScoringConfigGroup.ActivityParams("work"); work.setTypicalDuration(14 * 3600); work.setOpeningTime(8 * 3600); work.setClosingTime(8 * 3600); diff --git a/contribs/commercialTrafficApplications/src/main/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/examples/RunJointDemandCarExample.java b/contribs/commercialTrafficApplications/src/main/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/examples/RunJointDemandCarExample.java index 5a3386fba32..bc9536aca2a 100644 --- a/contribs/commercialTrafficApplications/src/main/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/examples/RunJointDemandCarExample.java +++ b/contribs/commercialTrafficApplications/src/main/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/examples/RunJointDemandCarExample.java @@ -29,8 +29,8 @@ import org.matsim.contrib.freight.controler.FreightUtils; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; -import org.matsim.core.config.groups.StrategyConfigGroup; +import org.matsim.core.config.groups.ReplanningConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; import org.matsim.core.controler.Controler; import org.matsim.core.controler.OutputDirectoryHierarchy; import org.matsim.core.replanning.strategies.DefaultPlanStrategiesModule; @@ -90,21 +90,21 @@ public void run(URL configUrl){ } private static void prepareConfig(Config config) { - StrategyConfigGroup.StrategySettings changeExpBeta = new StrategyConfigGroup.StrategySettings(); + ReplanningConfigGroup.StrategySettings changeExpBeta = new ReplanningConfigGroup.StrategySettings(); changeExpBeta.setStrategyName(DefaultPlanStrategiesModule.DefaultSelector.ChangeExpBeta); changeExpBeta.setWeight(0.5); config.strategy().addStrategySettings(changeExpBeta); - StrategyConfigGroup.StrategySettings changeJobOperator = new StrategyConfigGroup.StrategySettings(); + ReplanningConfigGroup.StrategySettings changeJobOperator = new ReplanningConfigGroup.StrategySettings(); changeJobOperator.setStrategyName(ChangeCommercialJobOperator.SELECTOR_NAME); changeJobOperator.setWeight(0.5); config.strategy().addStrategySettings(changeJobOperator); config.strategy().setFractionOfIterationsToDisableInnovation(.8); - PlanCalcScoreConfigGroup.ActivityParams home = new PlanCalcScoreConfigGroup.ActivityParams("home"); + ScoringConfigGroup.ActivityParams home = new ScoringConfigGroup.ActivityParams("home"); home.setTypicalDuration(14 * 3600); config.planCalcScore().addActivityParams(home); - PlanCalcScoreConfigGroup.ActivityParams work = new PlanCalcScoreConfigGroup.ActivityParams("work"); + ScoringConfigGroup.ActivityParams work = new ScoringConfigGroup.ActivityParams("work"); work.setTypicalDuration(14 * 3600); work.setOpeningTime(8 * 3600); work.setClosingTime(8 * 3600); diff --git a/contribs/commercialTrafficApplications/src/main/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/examples/RunJointDemandDRTExample.java b/contribs/commercialTrafficApplications/src/main/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/examples/RunJointDemandDRTExample.java index ee0983bd2df..0d9d61cc72f 100644 --- a/contribs/commercialTrafficApplications/src/main/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/examples/RunJointDemandDRTExample.java +++ b/contribs/commercialTrafficApplications/src/main/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/examples/RunJointDemandDRTExample.java @@ -40,9 +40,9 @@ import org.matsim.contrib.freight.controler.FreightUtils; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; import org.matsim.core.config.groups.QSimConfigGroup; -import org.matsim.core.config.groups.StrategyConfigGroup; +import org.matsim.core.config.groups.ReplanningConfigGroup; import org.matsim.core.controler.Controler; import org.matsim.core.controler.OutputDirectoryHierarchy; import org.matsim.core.replanning.strategies.DefaultPlanStrategiesModule; @@ -102,20 +102,20 @@ private static void prepareConfig(Config config) { config.qsim().setSimStarttimeInterpretation(QSimConfigGroup.StarttimeInterpretation.onlyUseStarttime); - StrategyConfigGroup.StrategySettings changeExpBeta = new StrategyConfigGroup.StrategySettings(); + ReplanningConfigGroup.StrategySettings changeExpBeta = new ReplanningConfigGroup.StrategySettings(); changeExpBeta.setStrategyName(DefaultPlanStrategiesModule.DefaultSelector.ChangeExpBeta); changeExpBeta.setWeight(0.5); config.strategy().addStrategySettings(changeExpBeta); - StrategyConfigGroup.StrategySettings changeServiceOperator = new StrategyConfigGroup.StrategySettings(); + ReplanningConfigGroup.StrategySettings changeServiceOperator = new ReplanningConfigGroup.StrategySettings(); changeServiceOperator.setStrategyName(ChangeCommercialJobOperator.SELECTOR_NAME); changeServiceOperator.setWeight(0.5); config.strategy().addStrategySettings(changeServiceOperator); config.strategy().setFractionOfIterationsToDisableInnovation(.8); - PlanCalcScoreConfigGroup.ActivityParams home = new PlanCalcScoreConfigGroup.ActivityParams("home"); + ScoringConfigGroup.ActivityParams home = new ScoringConfigGroup.ActivityParams("home"); home.setTypicalDuration(14 * 3600); config.planCalcScore().addActivityParams(home); - PlanCalcScoreConfigGroup.ActivityParams work = new PlanCalcScoreConfigGroup.ActivityParams("work"); + ScoringConfigGroup.ActivityParams work = new ScoringConfigGroup.ActivityParams("work"); work.setTypicalDuration(14 * 3600); work.setOpeningTime(8 * 3600); work.setClosingTime(8 * 3600); diff --git a/contribs/common/src/test/java/org/matsim/contrib/common/randomizingtransitrouter/RandomizingTransitRouterIT.java b/contribs/common/src/test/java/org/matsim/contrib/common/randomizingtransitrouter/RandomizingTransitRouterIT.java index e703c6c4af6..80024394f05 100644 --- a/contribs/common/src/test/java/org/matsim/contrib/common/randomizingtransitrouter/RandomizingTransitRouterIT.java +++ b/contribs/common/src/test/java/org/matsim/contrib/common/randomizingtransitrouter/RandomizingTransitRouterIT.java @@ -33,11 +33,9 @@ import org.matsim.api.core.v01.events.handler.PersonEntersVehicleEventHandler; import org.matsim.contrib.common.randomizedtransitrouter.RandomizingTransitRouterModule; import org.matsim.core.config.Config; -import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.FacilitiesConfigGroup; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup.ActivityParams; +import org.matsim.core.config.groups.ScoringConfigGroup.ActivityParams; import org.matsim.core.config.groups.QSimConfigGroup.TrafficDynamics; -import org.matsim.core.config.groups.StrategyConfigGroup.StrategySettings; +import org.matsim.core.config.groups.ReplanningConfigGroup.StrategySettings; import org.matsim.core.config.groups.VspExperimentalConfigGroup.VspDefaultsCheckingLevel; import org.matsim.core.controler.Controler; import org.matsim.core.replanning.strategies.DefaultPlanStrategiesModule.DefaultSelector; @@ -54,11 +52,11 @@ */ public class RandomizingTransitRouterIT { private static final Logger log = LogManager.getLogger( RandomizingTransitRouterIT.class ) ; - + private static final class MyObserver implements PersonEntersVehicleEventHandler { // private enum ObservedVehicle{ pt_1009_1 /*direct, fast, with wait*/, pt_2009_1 /*direct, slow*/, pt_3009_1 /*with interchange*/} ; - - Map,Double> cnts = new HashMap<>() ; + + Map,Double> cnts = new HashMap<>() ; @Override public void reset(int iteration) { cnts.clear(); @@ -67,13 +65,13 @@ private static final class MyObserver implements PersonEntersVehicleEventHandler @Override public void handleEvent(PersonEntersVehicleEvent event) { cnts.merge( event.getVehicleId() , 1. , Double::sum ); } - + void printCounts() { for ( Entry, Double> entry : cnts.entrySet() ) { log.info( "Vehicle id: " + entry.getKey() + "; number of boards: " + entry.getValue() ) ; } } - + Map< Id, Double> getCounts() { return this.cnts ; } @@ -87,7 +85,7 @@ public final void test() { String outputDir = utils.getOutputDirectory() ; Config config = utils.createConfigWithPackageInputResourcePathAsContext(); - + config.network().setInputFile("network.xml"); config.plans().setInputFile("population.xml"); @@ -95,14 +93,14 @@ public final void test() { config.transit().setTransitScheduleFile("transitschedule.xml"); config.transit().setVehiclesFile("transitVehicles.xml"); config.transit().setUseTransit(true); - + config.controler().setOutputDirectory( outputDir ); config.controler().setLastIteration(20); config.controler().setCreateGraphs(false); config.controler().setDumpDataAtEnd(false); - + config.global().setNumberOfThreads(1); - + config.planCalcScore().addActivityParams( new ActivityParams("home").setTypicalDuration( 6*3600. ) ); config.planCalcScore().addActivityParams( new ActivityParams("education_100").setTypicalDuration( 6*3600. ) ); @@ -113,7 +111,7 @@ public final void test() { // yy changing the above (= no longer using createAvailableStrategyId) changes the results. :-( :-( :-( config.qsim().setEndTime(18.*3600.); - + config.timeAllocationMutator().setMutationRange(7200); config.timeAllocationMutator().setAffectingDuration(false); config.plans().setRemovingUnneccessaryPlanAttributes(true); @@ -125,39 +123,39 @@ public final void test() { // * The implicit activity coordinates may be elsewhere. // * The "fudged" walk distances may be different. // * It uses getNearestLinkEXACTLY, and thus activities may be attached to other links. - + config.vspExperimental().setWritingOutputEvents(true); config.vspExperimental().setVspDefaultsCheckingLevel( VspDefaultsCheckingLevel.warn ); - + // --- - + Scenario scenario = ScenarioUtils.loadScenario( config ) ; - + // --- - + Controler controler = new Controler( scenario ) ; controler.addOverridingModule( new RandomizingTransitRouterModule() ); final MyObserver observer = new MyObserver(); controler.getEvents().addHandler(observer); - + controler.run(); - + // --- - - observer.printCounts(); - + + observer.printCounts(); + // yyyy the following is just a regression test, making sure that results remain stable. In general, the randomized transit router // could be improved, for example along the lines of the randomized regular router, which uses a (hopefully unbiased) lognormal // distribution rather than a biased uniform distribution as is used here. kai, jul'15 - + Assert.assertEquals(36., observer.getCounts().get( Id.create("1009", Vehicle.class) ), 0.1 ); Assert.assertEquals( 8. /*6.*/ , observer.getCounts().get( Id.create("1012", Vehicle.class) ) , 0.1 ); Assert.assertEquals(22. /*21.*/, observer.getCounts().get( Id.create("2009", Vehicle.class) ) , 0.1 ); Assert.assertEquals(36., observer.getCounts().get( Id.create("3009", Vehicle.class) ) , 0.1 ); - - + + } } diff --git a/contribs/decongestion/src/main/java/org/matsim/contrib/decongestion/DecongestionControlerListener.java b/contribs/decongestion/src/main/java/org/matsim/contrib/decongestion/DecongestionControlerListener.java index 07b279f0be9..656d7e583d0 100644 --- a/contribs/decongestion/src/main/java/org/matsim/contrib/decongestion/DecongestionControlerListener.java +++ b/contribs/decongestion/src/main/java/org/matsim/contrib/decongestion/DecongestionControlerListener.java @@ -40,7 +40,7 @@ import org.matsim.contrib.decongestion.handler.DelayAnalysis; import org.matsim.contrib.decongestion.handler.IntervalBasedTolling; import org.matsim.contrib.decongestion.tollSetting.DecongestionTollSetting; -import org.matsim.core.config.groups.StrategyConfigGroup.StrategySettings; +import org.matsim.core.config.groups.ReplanningConfigGroup.StrategySettings; import org.matsim.core.controler.events.AfterMobsimEvent; import org.matsim.core.controler.events.IterationEndsEvent; import org.matsim.core.controler.events.IterationStartsEvent; diff --git a/contribs/discrete_mode_choice/src/main/java/org/matsim/contribs/discrete_mode_choice/modules/DiscreteModeChoiceConfigurator.java b/contribs/discrete_mode_choice/src/main/java/org/matsim/contribs/discrete_mode_choice/modules/DiscreteModeChoiceConfigurator.java index 44838aa3186..94fe60a570a 100644 --- a/contribs/discrete_mode_choice/src/main/java/org/matsim/contribs/discrete_mode_choice/modules/DiscreteModeChoiceConfigurator.java +++ b/contribs/discrete_mode_choice/src/main/java/org/matsim/contribs/discrete_mode_choice/modules/DiscreteModeChoiceConfigurator.java @@ -10,8 +10,8 @@ import org.matsim.contribs.discrete_mode_choice.modules.config.DiscreteModeChoiceConfigGroup; import org.matsim.contribs.discrete_mode_choice.replanning.NonSelectedPlanSelector; import org.matsim.core.config.Config; -import org.matsim.core.config.groups.StrategyConfigGroup; -import org.matsim.core.config.groups.StrategyConfigGroup.StrategySettings; +import org.matsim.core.config.groups.ReplanningConfigGroup; +import org.matsim.core.config.groups.ReplanningConfigGroup.StrategySettings; import org.matsim.core.config.groups.SubtourModeChoiceConfigGroup; import org.matsim.core.replanning.strategies.DefaultPlanStrategiesModule.DefaultSelector; import org.matsim.core.replanning.strategies.DefaultPlanStrategiesModule.DefaultStrategy; @@ -19,7 +19,7 @@ /** * Utility class that makes it possible to set up various was of using the * Discrete Mode Choice extension with MATSim. - * + * * @author sebhoerl */ public final class DiscreteModeChoiceConfigurator { @@ -89,24 +89,24 @@ static public void configureAsModeChoiceInTheLoop(Config config) { } static public void configureAsModeChoiceInTheLoop(Config config, double replanningRate) { - StrategyConfigGroup strategyConfigGroup = config.strategy(); - strategyConfigGroup.clearStrategySettings(); + ReplanningConfigGroup replanningConfigGroup = config.strategy(); + replanningConfigGroup.clearStrategySettings(); - strategyConfigGroup.setMaxAgentPlanMemorySize(1); - strategyConfigGroup.setFractionOfIterationsToDisableInnovation(Double.POSITIVE_INFINITY); - strategyConfigGroup.setPlanSelectorForRemoval(NonSelectedPlanSelector.NAME); + replanningConfigGroup.setMaxAgentPlanMemorySize(1); + replanningConfigGroup.setFractionOfIterationsToDisableInnovation(Double.POSITIVE_INFINITY); + replanningConfigGroup.setPlanSelectorForRemoval(NonSelectedPlanSelector.NAME); StrategySettings dmcStrategy = new StrategySettings(); dmcStrategy.setStrategyName(DiscreteModeChoiceModule.STRATEGY_NAME); dmcStrategy.setWeight(replanningRate); - strategyConfigGroup.addStrategySettings(dmcStrategy); + replanningConfigGroup.addStrategySettings(dmcStrategy); StrategySettings selectorStrategy = new StrategySettings(); selectorStrategy.setStrategyName(DefaultSelector.KeepLastSelected); selectorStrategy.setWeight(1.0 - replanningRate); - strategyConfigGroup.addStrategySettings(selectorStrategy); + replanningConfigGroup.addStrategySettings(selectorStrategy); - checkModeChoiceInTheLoop(strategyConfigGroup); + checkModeChoiceInTheLoop(replanningConfigGroup); DiscreteModeChoiceConfigGroup dmcConfig = (DiscreteModeChoiceConfigGroup) config.getModules() .get(DiscreteModeChoiceConfigGroup.GROUP_NAME); @@ -119,15 +119,15 @@ static public void configureAsModeChoiceInTheLoop(Config config, double replanni dmcConfig.setEnforceSinglePlan(true); } - public static void checkModeChoiceInTheLoop(StrategyConfigGroup strategyConfigGroup) { - if (strategyConfigGroup.getMaxAgentPlanMemorySize() != 1) { + public static void checkModeChoiceInTheLoop(ReplanningConfigGroup replanningConfigGroup) { + if (replanningConfigGroup.getMaxAgentPlanMemorySize() != 1) { throw new IllegalStateException( "Option strategy.maxAgentPlanMemorySize should be 1 if mode-choice-in-the-loop is enforced."); } Set activeStrategies = new HashSet<>(); - for (StrategySettings strategySettings : strategyConfigGroup.getStrategySettings()) { + for (StrategySettings strategySettings : replanningConfigGroup.getStrategySettings()) { if (strategySettings.getDisableAfter() != 0) { activeStrategies.add(strategySettings.getStrategyName()); } @@ -146,14 +146,14 @@ public static void checkModeChoiceInTheLoop(StrategyConfigGroup strategyConfigGr activeStrategies.remove(DefaultSelector.KeepLastSelected); activeStrategies.remove(DiscreteModeChoiceModule.STRATEGY_NAME); activeStrategies.remove(DefaultStrategy.ReRoute); - + if (activeStrategies.size() > 0) { throw new IllegalStateException( "All these strategies should be disabled (disableAfter == 0) if mode-choice-in-the-loop is enforced: " + activeStrategies); } - if (!strategyConfigGroup.getPlanSelectorForRemoval().equals(NonSelectedPlanSelector.NAME)) { + if (!replanningConfigGroup.getPlanSelectorForRemoval().equals(NonSelectedPlanSelector.NAME)) { throw new IllegalStateException( "Removal selector should be NonSelectedPlanSelector if mode-choice-in-the-loop is enforced."); } diff --git a/contribs/discrete_mode_choice/src/main/java/org/matsim/contribs/discrete_mode_choice/modules/utils/ModeChoiceInTheLoopChecker.java b/contribs/discrete_mode_choice/src/main/java/org/matsim/contribs/discrete_mode_choice/modules/utils/ModeChoiceInTheLoopChecker.java index 0d7df42a168..04617415d08 100644 --- a/contribs/discrete_mode_choice/src/main/java/org/matsim/contribs/discrete_mode_choice/modules/utils/ModeChoiceInTheLoopChecker.java +++ b/contribs/discrete_mode_choice/src/main/java/org/matsim/contribs/discrete_mode_choice/modules/utils/ModeChoiceInTheLoopChecker.java @@ -4,7 +4,7 @@ import org.matsim.api.core.v01.population.Plan; import org.matsim.contribs.discrete_mode_choice.modules.DiscreteModeChoiceConfigurator; import org.matsim.contribs.discrete_mode_choice.replanning.NonSelectedPlanSelector; -import org.matsim.core.config.groups.StrategyConfigGroup; +import org.matsim.core.config.groups.ReplanningConfigGroup; import org.matsim.core.controler.events.StartupEvent; import org.matsim.core.controler.listener.StartupListener; import org.matsim.core.replanning.selectors.PlanSelector; @@ -14,16 +14,16 @@ /** * Internal listener that is used to do some runtime checks when * mode-choice-in-the-loop should be enforced. - * + * * @author sebhoerl * */ public class ModeChoiceInTheLoopChecker implements StartupListener { - private final StrategyConfigGroup strategyConfig; + private final ReplanningConfigGroup strategyConfig; private final PlanSelector removalSelector; @Inject - public ModeChoiceInTheLoopChecker(StrategyConfigGroup strategyConfig, PlanSelector removalSelector) { + public ModeChoiceInTheLoopChecker(ReplanningConfigGroup strategyConfig, PlanSelector removalSelector) { this.strategyConfig = strategyConfig; this.removalSelector = removalSelector; } diff --git a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/DrtTestScenario.java b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/DrtTestScenario.java index 4ca143f3cf3..727e308844a 100644 --- a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/DrtTestScenario.java +++ b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/DrtTestScenario.java @@ -17,8 +17,8 @@ import org.matsim.contrib.vsp.scenario.SnzActivities; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; -import org.matsim.core.config.groups.PlansCalcRouteConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; +import org.matsim.core.config.groups.RoutingConfigGroup; import org.matsim.core.controler.Controler; import org.matsim.core.controler.OutputDirectoryHierarchy; import org.matsim.core.utils.io.IOUtils; @@ -76,11 +76,11 @@ protected Config prepareConfig(Config config) { SnzActivities.addScoringParams(config); - config.planCalcScore().addActivityParams(new PlanCalcScoreConfigGroup.ActivityParams("car interaction").setTypicalDuration(60)); - config.planCalcScore().addActivityParams(new PlanCalcScoreConfigGroup.ActivityParams("other").setTypicalDuration(600 * 3)); + config.planCalcScore().addActivityParams(new ScoringConfigGroup.ActivityParams("car interaction").setTypicalDuration(60)); + config.planCalcScore().addActivityParams(new ScoringConfigGroup.ActivityParams("other").setTypicalDuration(600 * 3)); - config.planCalcScore().addActivityParams(new PlanCalcScoreConfigGroup.ActivityParams("freight_start").setTypicalDuration(60 * 15)); - config.planCalcScore().addActivityParams(new PlanCalcScoreConfigGroup.ActivityParams("freight_end").setTypicalDuration(60 * 15)); + config.planCalcScore().addActivityParams(new ScoringConfigGroup.ActivityParams("freight_start").setTypicalDuration(60 * 15)); + config.planCalcScore().addActivityParams(new ScoringConfigGroup.ActivityParams("freight_end").setTypicalDuration(60 * 15)); MultiModeDrtConfigGroup multiModeDrtConfig = ConfigUtils.addOrGetModule(config, MultiModeDrtConfigGroup.class); @@ -88,7 +88,7 @@ protected Config prepareConfig(Config config) { DrtConfigs.adjustMultiModeDrtConfig(multiModeDrtConfig, config.planCalcScore(), config.plansCalcRoute()); - config.plansCalcRoute().setAccessEgressType(PlansCalcRouteConfigGroup.AccessEgressType.accessEgressModeToLink); + config.plansCalcRoute().setAccessEgressType(RoutingConfigGroup.AccessEgressType.accessEgressModeToLink); prepareConfig.accept(config); diff --git a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/fiss/RunFissDrtScenarioIT.java b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/fiss/RunFissDrtScenarioIT.java index c6ad3f7dff8..90c58dcc729 100644 --- a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/fiss/RunFissDrtScenarioIT.java +++ b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/fiss/RunFissDrtScenarioIT.java @@ -20,9 +20,9 @@ import org.matsim.core.config.Config; import org.matsim.core.config.ConfigGroup; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; import org.matsim.core.config.groups.QSimConfigGroup; -import org.matsim.core.config.groups.StrategyConfigGroup; +import org.matsim.core.config.groups.ReplanningConfigGroup; import org.matsim.core.controler.AbstractModule; import org.matsim.core.controler.Controler; import org.matsim.core.controler.OutputDirectoryHierarchy; @@ -91,9 +91,9 @@ public void test() { modes.add("drt"); config.travelTimeCalculator().setAnalyzedModes(modes); - PlanCalcScoreConfigGroup.ModeParams scoreParams = new PlanCalcScoreConfigGroup.ModeParams("drt"); + ScoringConfigGroup.ModeParams scoreParams = new ScoringConfigGroup.ModeParams("drt"); config.planCalcScore().addModeParams(scoreParams); - PlanCalcScoreConfigGroup.ModeParams scoreParams2 = new PlanCalcScoreConfigGroup.ModeParams("walk"); + ScoringConfigGroup.ModeParams scoreParams2 = new ScoringConfigGroup.ModeParams("walk"); config.planCalcScore().addModeParams(scoreParams2); config.plans().setInputFile(plansFile); @@ -102,15 +102,15 @@ public void test() { config.qsim().setSimStarttimeInterpretation(QSimConfigGroup.StarttimeInterpretation.onlyUseStarttime); config.qsim().setSimEndtimeInterpretation(QSimConfigGroup.EndtimeInterpretation.minOfEndtimeAndMobsimFinished); - final PlanCalcScoreConfigGroup.ActivityParams home = new PlanCalcScoreConfigGroup.ActivityParams("home"); + final ScoringConfigGroup.ActivityParams home = new ScoringConfigGroup.ActivityParams("home"); home.setTypicalDuration(8 * 3600); - final PlanCalcScoreConfigGroup.ActivityParams other = new PlanCalcScoreConfigGroup.ActivityParams("other"); + final ScoringConfigGroup.ActivityParams other = new ScoringConfigGroup.ActivityParams("other"); other.setTypicalDuration(4 * 3600); - final PlanCalcScoreConfigGroup.ActivityParams education = new PlanCalcScoreConfigGroup.ActivityParams("education"); + final ScoringConfigGroup.ActivityParams education = new ScoringConfigGroup.ActivityParams("education"); education.setTypicalDuration(6 * 3600); - final PlanCalcScoreConfigGroup.ActivityParams shopping = new PlanCalcScoreConfigGroup.ActivityParams("shopping"); + final ScoringConfigGroup.ActivityParams shopping = new ScoringConfigGroup.ActivityParams("shopping"); shopping.setTypicalDuration(2 * 3600); - final PlanCalcScoreConfigGroup.ActivityParams work = new PlanCalcScoreConfigGroup.ActivityParams("work"); + final ScoringConfigGroup.ActivityParams work = new ScoringConfigGroup.ActivityParams("work"); work.setTypicalDuration(2 * 3600); config.planCalcScore().addActivityParams(home); @@ -119,7 +119,7 @@ public void test() { config.planCalcScore().addActivityParams(shopping); config.planCalcScore().addActivityParams(work); - final StrategyConfigGroup.StrategySettings stratSets = new StrategyConfigGroup.StrategySettings(); + final ReplanningConfigGroup.StrategySettings stratSets = new ReplanningConfigGroup.StrategySettings(); stratSets.setWeight(1); stratSets.setStrategyName("ChangeExpBeta"); config.strategy().addStrategySettings(stratSets); diff --git a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/eshifts/run/RunEShiftDrtScenarioIT.java b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/eshifts/run/RunEShiftDrtScenarioIT.java index 1f57b4d54c7..be9a9ce3972 100644 --- a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/eshifts/run/RunEShiftDrtScenarioIT.java +++ b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/eshifts/run/RunEShiftDrtScenarioIT.java @@ -20,9 +20,9 @@ import org.matsim.core.config.Config; import org.matsim.core.config.ConfigGroup; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; +import org.matsim.core.config.groups.ReplanningConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; import org.matsim.core.config.groups.QSimConfigGroup; -import org.matsim.core.config.groups.StrategyConfigGroup; import org.matsim.core.controler.AbstractModule; import org.matsim.core.controler.Controler; import org.matsim.core.controler.OutputDirectoryHierarchy; @@ -94,9 +94,9 @@ public void test() { modes.add("drt"); config.travelTimeCalculator().setAnalyzedModes(modes); - PlanCalcScoreConfigGroup.ModeParams scoreParams = new PlanCalcScoreConfigGroup.ModeParams("drt"); + ScoringConfigGroup.ModeParams scoreParams = new ScoringConfigGroup.ModeParams("drt"); config.planCalcScore().addModeParams(scoreParams); - PlanCalcScoreConfigGroup.ModeParams scoreParams2 = new PlanCalcScoreConfigGroup.ModeParams("walk"); + ScoringConfigGroup.ModeParams scoreParams2 = new ScoringConfigGroup.ModeParams("walk"); config.planCalcScore().addModeParams(scoreParams2); config.plans().setInputFile(plansFile); @@ -106,15 +106,15 @@ public void test() { config.qsim().setSimEndtimeInterpretation(QSimConfigGroup.EndtimeInterpretation.minOfEndtimeAndMobsimFinished); - final PlanCalcScoreConfigGroup.ActivityParams home = new PlanCalcScoreConfigGroup.ActivityParams("home"); + final ScoringConfigGroup.ActivityParams home = new ScoringConfigGroup.ActivityParams("home"); home.setTypicalDuration(8 * 3600); - final PlanCalcScoreConfigGroup.ActivityParams other = new PlanCalcScoreConfigGroup.ActivityParams("other"); + final ScoringConfigGroup.ActivityParams other = new ScoringConfigGroup.ActivityParams("other"); other.setTypicalDuration(4 * 3600); - final PlanCalcScoreConfigGroup.ActivityParams education = new PlanCalcScoreConfigGroup.ActivityParams("education"); + final ScoringConfigGroup.ActivityParams education = new ScoringConfigGroup.ActivityParams("education"); education.setTypicalDuration(6 * 3600); - final PlanCalcScoreConfigGroup.ActivityParams shopping = new PlanCalcScoreConfigGroup.ActivityParams("shopping"); + final ScoringConfigGroup.ActivityParams shopping = new ScoringConfigGroup.ActivityParams("shopping"); shopping.setTypicalDuration(2 * 3600); - final PlanCalcScoreConfigGroup.ActivityParams work = new PlanCalcScoreConfigGroup.ActivityParams("work"); + final ScoringConfigGroup.ActivityParams work = new ScoringConfigGroup.ActivityParams("work"); work.setTypicalDuration(2 * 3600); config.planCalcScore().addActivityParams(home); @@ -123,7 +123,7 @@ public void test() { config.planCalcScore().addActivityParams(shopping); config.planCalcScore().addActivityParams(work); - final StrategyConfigGroup.StrategySettings stratSets = new StrategyConfigGroup.StrategySettings(); + final ReplanningConfigGroup.StrategySettings stratSets = new ReplanningConfigGroup.StrategySettings(); stratSets.setWeight(1); stratSets.setStrategyName("ChangeExpBeta"); config.strategy().addStrategySettings(stratSets); diff --git a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/shifts/run/RunMultiHubShiftDrtScenarioIT.java b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/shifts/run/RunMultiHubShiftDrtScenarioIT.java index 8b0e6b3a179..fa860c4ccdf 100644 --- a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/shifts/run/RunMultiHubShiftDrtScenarioIT.java +++ b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/shifts/run/RunMultiHubShiftDrtScenarioIT.java @@ -17,9 +17,9 @@ import org.matsim.core.config.Config; import org.matsim.core.config.ConfigGroup; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; import org.matsim.core.config.groups.QSimConfigGroup; -import org.matsim.core.config.groups.StrategyConfigGroup; +import org.matsim.core.config.groups.ReplanningConfigGroup; import org.matsim.core.controler.Controler; import org.matsim.core.controler.OutputDirectoryHierarchy; import org.matsim.examples.ExamplesUtils; @@ -83,9 +83,9 @@ public void test() { modes.add("drt"); config.travelTimeCalculator().setAnalyzedModes(modes); - PlanCalcScoreConfigGroup.ModeParams scoreParams = new PlanCalcScoreConfigGroup.ModeParams("drt"); + ScoringConfigGroup.ModeParams scoreParams = new ScoringConfigGroup.ModeParams("drt"); config.planCalcScore().addModeParams(scoreParams); - PlanCalcScoreConfigGroup.ModeParams scoreParams2 = new PlanCalcScoreConfigGroup.ModeParams("walk"); + ScoringConfigGroup.ModeParams scoreParams2 = new ScoringConfigGroup.ModeParams("walk"); config.planCalcScore().addModeParams(scoreParams2); config.plans().setInputFile(plansFile); @@ -95,15 +95,15 @@ public void test() { config.qsim().setSimEndtimeInterpretation(QSimConfigGroup.EndtimeInterpretation.minOfEndtimeAndMobsimFinished); - final PlanCalcScoreConfigGroup.ActivityParams home = new PlanCalcScoreConfigGroup.ActivityParams("home"); + final ScoringConfigGroup.ActivityParams home = new ScoringConfigGroup.ActivityParams("home"); home.setTypicalDuration(8 * 3600); - final PlanCalcScoreConfigGroup.ActivityParams other = new PlanCalcScoreConfigGroup.ActivityParams("other"); + final ScoringConfigGroup.ActivityParams other = new ScoringConfigGroup.ActivityParams("other"); other.setTypicalDuration(4 * 3600); - final PlanCalcScoreConfigGroup.ActivityParams education = new PlanCalcScoreConfigGroup.ActivityParams("education"); + final ScoringConfigGroup.ActivityParams education = new ScoringConfigGroup.ActivityParams("education"); education.setTypicalDuration(6 * 3600); - final PlanCalcScoreConfigGroup.ActivityParams shopping = new PlanCalcScoreConfigGroup.ActivityParams("shopping"); + final ScoringConfigGroup.ActivityParams shopping = new ScoringConfigGroup.ActivityParams("shopping"); shopping.setTypicalDuration(2 * 3600); - final PlanCalcScoreConfigGroup.ActivityParams work = new PlanCalcScoreConfigGroup.ActivityParams("work"); + final ScoringConfigGroup.ActivityParams work = new ScoringConfigGroup.ActivityParams("work"); work.setTypicalDuration(2 * 3600); config.planCalcScore().addActivityParams(home); @@ -112,7 +112,7 @@ public void test() { config.planCalcScore().addActivityParams(shopping); config.planCalcScore().addActivityParams(work); - final StrategyConfigGroup.StrategySettings stratSets = new StrategyConfigGroup.StrategySettings(); + final ReplanningConfigGroup.StrategySettings stratSets = new ReplanningConfigGroup.StrategySettings(); stratSets.setWeight(1); stratSets.setStrategyName("ChangeExpBeta"); config.strategy().addStrategySettings(stratSets); diff --git a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/shifts/run/RunShiftDrtScenarioIT.java b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/shifts/run/RunShiftDrtScenarioIT.java index 3205bae0a4f..39e6cd667b4 100644 --- a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/shifts/run/RunShiftDrtScenarioIT.java +++ b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/shifts/run/RunShiftDrtScenarioIT.java @@ -17,9 +17,9 @@ import org.matsim.core.config.Config; import org.matsim.core.config.ConfigGroup; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; +import org.matsim.core.config.groups.ReplanningConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; import org.matsim.core.config.groups.QSimConfigGroup; -import org.matsim.core.config.groups.StrategyConfigGroup; import org.matsim.core.controler.Controler; import org.matsim.core.controler.OutputDirectoryHierarchy; import org.matsim.examples.ExamplesUtils; @@ -84,9 +84,9 @@ public void test() { modes.add("drt"); config.travelTimeCalculator().setAnalyzedModes(modes); - PlanCalcScoreConfigGroup.ModeParams scoreParams = new PlanCalcScoreConfigGroup.ModeParams("drt"); + ScoringConfigGroup.ModeParams scoreParams = new ScoringConfigGroup.ModeParams("drt"); config.planCalcScore().addModeParams(scoreParams); - PlanCalcScoreConfigGroup.ModeParams scoreParams2 = new PlanCalcScoreConfigGroup.ModeParams("walk"); + ScoringConfigGroup.ModeParams scoreParams2 = new ScoringConfigGroup.ModeParams("walk"); config.planCalcScore().addModeParams(scoreParams2); config.plans().setInputFile(plansFile); @@ -95,15 +95,15 @@ public void test() { config.qsim().setSimStarttimeInterpretation(QSimConfigGroup.StarttimeInterpretation.onlyUseStarttime); config.qsim().setSimEndtimeInterpretation(QSimConfigGroup.EndtimeInterpretation.minOfEndtimeAndMobsimFinished); - final PlanCalcScoreConfigGroup.ActivityParams home = new PlanCalcScoreConfigGroup.ActivityParams("home"); + final ScoringConfigGroup.ActivityParams home = new ScoringConfigGroup.ActivityParams("home"); home.setTypicalDuration(8 * 3600); - final PlanCalcScoreConfigGroup.ActivityParams other = new PlanCalcScoreConfigGroup.ActivityParams("other"); + final ScoringConfigGroup.ActivityParams other = new ScoringConfigGroup.ActivityParams("other"); other.setTypicalDuration(4 * 3600); - final PlanCalcScoreConfigGroup.ActivityParams education = new PlanCalcScoreConfigGroup.ActivityParams("education"); + final ScoringConfigGroup.ActivityParams education = new ScoringConfigGroup.ActivityParams("education"); education.setTypicalDuration(6 * 3600); - final PlanCalcScoreConfigGroup.ActivityParams shopping = new PlanCalcScoreConfigGroup.ActivityParams("shopping"); + final ScoringConfigGroup.ActivityParams shopping = new ScoringConfigGroup.ActivityParams("shopping"); shopping.setTypicalDuration(2 * 3600); - final PlanCalcScoreConfigGroup.ActivityParams work = new PlanCalcScoreConfigGroup.ActivityParams("work"); + final ScoringConfigGroup.ActivityParams work = new ScoringConfigGroup.ActivityParams("work"); work.setTypicalDuration(2 * 3600); config.planCalcScore().addActivityParams(home); @@ -112,7 +112,7 @@ public void test() { config.planCalcScore().addActivityParams(shopping); config.planCalcScore().addActivityParams(work); - final StrategyConfigGroup.StrategySettings stratSets = new StrategyConfigGroup.StrategySettings(); + final ReplanningConfigGroup.StrategySettings stratSets = new ReplanningConfigGroup.StrategySettings(); stratSets.setWeight(1); stratSets.setStrategyName("ChangeExpBeta"); config.strategy().addStrategySettings(stratSets); diff --git a/contribs/drt/src/main/java/org/matsim/contrib/drt/routing/MultiModeDrtMainModeIdentifier.java b/contribs/drt/src/main/java/org/matsim/contrib/drt/routing/MultiModeDrtMainModeIdentifier.java index 549a4761a13..6fb846726ab 100644 --- a/contribs/drt/src/main/java/org/matsim/contrib/drt/routing/MultiModeDrtMainModeIdentifier.java +++ b/contribs/drt/src/main/java/org/matsim/contrib/drt/routing/MultiModeDrtMainModeIdentifier.java @@ -31,7 +31,7 @@ import org.matsim.api.core.v01.population.PlanElement; import org.matsim.contrib.drt.run.DrtConfigGroup; import org.matsim.contrib.drt.run.MultiModeDrtConfigGroup; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; import org.matsim.core.router.MainModeIdentifier; import org.matsim.core.router.MainModeIdentifierImpl; import org.matsim.core.router.TripRouter; @@ -49,7 +49,7 @@ public MultiModeDrtMainModeIdentifier(MultiModeDrtConfigGroup drtCfg) { stageActivityTypeToDrtMode = drtCfg.getModalElements() .stream() .map(DrtConfigGroup::getMode) - .collect(Collectors.toMap(PlanCalcScoreConfigGroup::createStageActivityType, s -> s)); + .collect(Collectors.toMap(ScoringConfigGroup::createStageActivityType, s -> s)); // #deleteBeforeRelease : only used to retrofit plans created since the merge of fallback routing module (sep'-dec'19) fallbackModeToDrtMode = drtCfg.getModalElements() diff --git a/contribs/drt/src/main/java/org/matsim/contrib/drt/run/DrtConfigGroup.java b/contribs/drt/src/main/java/org/matsim/contrib/drt/run/DrtConfigGroup.java index 5ef3e7adadd..5b54e43eb45 100644 --- a/contribs/drt/src/main/java/org/matsim/contrib/drt/run/DrtConfigGroup.java +++ b/contribs/drt/src/main/java/org/matsim/contrib/drt/run/DrtConfigGroup.java @@ -43,8 +43,8 @@ import org.matsim.contrib.dvrp.run.Modal; import org.matsim.contrib.util.ReflectiveConfigGroupWithConfigurableParameterSets; import org.matsim.core.config.Config; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; -import org.matsim.core.config.groups.PlansCalcRouteConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; +import org.matsim.core.config.groups.RoutingConfigGroup; import com.google.common.base.Preconditions; import com.google.common.base.Verify; @@ -325,7 +325,7 @@ public Optional getDrtRequestInsertionRetryParam } /** - * Convenience method that brings syntax closer to syntax in, e.g., {@link PlansCalcRouteConfigGroup} or {@link PlanCalcScoreConfigGroup} + * Convenience method that brings syntax closer to syntax in, e.g., {@link RoutingConfigGroup} or {@link ScoringConfigGroup} */ public final void addDrtInsertionSearchParams(final DrtInsertionSearchParams pars) { addParameterSet(pars); diff --git a/contribs/drt/src/main/java/org/matsim/contrib/drt/run/DrtConfigs.java b/contribs/drt/src/main/java/org/matsim/contrib/drt/run/DrtConfigs.java index 92d29a97d42..dccfb2d7449 100644 --- a/contribs/drt/src/main/java/org/matsim/contrib/drt/run/DrtConfigs.java +++ b/contribs/drt/src/main/java/org/matsim/contrib/drt/run/DrtConfigs.java @@ -22,8 +22,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; -import org.matsim.core.config.groups.PlansCalcRouteConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; +import org.matsim.core.config.groups.RoutingConfigGroup; /** * @author Michal Maciejewski (michalm) @@ -32,22 +32,22 @@ public class DrtConfigs { private static final Logger LOGGER = LogManager.getLogger(DrtControlerCreator.class); public static void adjustMultiModeDrtConfig(MultiModeDrtConfigGroup multiModeDrtCfg, - PlanCalcScoreConfigGroup planCalcScoreCfg, PlansCalcRouteConfigGroup plansCalcRouteCfg) { + ScoringConfigGroup planCalcScoreCfg, RoutingConfigGroup plansCalcRouteCfg) { for (DrtConfigGroup drtCfg : multiModeDrtCfg.getModalElements()) { DrtConfigs.adjustDrtConfig(drtCfg, planCalcScoreCfg, plansCalcRouteCfg); } } - public static void adjustDrtConfig(DrtConfigGroup drtCfg, PlanCalcScoreConfigGroup planCalcScoreCfg, - PlansCalcRouteConfigGroup plansCalcRouteCfg) { - String drtStageActivityType = PlanCalcScoreConfigGroup.createStageActivityType(drtCfg.getMode()); + public static void adjustDrtConfig(DrtConfigGroup drtCfg, ScoringConfigGroup planCalcScoreCfg, + RoutingConfigGroup plansCalcRouteCfg) { + String drtStageActivityType = ScoringConfigGroup.createStageActivityType(drtCfg.getMode()); if (planCalcScoreCfg.getActivityParams(drtStageActivityType) == null) { addDrtStageActivityParams(planCalcScoreCfg, drtStageActivityType); } } - private static void addDrtStageActivityParams(PlanCalcScoreConfigGroup planCalcScoreCfg, String stageActivityType) { - PlanCalcScoreConfigGroup.ActivityParams params = new PlanCalcScoreConfigGroup.ActivityParams(stageActivityType); + private static void addDrtStageActivityParams(ScoringConfigGroup planCalcScoreCfg, String stageActivityType) { + ScoringConfigGroup.ActivityParams params = new ScoringConfigGroup.ActivityParams(stageActivityType); params.setTypicalDuration(1); params.setScoringThisActivityAtAll(false); planCalcScoreCfg.getScoringParametersPerSubpopulation().values().forEach(k -> k.addActivityParams(params)); diff --git a/contribs/drt/src/main/java/org/matsim/contrib/drt/speedup/DrtSpeedUp.java b/contribs/drt/src/main/java/org/matsim/contrib/drt/speedup/DrtSpeedUp.java index 13da140a338..978ddbc7417 100644 --- a/contribs/drt/src/main/java/org/matsim/contrib/drt/speedup/DrtSpeedUp.java +++ b/contribs/drt/src/main/java/org/matsim/contrib/drt/speedup/DrtSpeedUp.java @@ -34,7 +34,7 @@ import org.matsim.contrib.drt.passenger.events.DrtRequestSubmittedEvent; import org.matsim.contrib.drt.speedup.DrtSpeedUpParams.WaitingTimeUpdateDuringSpeedUp; import org.matsim.contrib.dvrp.fleet.FleetSpecification; -import org.matsim.core.config.groups.ControlerConfigGroup; +import org.matsim.core.config.groups.ControllerConfigGroup; import org.matsim.core.controler.events.IterationEndsEvent; import org.matsim.core.controler.events.IterationStartsEvent; import org.matsim.core.controler.listener.IterationEndsListener; @@ -49,7 +49,7 @@ public final class DrtSpeedUp implements IterationStartsListener, IterationEndsListener { private static final Logger log = LogManager.getLogger(DrtSpeedUp.class); - public static boolean isTeleportDrtUsers(DrtSpeedUpParams drtSpeedUpParams, ControlerConfigGroup controlerConfig, + public static boolean isTeleportDrtUsers(DrtSpeedUpParams drtSpeedUpParams, ControllerConfigGroup controlerConfig, int iteration) { int lastIteration = controlerConfig.getLastIteration(); if (iteration < drtSpeedUpParams.fractionOfIterationsSwitchOn * lastIteration @@ -63,7 +63,7 @@ public static boolean isTeleportDrtUsers(DrtSpeedUpParams drtSpeedUpParams, Cont private final String mode; private final DrtSpeedUpParams drtSpeedUpParams; - private final ControlerConfigGroup controlerConfig; + private final ControllerConfigGroup controlerConfig; private final Network network; private final FleetSpecification fleetSpecification; private final DrtEventSequenceCollector drtEventSequenceCollector; @@ -76,7 +76,7 @@ public static boolean isTeleportDrtUsers(DrtSpeedUpParams drtSpeedUpParams, Cont private double currentAvgWaitingTime; private double currentAvgInVehicleBeelineSpeed; - public DrtSpeedUp(String mode, DrtSpeedUpParams drtSpeedUpParams, ControlerConfigGroup controlerConfig, + public DrtSpeedUp(String mode, DrtSpeedUpParams drtSpeedUpParams, ControllerConfigGroup controlerConfig, Network network, FleetSpecification fleetSpecification, DrtEventSequenceCollector drtEventSequenceCollector) { this.mode = mode; diff --git a/contribs/drt/src/test/java/org/matsim/contrib/drt/routing/MultiModeDrtMainModeIdentifierTest.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/routing/MultiModeDrtMainModeIdentifierTest.java index 750f73e21d2..d9af16f9896 100644 --- a/contribs/drt/src/test/java/org/matsim/contrib/drt/routing/MultiModeDrtMainModeIdentifierTest.java +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/routing/MultiModeDrtMainModeIdentifierTest.java @@ -14,7 +14,7 @@ import org.matsim.contrib.drt.run.MultiModeDrtConfigGroup; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; import org.matsim.core.population.PopulationUtils; import org.matsim.core.router.TripRouter; @@ -43,7 +43,7 @@ public void test() { Assert.assertEquals(drtMode, mmi.identifyMainMode(testElements)); } { - String drtStageActivityType = PlanCalcScoreConfigGroup.createStageActivityType(drtMode); + String drtStageActivityType = ScoringConfigGroup.createStageActivityType(drtMode); List testElements = new ArrayList<>(); // #deleteBeforeRelease : only used to retrofit plans created since the merge of fallback routing module (sep'-dec'19) diff --git a/contribs/drt/src/test/java/org/matsim/contrib/drt/speedup/DrtSpeedUpTest.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/speedup/DrtSpeedUpTest.java index d2c002a68a9..37ec10d3eda 100644 --- a/contribs/drt/src/test/java/org/matsim/contrib/drt/speedup/DrtSpeedUpTest.java +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/speedup/DrtSpeedUpTest.java @@ -54,7 +54,7 @@ import org.matsim.contrib.dvrp.passenger.PassengerPickedUpEvent; import org.matsim.contrib.dvrp.passenger.PassengerRequestScheduledEvent; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.ControlerConfigGroup; +import org.matsim.core.config.groups.ControllerConfigGroup; import org.matsim.core.controler.events.IterationEndsEvent; import org.matsim.core.network.NetworkUtils; @@ -66,7 +66,7 @@ */ public class DrtSpeedUpTest { private final DrtSpeedUpParams drtSpeedUpParams = new DrtSpeedUpParams(); - private final ControlerConfigGroup controlerConfig = new ControlerConfigGroup(); + private final ControllerConfigGroup controlerConfig = new ControllerConfigGroup(); @Test public final void test_computeMovingAverage() { diff --git a/contribs/drt/src/test/java/org/matsim/contrib/drt/util/DrtEventsReadersTest.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/util/DrtEventsReadersTest.java index b34b5af05ad..43510e98db7 100644 --- a/contribs/drt/src/test/java/org/matsim/contrib/drt/util/DrtEventsReadersTest.java +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/util/DrtEventsReadersTest.java @@ -46,7 +46,7 @@ import org.matsim.contrib.dvrp.vrpagent.TaskStartedEvent; import org.matsim.contrib.dvrp.vrpagent.TaskStartedEventHandler; import org.matsim.core.api.experimental.events.EventsManager; -import org.matsim.core.config.groups.ControlerConfigGroup; +import org.matsim.core.config.groups.ControllerConfigGroup; import org.matsim.core.events.EventsUtils; import org.matsim.core.events.algorithms.EventWriterXML; @@ -83,7 +83,7 @@ public void testReader() { eventsManager.initProcessing(); DrtEventsReaders.createEventsReader(eventsManager) .readStream(new ByteArrayInputStream(outputStream.toByteArray()), - ControlerConfigGroup.EventsFileFormat.xml); + ControllerConfigGroup.EventsFileFormat.xml); eventsManager.finishProcessing(); assertThat(handler.handledEvents).usingRecursiveFieldByFieldElementComparator() diff --git a/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/util/DvrpEventsReadersTest.java b/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/util/DvrpEventsReadersTest.java index fec0ba99afc..6f661026552 100644 --- a/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/util/DvrpEventsReadersTest.java +++ b/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/util/DvrpEventsReadersTest.java @@ -21,7 +21,7 @@ package org.matsim.contrib.dvrp.util; import static org.assertj.core.api.Assertions.assertThat; -import static org.matsim.core.config.groups.ControlerConfigGroup.EventsFileFormat; +import static org.matsim.core.config.groups.ControllerConfigGroup.EventsFileFormat; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; diff --git a/contribs/emissions/src/main/java/org/matsim/contrib/emissions/PositionEmissionsModule.java b/contribs/emissions/src/main/java/org/matsim/contrib/emissions/PositionEmissionsModule.java index 5d9974f9c92..2752083ac30 100644 --- a/contribs/emissions/src/main/java/org/matsim/contrib/emissions/PositionEmissionsModule.java +++ b/contribs/emissions/src/main/java/org/matsim/contrib/emissions/PositionEmissionsModule.java @@ -37,7 +37,7 @@ import org.matsim.core.api.experimental.events.EventsManager; import org.matsim.api.core.v01.events.HasPersonId; import org.matsim.core.config.Config; -import org.matsim.core.config.groups.ControlerConfigGroup; +import org.matsim.core.config.groups.ControllerConfigGroup; import org.matsim.core.config.groups.QSimConfigGroup; import org.matsim.core.controler.AbstractModule; import org.matsim.core.events.MatsimEventsReader; @@ -68,7 +68,7 @@ private static void checkConsistency(Config config) { if (config.qsim().getSnapshotPeriod() > 1) { throw new RuntimeException("only snapshot periods of 1s are supported."); } - if (!config.controler().getSnapshotFormat().contains(ControlerConfigGroup.SnapshotFormat.positionevents)) { + if (!config.controler().getSnapshotFormat().contains(ControllerConfigGroup.SnapshotFormat.positionevents)) { throw new RuntimeException("config.controler.snapshotFormat must be set to 'positionevents'"); } if (isNotCorrectSnapshotStyle(config.qsim().getSnapshotStyle())) { diff --git a/contribs/emissions/src/main/java/org/matsim/contrib/emissions/example/CreateEmissionConfig.java b/contribs/emissions/src/main/java/org/matsim/contrib/emissions/example/CreateEmissionConfig.java index 74f24e7321c..bb4e8350d53 100644 --- a/contribs/emissions/src/main/java/org/matsim/contrib/emissions/example/CreateEmissionConfig.java +++ b/contribs/emissions/src/main/java/org/matsim/contrib/emissions/example/CreateEmissionConfig.java @@ -23,19 +23,19 @@ import org.matsim.core.config.Config; import org.matsim.core.config.ConfigWriter; import org.matsim.core.config.groups.*; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup.ActivityParams; -import org.matsim.core.config.groups.StrategyConfigGroup.StrategySettings; +import org.matsim.core.config.groups.ScoringConfigGroup.ActivityParams; +import org.matsim.core.config.groups.ReplanningConfigGroup.StrategySettings; import org.matsim.core.controler.Controler; import org.matsim.core.controler.MatsimServices; /** - * - * Creates a config file + * + * Creates a config file * with necessary emission input files for the {@link EmissionsConfigGroup EmissionsConfigGroup}. - * + * * This config file is used by the {@link RunDetailedEmissionToolOfflineExample OfflineExample} and * the {@link RunDetailedEmissionToolOnlineExample OnlineExample} - * + * * @author benjamin, julia * * @deprecated -- has not been maintained and should in consequence be phased out. kai, nov'21 @@ -45,47 +45,47 @@ public final class CreateEmissionConfig { private static final String inputPath = "./test/input/org/matsim/contrib/emissions/"; - private static final String networkFile = //inputPath + + private static final String networkFile = //inputPath + "sample_network.xml"; - private static final String plansFile = //inputPath + + private static final String plansFile = //inputPath + "sample_population.xml"; - private static final String emissionVehicleFile = //inputPath + + private static final String emissionVehicleFile = //inputPath + "sample_emissionVehicles.xml"; - + private static final String roadTypeMappingFile = //inputPath + "sample_roadTypeMapping.txt"; - + private static final String averageFleetWarmEmissionFactorsFile = //inputPath + "sample_EFA_HOT_vehcat_2005average.txt"; private static final String averageFleetColdEmissionFactorsFile = //inputPath + "sample_EFA_ColdStart_vehcat_2005average.txt"; - + private static final boolean isUsingDetailedEmissionCalculation = true; private static final String detailedWarmEmissionFactorsFile = //inputPath + "sample_EFA_HOT_SubSegm_2005detailed.txt"; private static final String detailedColdEmissionFactorsFile = //inputPath + "sample_EFA_ColdStart_SubSegm_2005detailed.txt"; - + private static final String outputPath = "./test/output/"; private static final String configFilePath = inputPath + "config_v2.xml"; - + private static final int numberOfIterations = 6; - - + + public static void main(String[] args) { - + Config config = new Config(); config.addCoreModules(); MatsimServices controler = new Controler(config); - + // controlerConfigGroup - ControlerConfigGroup ccg = controler.getConfig().controler(); + ControllerConfigGroup ccg = controler.getConfig().controler(); ccg.setOutputDirectory(outputPath); ccg.setFirstIteration(0); ccg.setLastIteration(numberOfIterations-1); - + // planCalcScoreConfigGroup - PlanCalcScoreConfigGroup pcs = controler.getConfig().planCalcScore(); + ScoringConfigGroup pcs = controler.getConfig().planCalcScore(); ActivityParams homeP = new ActivityParams("home"); homeP.setTypicalDuration(12 * 3600); pcs.addActivityParams(homeP); @@ -94,21 +94,21 @@ public static void main(String[] args) { pcs.addActivityParams(workP); // strategy - StrategyConfigGroup scg = controler.getConfig().strategy(); + ReplanningConfigGroup scg = controler.getConfig().strategy(); StrategySettings strategySettings = new StrategySettings(); strategySettings.setStrategyName("ChangeExpBeta"); strategySettings.setWeight(1.0); scg.addStrategySettings(strategySettings); - + // network NetworkConfigGroup ncg = controler.getConfig().network(); ncg.setInputFile(networkFile); - + // plans PlansConfigGroup pcg = controler.getConfig().plans(); pcg.setInputFile(plansFile); - - // define emission tool input files + + // define emission tool input files EmissionsConfigGroup ecg = new EmissionsConfigGroup() ; controler.getConfig().addModule(ecg); @@ -137,11 +137,11 @@ public static void main(String[] args) { // ecg.setEmissionCostMultiplicationFactor(1.0); // ecg.setConsideringCO2Costs(true); // ecg.setEmissionEfficiencyFactor(1.0); - - // write config + + // write config ConfigWriter cw = new ConfigWriter(config); cw.write(configFilePath); - + } diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestPositionEmissionModule.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestPositionEmissionModule.java index 73ee5c208b5..f67e40f93d9 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestPositionEmissionModule.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestPositionEmissionModule.java @@ -18,17 +18,16 @@ import org.matsim.contrib.emissions.utils.EmissionsConfigGroup; import org.matsim.core.api.experimental.events.EventsManager; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.ControlerConfigGroup; +import org.matsim.core.config.groups.ControllerConfigGroup; import org.matsim.core.config.groups.NetworkConfigGroup; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; +import org.matsim.core.config.groups.ReplanningConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; import org.matsim.core.config.groups.QSimConfigGroup; -import org.matsim.core.config.groups.StrategyConfigGroup; import org.matsim.core.controler.AbstractModule; import org.matsim.core.controler.Controler; import org.matsim.core.controler.OutputDirectoryHierarchy; import org.matsim.core.events.EventsManagerImpl; import org.matsim.core.events.handler.BasicEventHandler; -import org.matsim.core.events.handler.EventHandler; import org.matsim.core.network.NetworkUtils; import org.matsim.core.population.PopulationUtils; import org.matsim.core.population.routes.RouteUtils; @@ -36,7 +35,6 @@ import org.matsim.core.scenario.ScenarioUtils; import org.matsim.core.utils.io.IOUtils; import org.matsim.examples.ExamplesUtils; -import org.matsim.facilities.filters.Filter; import org.matsim.testcases.MatsimTestUtils; import org.matsim.vehicles.EngineInformation; import org.matsim.vehicles.Vehicle; @@ -73,7 +71,7 @@ public void simpleTest() { config.qsim().setSnapshotPeriod(1); config.qsim().setSnapshotStyle(QSimConfigGroup.SnapshotStyle.queue); config.controler().setWriteSnapshotsInterval(1); - config.controler().setSnapshotFormat(Set.of(ControlerConfigGroup.SnapshotFormat.positionevents)); + config.controler().setSnapshotFormat(Set.of(ControllerConfigGroup.SnapshotFormat.positionevents)); var scenario = ScenarioUtils.loadScenario(config); @@ -98,14 +96,14 @@ public void compareToOtherModule_singleVehicleSingleLink() { emissionConfig.setAverageWarmEmissionFactorsFile( "../sample_41_EFA_HOT_vehcat_2020average.csv" ); emissionConfig.setHbefaTableConsistencyCheckingLevel( EmissionsConfigGroup.HbefaTableConsistencyCheckingLevel.consistent ); - final PlanCalcScoreConfigGroup.ActivityParams homeParams = new PlanCalcScoreConfigGroup.ActivityParams("home") + final ScoringConfigGroup.ActivityParams homeParams = new ScoringConfigGroup.ActivityParams("home") .setTypicalDuration(20); config.planCalcScore().addActivityParams(homeParams); - final PlanCalcScoreConfigGroup.ActivityParams workParams = new PlanCalcScoreConfigGroup.ActivityParams("work") + final ScoringConfigGroup.ActivityParams workParams = new ScoringConfigGroup.ActivityParams("work") .setTypicalDuration(20); config.planCalcScore().addActivityParams(workParams); - var strategy = new StrategyConfigGroup.StrategySettings(); + var strategy = new ReplanningConfigGroup.StrategySettings(); strategy.setStrategyName("ChangeExpBeta"); strategy.setWeight(1.0); @@ -115,7 +113,7 @@ public void compareToOtherModule_singleVehicleSingleLink() { config.qsim().setSnapshotPeriod(1); config.qsim().setSnapshotStyle(QSimConfigGroup.SnapshotStyle.queue); config.controler().setWriteSnapshotsInterval(1); - config.controler().setSnapshotFormat(Set.of(ControlerConfigGroup.SnapshotFormat.positionevents)); + config.controler().setSnapshotFormat(Set.of(ControllerConfigGroup.SnapshotFormat.positionevents)); config.controler().setFirstIteration(0); config.controler().setLastIteration(0); diff --git a/contribs/ev/src/main/java/org/matsim/contrib/ev/charging/VehicleChargingHandler.java b/contribs/ev/src/main/java/org/matsim/contrib/ev/charging/VehicleChargingHandler.java index d450afb6d24..81f6682c3ff 100644 --- a/contribs/ev/src/main/java/org/matsim/contrib/ev/charging/VehicleChargingHandler.java +++ b/contribs/ev/src/main/java/org/matsim/contrib/ev/charging/VehicleChargingHandler.java @@ -43,7 +43,7 @@ import org.matsim.contrib.ev.infrastructure.Charger; import org.matsim.contrib.ev.infrastructure.ChargingInfrastructure; import org.matsim.contrib.ev.infrastructure.ChargingInfrastructures; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; import org.matsim.core.events.MobsimScopeEventHandler; import org.matsim.vehicles.Vehicle; @@ -60,7 +60,7 @@ public class VehicleChargingHandler ChargingEndEventHandler, MobsimScopeEventHandler { public static final String CHARGING_IDENTIFIER = " charging"; - public static final String CHARGING_INTERACTION = PlanCalcScoreConfigGroup.createStageActivityType( + public static final String CHARGING_INTERACTION = ScoringConfigGroup.createStageActivityType( CHARGING_IDENTIFIER); private final Map, Id> lastVehicleUsed = new HashMap<>(); private final Map, Id> vehiclesAtChargers = new HashMap<>(); diff --git a/contribs/ev/src/main/java/org/matsim/contrib/ev/routing/EvNetworkRoutingProvider.java b/contribs/ev/src/main/java/org/matsim/contrib/ev/routing/EvNetworkRoutingProvider.java index d183fd702fd..bb424097ef5 100644 --- a/contribs/ev/src/main/java/org/matsim/contrib/ev/routing/EvNetworkRoutingProvider.java +++ b/contribs/ev/src/main/java/org/matsim/contrib/ev/routing/EvNetworkRoutingProvider.java @@ -14,8 +14,8 @@ import org.matsim.contrib.ev.fleet.ElectricFleetSpecification; import org.matsim.contrib.ev.infrastructure.ChargingInfrastructureSpecification; import org.matsim.core.config.Config; -import org.matsim.core.config.groups.PlansCalcRouteConfigGroup; -import org.matsim.core.config.groups.PlansCalcRouteConfigGroup.AccessEgressType; +import org.matsim.core.config.groups.RoutingConfigGroup; +import org.matsim.core.config.groups.RoutingConfigGroup.AccessEgressType; import org.matsim.core.network.NetworkUtils; import org.matsim.core.network.algorithms.TransportModeNetworkFilter; import org.matsim.core.router.DefaultRoutingModules; @@ -46,7 +46,7 @@ public class EvNetworkRoutingProvider implements Provider { private Config config; @Inject - private PlansCalcRouteConfigGroup plansCalcRouteConfigGroup; + private RoutingConfigGroup routingConfigGroup; @Inject private Network network; @@ -129,7 +129,7 @@ public RoutingModule get() { travelDisutilityFactory.createTravelDisutility(travelTime), travelTime); // the following again refers to the (transport)mode, since it will determine the mode of the leg on the network: - if (!plansCalcRouteConfigGroup.getAccessEgressType().equals(AccessEgressType.none)) { + if (!routingConfigGroup.getAccessEgressType().equals(AccessEgressType.none)) { throw new IllegalArgumentException("Bushwacking is not currently supported by the EV routing module"); } else { return new EvNetworkRoutingModule(mode, filteredNetwork, diff --git a/contribs/freight/src/main/java/org/matsim/contrib/freight/usecases/chessboard/RunPassengerPlansFromScratch.java b/contribs/freight/src/main/java/org/matsim/contrib/freight/usecases/chessboard/RunPassengerPlansFromScratch.java index 8de9c700aab..b62382737da 100644 --- a/contribs/freight/src/main/java/org/matsim/contrib/freight/usecases/chessboard/RunPassengerPlansFromScratch.java +++ b/contribs/freight/src/main/java/org/matsim/contrib/freight/usecases/chessboard/RunPassengerPlansFromScratch.java @@ -22,8 +22,8 @@ package org.matsim.contrib.freight.usecases.chessboard; import org.matsim.core.config.Config; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup.ActivityParams; -import org.matsim.core.config.groups.StrategyConfigGroup.StrategySettings; +import org.matsim.core.config.groups.ScoringConfigGroup.ActivityParams; +import org.matsim.core.config.groups.ReplanningConfigGroup.StrategySettings; import org.matsim.core.controler.Controler; import org.matsim.core.controler.OutputDirectoryHierarchy; diff --git a/contribs/freight/src/test/java/org/matsim/contrib/freight/carrier/CarrierModuleTest.java b/contribs/freight/src/test/java/org/matsim/contrib/freight/carrier/CarrierModuleTest.java index 4a2015aa13b..8ea974fa096 100644 --- a/contribs/freight/src/test/java/org/matsim/contrib/freight/carrier/CarrierModuleTest.java +++ b/contribs/freight/src/test/java/org/matsim/contrib/freight/carrier/CarrierModuleTest.java @@ -31,7 +31,7 @@ import org.matsim.contrib.freight.controler.FreightUtils; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; import org.matsim.core.controler.AbstractModule; import org.matsim.core.controler.Controler; import org.matsim.core.controler.OutputDirectoryHierarchy; @@ -50,10 +50,10 @@ public class CarrierModuleTest { @Before public void setUp(){ Config config = ConfigUtils.createConfig() ; - PlanCalcScoreConfigGroup.ActivityParams workParams = new PlanCalcScoreConfigGroup.ActivityParams("w"); + ScoringConfigGroup.ActivityParams workParams = new ScoringConfigGroup.ActivityParams("w"); workParams.setTypicalDuration(60 * 60 * 8); config.planCalcScore().addActivityParams(workParams); - PlanCalcScoreConfigGroup.ActivityParams homeParams = new PlanCalcScoreConfigGroup.ActivityParams("h"); + ScoringConfigGroup.ActivityParams homeParams = new ScoringConfigGroup.ActivityParams("h"); homeParams.setTypicalDuration(16 * 60 * 60); config.planCalcScore().addActivityParams(homeParams); config.global().setCoordinateSystem("EPSG:32632"); diff --git a/contribs/freight/src/test/java/org/matsim/contrib/freight/controler/EquilWithCarrierWithPersonsIT.java b/contribs/freight/src/test/java/org/matsim/contrib/freight/controler/EquilWithCarrierWithPersonsIT.java index c326e650f8f..b96a6f75553 100644 --- a/contribs/freight/src/test/java/org/matsim/contrib/freight/controler/EquilWithCarrierWithPersonsIT.java +++ b/contribs/freight/src/test/java/org/matsim/contrib/freight/controler/EquilWithCarrierWithPersonsIT.java @@ -31,8 +31,8 @@ import org.matsim.contrib.freight.mobsim.StrategyManagerFactoryForTests; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup.ActivityParams; -import org.matsim.core.config.groups.StrategyConfigGroup.StrategySettings; +import org.matsim.core.config.groups.ScoringConfigGroup.ActivityParams; +import org.matsim.core.config.groups.ReplanningConfigGroup.StrategySettings; import org.matsim.core.controler.AbstractModule; import org.matsim.core.controler.Controler; import org.matsim.core.scenario.ScenarioUtils; diff --git a/contribs/freight/src/test/java/org/matsim/contrib/freight/jsprit/DistanceConstraintFromVehiclesFileTest.java b/contribs/freight/src/test/java/org/matsim/contrib/freight/jsprit/DistanceConstraintFromVehiclesFileTest.java index 64104984286..e0c70e41e09 100644 --- a/contribs/freight/src/test/java/org/matsim/contrib/freight/jsprit/DistanceConstraintFromVehiclesFileTest.java +++ b/contribs/freight/src/test/java/org/matsim/contrib/freight/jsprit/DistanceConstraintFromVehiclesFileTest.java @@ -35,7 +35,7 @@ import org.matsim.contrib.freight.controler.FreightUtils; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.ControlerConfigGroup.CompressionType; +import org.matsim.core.config.groups.ControllerConfigGroup.CompressionType; import org.matsim.core.controler.OutputDirectoryHierarchy; import org.matsim.core.controler.OutputDirectoryHierarchy.OverwriteFileSetting; import org.matsim.core.population.routes.NetworkRoute; @@ -130,7 +130,7 @@ public final void CarrierSmallBatteryTest_Version1() throws ExecutionException, MatsimTestUtils.EPSILON); Assert.assertEquals("Wrong maximum distance of the tour of this vehicleType", 30000, maxDistance_vehicleType_SmallV1, MatsimTestUtils.EPSILON); - + double distanceTour = 0.0; List elements = carrierV1.getSelectedPlan().getScheduledTours().iterator().next().getTour() .getTourElements(); @@ -185,8 +185,8 @@ public final void CarrierLargeBatteryTest_Version2() throws ExecutionException, CarrierUtils.setJspritIterations(carrierV2, 10); FreightUtils.runJsprit(scenario); - - + + Assert.assertEquals("Not the correct amout of scheduled tours", 1, carrierV2.getSelectedPlan().getScheduledTours().size()); @@ -359,7 +359,7 @@ public final void CarrierWithAdditionalDieselVehicleTest_Version4() throws Execu Assert.assertEquals("Wrong maximum distance of the tour of this vehicleType", 30000, maxDistance_vehicleType_SmallV4, MatsimTestUtils.EPSILON); - + for (ScheduledTour scheduledTour : carrierV4.getSelectedPlan().getScheduledTours()) { String thisTypeId = scheduledTour.getVehicle().getType().getId().toString(); diff --git a/contribs/freight/src/test/java/org/matsim/contrib/freight/jsprit/DistanceConstraintTest.java b/contribs/freight/src/test/java/org/matsim/contrib/freight/jsprit/DistanceConstraintTest.java index fce789621f8..1ca39718e22 100644 --- a/contribs/freight/src/test/java/org/matsim/contrib/freight/jsprit/DistanceConstraintTest.java +++ b/contribs/freight/src/test/java/org/matsim/contrib/freight/jsprit/DistanceConstraintTest.java @@ -35,7 +35,7 @@ import org.matsim.contrib.freight.controler.FreightUtils; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.ControlerConfigGroup.CompressionType; +import org.matsim.core.config.groups.ControllerConfigGroup.CompressionType; import org.matsim.core.controler.OutputDirectoryHierarchy; import org.matsim.core.controler.OutputDirectoryHierarchy.OverwriteFileSetting; import org.matsim.core.population.routes.NetworkRoute; @@ -102,7 +102,7 @@ public final void CarrierSmallBatteryTest_Version1() throws ExecutionException, VehicleUtils.setEnergyConsumptionKWhPerMeter(vehicleType_LargeV1.getEngineInformation(), 0.015); vehicleType_LargeV1.getCapacity().setOther(80.); vehicleType_LargeV1.setDescription("Carrier_Version1"); - + VehicleType vehicleType_SmallV1 = VehicleUtils.createVehicleType(Id.create("SmallBattery_V1", VehicleType.class)); vehicleType_SmallV1.getCostInformation().setCostsPerMeter(0.00055).setCostsPerSecond(0.008).setFixedCost(70.); VehicleUtils.setHbefaTechnology(vehicleType_SmallV1.getEngineInformation(), "electricity"); @@ -137,7 +137,7 @@ public final void CarrierSmallBatteryTest_Version1() throws ExecutionException, MatsimTestUtils.EPSILON); Assert.assertEquals("Wrong maximum distance of the tour of this vehicleType", 30000, maxDistance_vehicleType_SmallV1, MatsimTestUtils.EPSILON); - + double distanceTour = 0.0; List elements = carrierV1.getSelectedPlan().getScheduledTours().iterator().next().getTour() .getTourElements(); @@ -181,7 +181,7 @@ public final void CarrierLargeBatteryTest_Version2() throws ExecutionException, VehicleUtils.setEnergyConsumptionKWhPerMeter(vehicleType_LargeV2.getEngineInformation(), 0.015); vehicleType_LargeV2.setDescription("Carrier_Version2"); vehicleType_LargeV2.getCapacity().setOther(80.); - + VehicleType vehicleType_SmallV2 = VehicleUtils.createVehicleType(Id.create("SmallBattery_V2", VehicleType.class)); vehicleType_SmallV2.getCostInformation().setCostsPerMeter(0.00055).setCostsPerSecond(0.008).setFixedCost(70.); VehicleUtils.setHbefaTechnology(vehicleType_SmallV2.getEngineInformation(), "electricity"); @@ -201,8 +201,8 @@ public final void CarrierLargeBatteryTest_Version2() throws ExecutionException, CarrierUtils.setJspritIterations(carrierV2, 10); FreightUtils.runJsprit(scenario); - - + + Assert.assertEquals("Not the correct amout of scheduled tours", 1, carrierV2.getSelectedPlan().getScheduledTours().size()); @@ -262,7 +262,7 @@ public final void Carrier2SmallBatteryTest_Version3() throws ExecutionException, VehicleUtils.setEnergyConsumptionKWhPerMeter(vehicleType_LargeV3.getEngineInformation(), 0.015); vehicleType_LargeV3.setDescription("Carrier_Version3"); vehicleType_LargeV3.getCapacity().setOther(80.); - + VehicleType vehicleType_SmallV3 = VehicleUtils.createVehicleType(Id.create("SmallBattery_V3", VehicleType.class)); vehicleType_SmallV3.getCostInformation().setCostsPerMeter(0.00055).setCostsPerSecond(0.008).setFixedCost(40.); VehicleUtils.setHbefaTechnology(vehicleType_SmallV3.getEngineInformation(), "electricity"); @@ -352,15 +352,15 @@ public final void CarrierWithAdditionalDieselVehicleTest_Version4() throws Execu VehicleUtils.setEnergyConsumptionKWhPerMeter(vehicleType_LargeV4.getEngineInformation(), 0.015); vehicleType_LargeV4.setDescription("Carrier_Version4"); vehicleType_LargeV4.getCapacity().setOther(120.); - + VehicleType vehicleType_SmallV4 = VehicleUtils.createVehicleType(Id.create("SmallBattery_V4", VehicleType.class)); vehicleType_SmallV4.getCostInformation().setCostsPerMeter(0.00055).setCostsPerSecond(0.008).setFixedCost(70.); VehicleUtils.setHbefaTechnology(vehicleType_SmallV4.getEngineInformation(), "electricity"); VehicleUtils.setEnergyCapacity(vehicleType_SmallV4.getEngineInformation(), 300.); - VehicleUtils.setEnergyConsumptionKWhPerMeter(vehicleType_SmallV4.getEngineInformation(), 0.01); + VehicleUtils.setEnergyConsumptionKWhPerMeter(vehicleType_SmallV4.getEngineInformation(), 0.01); vehicleType_SmallV4.setDescription("Carrier_Version4"); vehicleType_SmallV4.getCapacity().setOther(120.); - + VehicleType vehicleType_Diesel = VehicleUtils.createVehicleType(Id.create("DieselVehicle", VehicleType.class)); vehicleType_Diesel.getCostInformation().setCostsPerMeter(0.00055).setCostsPerSecond(0.008).setFixedCost(400.); VehicleUtils.setHbefaTechnology(vehicleType_Diesel.getEngineInformation(), "diesel"); @@ -394,7 +394,7 @@ public final void CarrierWithAdditionalDieselVehicleTest_Version4() throws Execu Assert.assertEquals("Wrong maximum distance of the tour of this vehicleType", 30000, maxDistance_vehicleType_SmallV4, MatsimTestUtils.EPSILON); - + for (ScheduledTour scheduledTour : carrierV4.getSelectedPlan().getScheduledTours()) { String thisTypeId = scheduledTour.getVehicle().getType().getId().toString(); diff --git a/contribs/hybridsim/src/main/java/org/matsim/contrib/hybridsim/run/RunExample.java b/contribs/hybridsim/src/main/java/org/matsim/contrib/hybridsim/run/RunExample.java index ebab0cd810f..119dd040d69 100644 --- a/contribs/hybridsim/src/main/java/org/matsim/contrib/hybridsim/run/RunExample.java +++ b/contribs/hybridsim/src/main/java/org/matsim/contrib/hybridsim/run/RunExample.java @@ -23,7 +23,6 @@ import java.util.HashSet; import java.util.Set; -import org.apache.logging.log4j.Level; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Id; @@ -44,7 +43,7 @@ import org.matsim.core.api.experimental.events.EventsManager; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; import org.matsim.core.controler.AbstractModule; import org.matsim.core.controler.Controler; import org.matsim.core.controler.OutputDirectoryHierarchy; @@ -328,7 +327,7 @@ private static void createHybridsimScenario(Scenario sc) { } private static void enrichConfig(Config c) { - PlanCalcScoreConfigGroup.ActivityParams pre = new PlanCalcScoreConfigGroup.ActivityParams("origin"); + ScoringConfigGroup.ActivityParams pre = new ScoringConfigGroup.ActivityParams("origin"); pre.setTypicalDuration(49); // needs to be geq 49, otherwise when // running a simulation one gets // "java.lang.RuntimeException: zeroUtilityDuration of type pre-evac must be greater than 0.0. Did you forget to specify the typicalDuration?" @@ -340,7 +339,7 @@ private static void enrichConfig(Config c) { pre.setLatestStartTime(49); pre.setOpeningTime(49); - PlanCalcScoreConfigGroup.ActivityParams post = new PlanCalcScoreConfigGroup.ActivityParams("destination"); + ScoringConfigGroup.ActivityParams post = new ScoringConfigGroup.ActivityParams("destination"); post.setTypicalDuration(49); // dito post.setMinimalDuration(49); post.setClosingTime(49); diff --git a/contribs/informed-mode-choice/src/main/java/org/matsim/modechoice/commands/StrategyOptions.java b/contribs/informed-mode-choice/src/main/java/org/matsim/modechoice/commands/StrategyOptions.java index 12655fd73f8..038c1421efc 100644 --- a/contribs/informed-mode-choice/src/main/java/org/matsim/modechoice/commands/StrategyOptions.java +++ b/contribs/informed-mode-choice/src/main/java/org/matsim/modechoice/commands/StrategyOptions.java @@ -9,7 +9,7 @@ import org.matsim.api.core.v01.population.Plan; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.StrategyConfigGroup; +import org.matsim.core.config.groups.ReplanningConfigGroup; import org.matsim.core.replanning.choosers.ForceInnovationStrategyChooser; import org.matsim.core.replanning.choosers.StrategyChooser; import org.matsim.core.replanning.strategies.DefaultPlanStrategiesModule; @@ -128,13 +128,13 @@ public Module applyModule(Binder binder, Config config, Consumer strategies = config.strategy().getStrategySettings().stream() + List strategies = config.strategy().getStrategySettings().stream() .filter(s -> !filtered.contains(s.getStrategyName()) || !Objects.equals(s.getSubpopulation(), defaultSubpopulation)) .collect(Collectors.toList()); //add time mutation - strategies.add(new StrategyConfigGroup.StrategySettings() + strategies.add(new ReplanningConfigGroup.StrategySettings() .setStrategyName(DefaultPlanStrategiesModule.DefaultStrategy.TimeAllocationMutator) .setSubpopulation(defaultSubpopulation) .setWeight(group.timeMutation) @@ -142,7 +142,7 @@ public Module applyModule(Binder binder, Config config, Consumer> quadTreesOfType = new HashMap>(); private TreeMap facilitiesOfType = new TreeMap(); - + public DestinationChoiceContext(Scenario scenario) { - this.scenario = scenario; + this.scenario = scenario; log.info("dc context created but not yet initialized"); this.init(); // actually wanted to leave this away to be able to create but not yet fill the context. @@ -108,7 +108,7 @@ public DestinationChoiceContext(Scenario scenario) { } - + public void init() { if ( params==null ){ this.params = new ScoringParameters.Builder( scenario.getConfig().planCalcScore(), scenario.getConfig().planCalcScore().getScoringParameters( null ), @@ -126,7 +126,7 @@ public void init() { log.info( "dc context initialized" ); } } - + private void readOrCreateKVals(long seed) { ReadOrCreateKVals computer = new ReadOrCreateKVals(seed, this.scenario); this.arekValsRead = computer.run(); @@ -138,27 +138,27 @@ private void readOrCreateKVals(long seed) { this.personIndices.put(personId, personIndex); this.personsKValuesArray[personIndex] = (Double) scenario.getPopulation().getPersons().get(personId).getAttributes().getAttribute("k"); personIndex++; - } - + } + this.facilityIndices = new TObjectIntHashMap<>(); this.faciliesWithIndexMap = new HashMap<>(); this.facilitiesKValuesArray = new double[this.scenario.getActivityFacilities().getFacilities().size()]; int facilityIndex = 0; for (ActivityFacility facility : this.scenario.getActivityFacilities().getFacilities().values()) { Id facilityId = facility.getId(); - + this.facilityIndices.put(facilityId, facilityIndex); this.facilitiesKValuesArray[facilityIndex] = (Double) facility.getAttributes().getAttribute("k"); this.faciliesWithIndexMap.put(facilityId, new ActivityFacilityWithIndex(facility, facilityIndex)); - + facilityIndex++; } } - + private void readFacilitesAttributesAndBetas() { String pBetasFileName = this.dccg.getpBetasFile(); String fAttributesFileName = this.dccg.getfAttributesFile(); - if (pBetasFileName != null && fAttributesFileName!= null) { + if (pBetasFileName != null && fAttributesFileName!= null) { ObjectAttributesXmlReader personsBetasReader = new ObjectAttributesXmlReader(this.personsBetas); ObjectAttributesXmlReader facilitiesAttributesReader = new ObjectAttributesXmlReader(this.facilitiesAttributes); try { @@ -171,10 +171,10 @@ private void readFacilitesAttributesAndBetas() { } } } - + private void readPrefs() { String prefsFileName = this.dccg.getPrefsFile(); - if (prefsFileName != null) { + if (prefsFileName != null) { ObjectAttributesXmlReader prefsReader = new ObjectAttributesXmlReader(this.prefsAttributes); try { prefsReader.readFile(prefsFileName); @@ -185,7 +185,7 @@ private void readPrefs() { } } else { log.warn("prefs are taken from the config and if available from the desires as there is no preferences file specified \n"); - for (ActivityParams activityParams : this.scenario.getConfig().planCalcScore().getActivityParams()) { + for (ActivityParams activityParams : this.scenario.getConfig().planCalcScore().getActivityParams()) { for (Person p : this.scenario.getPopulation().getPersons().values()) { prefsAttributes.putAttribute(p.getId().toString(), "typicalDuration_" + activityParams.getActivityType(), activityParams.getTypicalDuration()); @@ -199,7 +199,7 @@ private void readPrefs() { } } } - + // public boolean cacheQuadTrees() { // return this.cacheQuadTrees; // } @@ -211,7 +211,7 @@ private void readPrefs() { // this.facilitiesOfType.clear(); // } // } - + Tuple, ActivityFacilityImpl[]> getQuadTreeAndFacilities( String activityType ) { /** * If this is set to true, QuadTrees are stored in memory. @@ -235,22 +235,22 @@ Tuple, ActivityFacilityImpl[]> getQuadTreeAn } else return new Tuple<>( quadTree, facilities ); } else return getTuple(activityType); } - + private Tuple, ActivityFacilityImpl[]> getTuple(String activityType) { TreesBuilder treesBuilder = new TreesBuilder(CollectionUtils.stringToSet(activityType), this.scenario.getNetwork(), this.dccg); // treesBuilder.setActTypeConverter(this.getConverter()); treesBuilder.createTrees(scenario.getActivityFacilities()); - + ActivityFacilityImpl[] facilities = treesBuilder.getFacilitiesOfType().get(activityType); - + /* * Create a copy of the treesBuilder.getQuadTreesOfType() outcome where the * ActivityFacility objects are replaced by ActivityFacilityWithIndex objects. * TODO: let the TreeBuilder use ActivityFacilityWithIndex objects directly? */ QuadTree quadTree = null; - + QuadTree qt = treesBuilder.getQuadTreesOfType().get(activityType); if (qt != null) { double minX = qt.getMinEasting(); @@ -260,12 +260,12 @@ private Tuple, ActivityFacilityImpl[]> getTu quadTree = new QuadTree(minX, minY, maxX, maxY); for (ActivityFacility activityFacility : qt.values()) { quadTree.put(activityFacility.getCoord().getX(), activityFacility.getCoord().getY(), this.faciliesWithIndexMap.get(activityFacility.getId())); - } + } } - + return new Tuple, ActivityFacilityImpl[]>(quadTree, facilities); } - + public Scenario getScenario() { return scenario; } @@ -293,7 +293,7 @@ private boolean kValsAreRead() { // public ObjectAttributes getPersonsKValues() { // return personsKValues; // } - + // public ObjectAttributes getFacilitiesKValues() { // return facilitiesKValues; // } @@ -301,7 +301,7 @@ private boolean kValsAreRead() { public double[] getPersonsKValuesArray() { return personsKValuesArray; } - + public double[] getFacilitiesKValuesArray() { return facilitiesKValuesArray; } @@ -309,19 +309,19 @@ public double[] getFacilitiesKValuesArray() { // public Map, Integer> getPersonIndices() { // return Collections.unmodifiableMap(this.personIndices); // } - + public int getPersonIndex(Id id) { return this.personIndices.get(id); } - + // public Map, Integer> getFacilityIndices() { // return Collections.unmodifiableMap(this.facilityIndices); // } - + public int getFacilityIndex(Id id) { return this.facilityIndices.get(id); } - + ObjectAttributes getPersonsBetas() { return personsBetas; } @@ -342,17 +342,17 @@ ObjectAttributes getPrefsAttributes() { public TreeMap getFacilityPenalties() { return facilityPenalties; } - + public static final class ActivityFacilityWithIndex implements ActivityFacility, HasIndex { private final ActivityFacility activityFacility; private final int index; - + ActivityFacilityWithIndex( ActivityFacility activityFacility, int index ) { this.activityFacility = activityFacility; this.index = index; } - + @Override public Id getLinkId() { return this.activityFacility.getLinkId(); diff --git a/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/LocationChoiceIT.java b/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/LocationChoiceIT.java index a7841c8799f..36f9d1731b0 100644 --- a/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/LocationChoiceIT.java +++ b/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/LocationChoiceIT.java @@ -44,10 +44,10 @@ import org.matsim.core.api.experimental.events.EventsManager; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup.ActivityParams; -import org.matsim.core.config.groups.PlansCalcRouteConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup.ActivityParams; +import org.matsim.core.config.groups.RoutingConfigGroup; import org.matsim.core.config.groups.QSimConfigGroup; -import org.matsim.core.config.groups.StrategyConfigGroup.StrategySettings; +import org.matsim.core.config.groups.ReplanningConfigGroup.StrategySettings; import org.matsim.core.controler.AbstractModule; import org.matsim.core.controler.Controler; import org.matsim.core.controler.OutputDirectoryHierarchy; @@ -137,7 +137,7 @@ public PlanStrategy get() { assertEquals("number of plans in person.", 2, person.getPlans().size()); Plan newPlan = person.getSelectedPlan(); Activity newWork = (Activity) newPlan.getPlanElements().get(2); - if (!config.plansCalcRoute().getAccessEgressType().equals(PlansCalcRouteConfigGroup.AccessEgressType.none) ) { + if (!config.plansCalcRoute().getAccessEgressType().equals(RoutingConfigGroup.AccessEgressType.none) ) { newWork = (Activity) newPlan.getPlanElements().get(6); } assertNotNull( newWork ) ; diff --git a/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/frozenepsilons/FrozenEpsilonLocaChoiceIT.java b/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/frozenepsilons/FrozenEpsilonLocaChoiceIT.java index 92ccc17d567..d3674fa6302 100644 --- a/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/frozenepsilons/FrozenEpsilonLocaChoiceIT.java +++ b/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/frozenepsilons/FrozenEpsilonLocaChoiceIT.java @@ -5,7 +5,7 @@ import static org.matsim.contrib.locationchoice.frozenepsilons.FrozenTastesConfigGroup.Algotype; import static org.matsim.contrib.locationchoice.frozenepsilons.FrozenTastesConfigGroup.Algotype.bestResponse; import static org.matsim.contrib.locationchoice.frozenepsilons.FrozenTastesConfigGroup.ApproximationLevel; -import static org.matsim.core.config.groups.StrategyConfigGroup.StrategySettings; +import static org.matsim.core.config.groups.ReplanningConfigGroup.StrategySettings; import java.util.HashSet; import java.util.List; @@ -33,8 +33,8 @@ import org.matsim.contrib.analysis.kai.KaiAnalysisListener; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup.ActivityParams; -import org.matsim.core.config.groups.PlansCalcRouteConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup.ActivityParams; +import org.matsim.core.config.groups.RoutingConfigGroup; import org.matsim.core.config.groups.QSimConfigGroup; import org.matsim.core.controler.AbstractModule; import org.matsim.core.controler.Controler; @@ -157,7 +157,7 @@ public void install() { Plan newPlan = person.getSelectedPlan(); System.err.println( " newPlan: " + newPlan ) ; Activity newWork = (Activity) newPlan.getPlanElements().get(2 ); - if ( !config.plansCalcRoute().getAccessEgressType().equals(PlansCalcRouteConfigGroup.AccessEgressType.none) ) { + if ( !config.plansCalcRoute().getAccessEgressType().equals(RoutingConfigGroup.AccessEgressType.none) ) { newWork = (Activity) newPlan.getPlanElements().get(6); } System.err.println( " newWork: " + newWork ) ; diff --git a/contribs/matrixbasedptrouter/src/main/java/org/matsim/contrib/matrixbasedptrouter/MatrixBasedPtModule.java b/contribs/matrixbasedptrouter/src/main/java/org/matsim/contrib/matrixbasedptrouter/MatrixBasedPtModule.java index 41366c39562..a4cedbff4cc 100644 --- a/contribs/matrixbasedptrouter/src/main/java/org/matsim/contrib/matrixbasedptrouter/MatrixBasedPtModule.java +++ b/contribs/matrixbasedptrouter/src/main/java/org/matsim/contrib/matrixbasedptrouter/MatrixBasedPtModule.java @@ -3,7 +3,7 @@ import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Network; import org.matsim.contrib.matrixbasedptrouter.utils.BoundingBox; -import org.matsim.core.config.groups.PlansCalcRouteConfigGroup; +import org.matsim.core.config.groups.RoutingConfigGroup; import org.matsim.core.controler.AbstractModule; import com.google.inject.Provides; @@ -18,9 +18,9 @@ public void install() { } addRoutingModuleBinding(TransportMode.pt).to(MatrixBasedPtRoutingModule.class); } - + @Provides - PtMatrix createPtMatrix(PlansCalcRouteConfigGroup plansCalcRoute, MatrixBasedPtRouterConfigGroup ippcm, Network network) { + PtMatrix createPtMatrix(RoutingConfigGroup plansCalcRoute, MatrixBasedPtRouterConfigGroup ippcm, Network network) { return PtMatrix.createPtMatrix(plansCalcRoute, BoundingBox.createBoundingBox(network), ippcm); } -} \ No newline at end of file +} diff --git a/contribs/matrixbasedptrouter/src/main/java/org/matsim/contrib/matrixbasedptrouter/PtMatrix.java b/contribs/matrixbasedptrouter/src/main/java/org/matsim/contrib/matrixbasedptrouter/PtMatrix.java index d55741d5606..56d9a6dc6c4 100644 --- a/contribs/matrixbasedptrouter/src/main/java/org/matsim/contrib/matrixbasedptrouter/PtMatrix.java +++ b/contribs/matrixbasedptrouter/src/main/java/org/matsim/contrib/matrixbasedptrouter/PtMatrix.java @@ -35,8 +35,8 @@ import org.matsim.api.core.v01.network.Node; import org.matsim.api.core.v01.population.Person; import org.matsim.contrib.matrixbasedptrouter.utils.BoundingBox; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; -import org.matsim.core.config.groups.PlansCalcRouteConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; +import org.matsim.core.config.groups.RoutingConfigGroup; import org.matsim.core.router.util.LeastCostPathCalculator; import org.matsim.core.utils.collections.QuadTree; import org.matsim.core.utils.geometry.CoordUtils; @@ -49,7 +49,7 @@ * Calculates travel times and distances from Coord to Coord based on a file containing transit stops with coordinates, * and, optionally, two files containing travel times and distances between each pair of stops. If files for travel times and distances are not provided, * they are calculated based on the teleportedModeSpeed of the pt mode, and the beelineDistanceFactor. - * + * * @author thomas */ public final class PtMatrix { @@ -60,20 +60,20 @@ public final class PtMatrix { /** * Creates an instance of this class. The config group contains the input file names, and whether speed/distance matrices are provided or not. * Speed and beeline distance factors are taken from the router configuration. - * - * A bounding box must be provided, which is used to filter the transit stop file while reading it. It is mandatory. If you just want to read the file, + * + * A bounding box must be provided, which is used to filter the transit stop file while reading it. It is mandatory. If you just want to read the file, * take the bounding box of your study area. - * + * * The transit stop file must always be provided, although it technically should not be necessary when you provide - * distance and speed matrices. It seems to be used only to give out warnings if transit stops are encountered which are not in the + * distance and speed matrices. It seems to be used only to give out warnings if transit stops are encountered which are not in the * transit stop file. - * + * * The calculated access/egress times are used without beeline distance correction, even though the pt travel times and distances are. - * - * Even though the parameters are taken from the teleportation router config, the teleportation router is not actually used to calculate + * + * Even though the parameters are taken from the teleportation router config, the teleportation router is not actually used to calculate * times and distances. I think this would be the more correct thing to do. */ - public static PtMatrix createPtMatrix(PlansCalcRouteConfigGroup plansCalcRoute, BoundingBox bb, MatrixBasedPtRouterConfigGroup ippcm) { + public static PtMatrix createPtMatrix(RoutingConfigGroup plansCalcRoute, BoundingBox bb, MatrixBasedPtRouterConfigGroup ippcm) { String ptStopInputFile = ippcm.getPtStopsInputFile(); QuadTree ptStops = FileUtils.readPtStops(ptStopInputFile, bb); @@ -138,26 +138,26 @@ public static PtMatrix createPtMatrix(PlansCalcRouteConfigGroup plansCalcRoute, private final QuadTree ptStops; private final double meterPerSecWalkSpeed; - private PtMatrix(PlansCalcRouteConfigGroup plansCalcRoute, QuadTree ptStops, Matrix originDestinationTravelTimeMatrix, Matrix originDestinationTravelDistanceMatrix){ + private PtMatrix(RoutingConfigGroup plansCalcRoute, QuadTree ptStops, Matrix originDestinationTravelTimeMatrix, Matrix originDestinationTravelDistanceMatrix){ this.meterPerSecWalkSpeed = plansCalcRoute.getTeleportedModeSpeeds().get(TransportMode.walk) ; - this.ptStops = ptStops; + this.ptStops = ptStops; this.originDestinationTravelTimeMatrix = originDestinationTravelTimeMatrix; this.originDestinationTravelDistanceMatrix = originDestinationTravelDistanceMatrix; } /** * total travel times (origin location > pt > destination location) in seconds. the travel times are composed as follows: - * + * * (O)-------(PT)===========(PT)--------(D) - * + * * O = origin location * D = destination location - * PT= next pt station - * + * PT= next pt station + * * total travel times = walk travel time from origin O to next pt stop + * pt travel time + * walk travel time from destination pt stop to destination D - * + * * @param fromFacilityCoord * @param toFacilityCoord * @return @@ -178,12 +178,12 @@ public double getTotalTravelTime_seconds(Coord fromFacilityCoord, Coord toFacili * returns the total walk travel times in seconds including * - walk travel time from given coordinate to next pt stop * - walk travel time from destination pt stop to given destination coordinate - * + * * @param fromFacilityCoord * @param toFacilityCoord * @return */ - public double getTotalWalkTravelTime_seconds(Coord fromFacilityCoord, Coord toFacilityCoord){ + public double getTotalWalkTravelTime_seconds(Coord fromFacilityCoord, Coord toFacilityCoord){ PtStop fromPtStop = this.ptStops.getClosest(fromFacilityCoord.getX(), fromFacilityCoord.getY()); PtStop toPtStop = this.ptStops.getClosest(toFacilityCoord.getX(), toFacilityCoord.getY()); @@ -219,17 +219,17 @@ public double getPtTravelTime_seconds(Coord fromFacilityCoord, Coord toFacilityC /** * total travel distance (origin location > pt > destination location) in seconds. the travel distances are composed as follows: - * + * * (O)-------(PT)===========(PT)--------(D) - * + * * O = origin location * D = destination location - * PT= next pt station - * + * PT= next pt station + * * total travel distance = walk travel distance from origin O to next pt stop + * pt travel distance + * walk travel distance from destination pt stop to destination D - * + * * travel distances in meter * @param fromFacilityCoord * @param toFacilityCoord @@ -238,7 +238,7 @@ public double getPtTravelTime_seconds(Coord fromFacilityCoord, Coord toFacilityC public double getTotalTravelDistance_meter(Coord fromFacilityCoord, Coord toFacilityCoord){ double totalWalkTravelDistance = getTotalWalkTravelDistance_meter(fromFacilityCoord, toFacilityCoord); - double ptTravelDistance = getPtTravelDistance_meter(fromFacilityCoord, toFacilityCoord); + double ptTravelDistance = getPtTravelDistance_meter(fromFacilityCoord, toFacilityCoord); double totalTravelDistance = totalWalkTravelDistance + ptTravelDistance; return totalTravelDistance; @@ -288,12 +288,12 @@ private static Map, PtStop> convertQuadTree2HashMap(QuadTree return ptStopHashMap; } - public LeastCostPathCalculator asPathCalculator(PlanCalcScoreConfigGroup planCalcScoreConfigGroup) { - final double betaWalkTT = planCalcScoreConfigGroup.getModes().get(TransportMode.walk).getMarginalUtilityOfTraveling() - planCalcScoreConfigGroup.getPerforming_utils_hr(); - final double betaWalkTD = planCalcScoreConfigGroup.getModes().get(TransportMode.walk).getMarginalUtilityOfDistance(); - final double betaPtTT = planCalcScoreConfigGroup.getModes().get(TransportMode.pt).getMarginalUtilityOfTraveling() - planCalcScoreConfigGroup.getPerforming_utils_hr(); - final double betaPtTD = planCalcScoreConfigGroup.getMarginalUtilityOfMoney() * planCalcScoreConfigGroup.getModes().get(TransportMode.pt).getMonetaryDistanceRate(); - final double constPt = planCalcScoreConfigGroup.getModes().get(TransportMode.pt).getConstant(); + public LeastCostPathCalculator asPathCalculator(ScoringConfigGroup scoringConfigGroup) { + final double betaWalkTT = scoringConfigGroup.getModes().get(TransportMode.walk).getMarginalUtilityOfTraveling() - scoringConfigGroup.getPerforming_utils_hr(); + final double betaWalkTD = scoringConfigGroup.getModes().get(TransportMode.walk).getMarginalUtilityOfDistance(); + final double betaPtTT = scoringConfigGroup.getModes().get(TransportMode.pt).getMarginalUtilityOfTraveling() - scoringConfigGroup.getPerforming_utils_hr(); + final double betaPtTD = scoringConfigGroup.getMarginalUtilityOfMoney() * scoringConfigGroup.getModes().get(TransportMode.pt).getMonetaryDistanceRate(); + final double constPt = scoringConfigGroup.getModes().get(TransportMode.pt).getConstant(); return new LeastCostPathCalculator() { @Override diff --git a/contribs/matrixbasedptrouter/src/main/java/org/matsim/contrib/matrixbasedptrouter/example/RunMatrixBasedPTRouterExample.java b/contribs/matrixbasedptrouter/src/main/java/org/matsim/contrib/matrixbasedptrouter/example/RunMatrixBasedPTRouterExample.java index 858298e4d4c..a26532a5c69 100644 --- a/contribs/matrixbasedptrouter/src/main/java/org/matsim/contrib/matrixbasedptrouter/example/RunMatrixBasedPTRouterExample.java +++ b/contribs/matrixbasedptrouter/src/main/java/org/matsim/contrib/matrixbasedptrouter/example/RunMatrixBasedPTRouterExample.java @@ -19,16 +19,11 @@ package org.matsim.contrib.matrixbasedptrouter.example; -import org.matsim.api.core.v01.Scenario; import org.matsim.contrib.matrixbasedptrouter.MatrixBasedPtModule; import org.matsim.contrib.matrixbasedptrouter.MatrixBasedPtRouterConfigGroup; -import org.matsim.contrib.matrixbasedptrouter.PtMatrix; -import org.matsim.contrib.matrixbasedptrouter.utils.BoundingBox; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.PlansCalcRouteConfigGroup; import org.matsim.core.controler.Controler; -import org.matsim.core.scenario.ScenarioUtils; /** * sets up a Matsim Scenario using example matrix based pt routing data @@ -46,7 +41,7 @@ public static void main(String[] args) //load config - check the config file for required PT Matrix input file data String path = "src/main/resources/example/"; Config config = ConfigUtils.loadConfig(path+"example_config.xml", new MatrixBasedPtRouterConfigGroup()); - + Controler controler = new Controler(config); controler.addOverridingModule(new MatrixBasedPtModule()); controler.run(); diff --git a/contribs/multimodal/src/main/java/org/matsim/contrib/multimodal/MultiModalModule.java b/contribs/multimodal/src/main/java/org/matsim/contrib/multimodal/MultiModalModule.java index d785e63042c..9a89542b2af 100644 --- a/contribs/multimodal/src/main/java/org/matsim/contrib/multimodal/MultiModalModule.java +++ b/contribs/multimodal/src/main/java/org/matsim/contrib/multimodal/MultiModalModule.java @@ -33,8 +33,8 @@ import org.matsim.contrib.multimodal.router.util.BikeTravelTimeFactory; import org.matsim.contrib.multimodal.router.util.UnknownTravelTimeFactory; import org.matsim.contrib.multimodal.router.util.WalkTravelTimeFactory; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; -import org.matsim.core.config.groups.PlansCalcRouteConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; +import org.matsim.core.config.groups.RoutingConfigGroup; import org.matsim.core.controler.AbstractModule; import org.matsim.core.router.NetworkRoutingProvider; import org.matsim.core.router.RoutingModule; @@ -63,14 +63,14 @@ public void install() { // would just operate on that sub-network. // kai, dec'19 - PlansCalcRouteConfigGroup plansCalcRouteConfigGroup = getConfig().plansCalcRoute(); - PlanCalcScoreConfigGroup cnScoringGroup = getConfig().planCalcScore(); + RoutingConfigGroup routingConfigGroup = getConfig().plansCalcRoute(); + ScoringConfigGroup cnScoringGroup = getConfig().planCalcScore(); MultiModalConfigGroup multiModalConfigGroup = (MultiModalConfigGroup) getConfig().getModule(MultiModalConfigGroup.GROUP_NAME); Set simulatedModes = CollectionUtils.stringToSet(multiModalConfigGroup.getSimulatedModes()); for (String mode : simulatedModes) { switch( mode ){ case TransportMode.walk:{ - Provider factory = new WalkTravelTimeFactory( plansCalcRouteConfigGroup, linkSlopes ); + Provider factory = new WalkTravelTimeFactory(routingConfigGroup, linkSlopes ); addTravelTimeBinding( mode ).toProvider( factory ); addTravelDisutilityFactoryBinding( mode ).toInstance( new RandomizingTimeDistanceTravelDisutilityFactory( mode, getConfig() ) ); addRoutingModuleBinding( mode ).toProvider( new NetworkRoutingProvider( mode ) ); @@ -83,7 +83,7 @@ public void install() { addRoutingModuleBinding( mode ).to( Key.get( RoutingModule.class, Names.named( TransportMode.walk ) ) ); break; case TransportMode.bike:{ - Provider factory = new BikeTravelTimeFactory( plansCalcRouteConfigGroup, linkSlopes ); + Provider factory = new BikeTravelTimeFactory(routingConfigGroup, linkSlopes ); addTravelTimeBinding( mode ).toProvider( factory ); addTravelDisutilityFactoryBinding( mode ).toInstance( new RandomizingTimeDistanceTravelDisutilityFactory( mode, getConfig() ) ); addRoutingModuleBinding( mode ).toProvider( new NetworkRoutingProvider( mode ) ); @@ -96,7 +96,7 @@ public void install() { "Use a constructor where you provide the travel time objects. " + "Using an UnknownTravelTime calculator based on constant speed." + "Agent specific attributes are not taken into account!" ); - factory = new UnknownTravelTimeFactory( mode, plansCalcRouteConfigGroup ); + factory = new UnknownTravelTimeFactory( mode, routingConfigGroup); } else{ log.info( "Found additional travel time factory from type " + factory.getClass().toString() + " for mode " + mode + "." ); diff --git a/contribs/multimodal/src/main/java/org/matsim/contrib/multimodal/router/util/BikeTravelTime.java b/contribs/multimodal/src/main/java/org/matsim/contrib/multimodal/router/util/BikeTravelTime.java index 69a4565d23a..c6a5cad91ba 100644 --- a/contribs/multimodal/src/main/java/org/matsim/contrib/multimodal/router/util/BikeTravelTime.java +++ b/contribs/multimodal/src/main/java/org/matsim/contrib/multimodal/router/util/BikeTravelTime.java @@ -24,7 +24,7 @@ import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.population.Person; -import org.matsim.core.config.groups.PlansCalcRouteConfigGroup; +import org.matsim.core.config.groups.RoutingConfigGroup; import org.matsim.vehicles.Vehicle; import java.util.Map; @@ -33,15 +33,15 @@ * Data to calculate a person's travel time on a link is taken from: * John Parkin and Jonathon Rotheram (2010): Design speeds and acceleration characteristics * of bicycle traffic for use in planning and appraisal. - * + * * The default downhill speed is limited to 35 km/h. The value is scaled for each person * based on age, gender and scatter. - * + * * On steep links, a person is faster by walking than by biking. For such links, the * walk travel time is returned. */ public class BikeTravelTime extends WalkTravelTime { - + /* * Cache variables for each thread accessing the object separately. */ @@ -49,31 +49,31 @@ public class BikeTravelTime extends WalkTravelTime { /*package*/ private final ThreadLocal maxPersonBikeSpeedCache; /*package*/ private final ThreadLocal personUphillFactorCache; /*package*/ private final ThreadLocal personDownhillFactorCache; - + /* * If the set reference speed does not match the default reference speed, - * the up- and downhill factors are scaled accordingly. + * the up- and downhill factors are scaled accordingly. */ private final double defaultReferenceSpeed = 6.01; // [m/s] - + private final double referenceBikeSpeed; // 6.01 according to Prakin and Rotheram private final double maxBikeSpeed = 35.0 / 3.6; // according to Parkin and Rotheram - + private final double downhillFactor = 0.2379; // 0%..-15% private final double uphillFactor = -0.4002; // 0%..12% - - public BikeTravelTime(PlansCalcRouteConfigGroup plansCalcGroup, Map, Double> linkSlopes) { + + public BikeTravelTime(RoutingConfigGroup plansCalcGroup, Map, Double> linkSlopes) { super(plansCalcGroup, linkSlopes); - + this.referenceBikeSpeed = plansCalcGroup.getTeleportedModeSpeeds().get(TransportMode.bike); - + this.personBikeSpeedCache = new ThreadLocal<>(); this.maxPersonBikeSpeedCache = new ThreadLocal<>(); this.personUphillFactorCache = new ThreadLocal<>(); this.personDownhillFactorCache = new ThreadLocal<>(); } - - public BikeTravelTime(PlansCalcRouteConfigGroup plansCalcGroup) { + + public BikeTravelTime(RoutingConfigGroup plansCalcGroup) { this(plansCalcGroup, null); } @@ -82,22 +82,22 @@ public BikeTravelTime(PlansCalcRouteConfigGroup plansCalcGroup) { public double getLinkTravelTime(Link link, double time, Person person, Vehicle vehicle) { setPerson(person); double walkTravelTime = super.getLinkTravelTime(link, time, person, vehicle); - + double slope = super.getSlope(link); double slopeShift = getSlopeShift(slope); - + // double linkSpeed = this.personBikeSpeed + slopeShift; double linkSpeed = this.personBikeSpeedCache.get() + slopeShift; - + // limit min and max speed // if (linkSpeed > maxPersonBikeSpeed) linkSpeed = maxPersonBikeSpeed; if (linkSpeed > this.maxPersonBikeSpeedCache.get()) linkSpeed = this.maxPersonBikeSpeedCache.get(); else if (linkSpeed < 0.0) linkSpeed = Double.MIN_VALUE; - + double bikeTravelTime = link.getLength() / linkSpeed; return Math.min(walkTravelTime, bikeTravelTime); } - + /* * It is assumed, that there is a linear relation between speed and slope. * The returned values shifts the speed on a flat area. @@ -107,20 +107,20 @@ public double getLinkTravelTime(Link link, double time, Person person, Vehicle v if (slope > 0.0) return this.personUphillFactorCache.get() * slope; else return this.personDownhillFactorCache.get() * slope; } - + @Override void setPerson(Person person) { - /* - * Only recalculate the person's speed factor if the person has + /* + * Only recalculate the person's speed factor if the person has * changed. This check has to be performed before super.setPerson(...) * is called because there the personId is already updated! */ - /* + /* * Only recalculate the person's walk speed factor if * the person has changed and is not in the map. */ if (this.personCache.get() != null && person.getId().equals(this.personCache.get().getId())) return; - + /* * If the person's walk speed is already in the map, use that value. * Otherwise calculate it and add it to the map. @@ -137,9 +137,9 @@ void setPerson(Person person) { super.setPerson(person); return; } - + super.setPerson(person); - + // this.personBikeSpeed = this.referenceBikeSpeed * this.personFactor; // this.maxPersonBikeSpeed = maxBikeSpeed * personFactor; // this.personUphillFactor = uphillFactor * personFactor * referenceBikeSpeed / defaultReferenceSpeed; diff --git a/contribs/multimodal/src/main/java/org/matsim/contrib/multimodal/router/util/BikeTravelTimeFactory.java b/contribs/multimodal/src/main/java/org/matsim/contrib/multimodal/router/util/BikeTravelTimeFactory.java index 47a3087b3ed..045dcefae3f 100644 --- a/contribs/multimodal/src/main/java/org/matsim/contrib/multimodal/router/util/BikeTravelTimeFactory.java +++ b/contribs/multimodal/src/main/java/org/matsim/contrib/multimodal/router/util/BikeTravelTimeFactory.java @@ -23,7 +23,7 @@ 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.groups.PlansCalcRouteConfigGroup; +import org.matsim.core.config.groups.RoutingConfigGroup; import org.matsim.core.router.util.TravelTime; import jakarta.inject.Provider; @@ -31,26 +31,26 @@ public class BikeTravelTimeFactory implements Provider { - private final PlansCalcRouteConfigGroup plansCalcRouteConfigGroup; + private final RoutingConfigGroup routingConfigGroup; private final Map, Double> linkSlopes; // slope information in % - public BikeTravelTimeFactory(PlansCalcRouteConfigGroup plansCalcRouteConfigGroup) { - this(plansCalcRouteConfigGroup, null); + public BikeTravelTimeFactory(RoutingConfigGroup routingConfigGroup) { + this(routingConfigGroup, null); } - public BikeTravelTimeFactory(PlansCalcRouteConfigGroup plansCalcRouteConfigGroup, - Map, Double> linkSlopes) { - this.plansCalcRouteConfigGroup = plansCalcRouteConfigGroup; + public BikeTravelTimeFactory(RoutingConfigGroup routingConfigGroup, + Map, Double> linkSlopes) { + this.routingConfigGroup = routingConfigGroup; this.linkSlopes = linkSlopes; - if (plansCalcRouteConfigGroup.getTeleportedModeSpeeds().get(TransportMode.bike) == null) { + if (routingConfigGroup.getTeleportedModeSpeeds().get(TransportMode.bike) == null) { throw new RuntimeException("No speed was found for mode bike! Aborting."); } } @Override public TravelTime get() { - return new BikeTravelTime(this.plansCalcRouteConfigGroup, this.linkSlopes); + return new BikeTravelTime(this.routingConfigGroup, this.linkSlopes); } } diff --git a/contribs/multimodal/src/main/java/org/matsim/contrib/multimodal/router/util/MultiModalTravelTimeFactory.java b/contribs/multimodal/src/main/java/org/matsim/contrib/multimodal/router/util/MultiModalTravelTimeFactory.java index 8a32bbd561b..a896cc33271 100644 --- a/contribs/multimodal/src/main/java/org/matsim/contrib/multimodal/router/util/MultiModalTravelTimeFactory.java +++ b/contribs/multimodal/src/main/java/org/matsim/contrib/multimodal/router/util/MultiModalTravelTimeFactory.java @@ -28,7 +28,7 @@ import org.matsim.contrib.multimodal.config.MultiModalConfigGroup; import org.matsim.core.api.internal.MatsimFactory; import org.matsim.core.config.Config; -import org.matsim.core.config.groups.PlansCalcRouteConfigGroup; +import org.matsim.core.config.groups.RoutingConfigGroup; import org.matsim.core.router.util.TravelTime; import org.matsim.core.utils.collections.CollectionUtils; @@ -79,19 +79,19 @@ public Map createTravelTimes() { private void initMultiModalTravelTimeFactories(Config config) { - PlansCalcRouteConfigGroup plansCalcRouteConfigGroup = config.plansCalcRoute(); + RoutingConfigGroup routingConfigGroup = config.plansCalcRoute(); MultiModalConfigGroup multiModalConfigGroup = (MultiModalConfigGroup) config.getModule(MultiModalConfigGroup.GROUP_NAME); Set simulatedModes = CollectionUtils.stringToSet(multiModalConfigGroup.getSimulatedModes()); for (String mode : simulatedModes) { if (mode.equals(TransportMode.walk)) { - Provider factory = new WalkTravelTimeFactory(plansCalcRouteConfigGroup, linkSlopes); + Provider factory = new WalkTravelTimeFactory(routingConfigGroup, linkSlopes); this.factories.put(mode, factory); } else if (mode.equals(TransportMode.transit_walk)) { - Provider factory = new TransitWalkTravelTimeFactory(plansCalcRouteConfigGroup, linkSlopes); + Provider factory = new TransitWalkTravelTimeFactory(routingConfigGroup, linkSlopes); this.factories.put(mode, factory); } else if (mode.equals(TransportMode.bike)) { - Provider factory = new BikeTravelTimeFactory(plansCalcRouteConfigGroup, linkSlopes); + Provider factory = new BikeTravelTimeFactory(routingConfigGroup, linkSlopes); this.factories.put(mode, factory); } else { Provider factory = getTravelTimeFactory(mode); @@ -101,7 +101,7 @@ private void initMultiModalTravelTimeFactories(Config config) { "Use a constructor where you provide the travel time objects. " + "Using a UnknownTravelTime calculator based on constant speed." + "Agent specific attributes are not taken into account!"); - factory = new UnknownTravelTimeFactory(mode, plansCalcRouteConfigGroup); + factory = new UnknownTravelTimeFactory(mode, routingConfigGroup); this.factories.put(mode, factory); } else { log.info("Found additional travel time factory from type " + factory.getClass().toString() + diff --git a/contribs/multimodal/src/main/java/org/matsim/contrib/multimodal/router/util/TransitWalkTravelTimeFactory.java b/contribs/multimodal/src/main/java/org/matsim/contrib/multimodal/router/util/TransitWalkTravelTimeFactory.java index f991751c15c..efc8570216f 100644 --- a/contribs/multimodal/src/main/java/org/matsim/contrib/multimodal/router/util/TransitWalkTravelTimeFactory.java +++ b/contribs/multimodal/src/main/java/org/matsim/contrib/multimodal/router/util/TransitWalkTravelTimeFactory.java @@ -23,7 +23,7 @@ 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.groups.PlansCalcRouteConfigGroup; +import org.matsim.core.config.groups.RoutingConfigGroup; import org.matsim.core.router.util.TravelTime; import jakarta.inject.Provider; @@ -31,26 +31,26 @@ public class TransitWalkTravelTimeFactory implements Provider { - private final PlansCalcRouteConfigGroup plansCalcRouteConfigGroup; + private final RoutingConfigGroup routingConfigGroup; private final Map, Double> linkSlopes; // slope information in % - public TransitWalkTravelTimeFactory(PlansCalcRouteConfigGroup plansCalcRouteConfigGroup) { - this(plansCalcRouteConfigGroup, null); + public TransitWalkTravelTimeFactory(RoutingConfigGroup routingConfigGroup) { + this(routingConfigGroup, null); } - public TransitWalkTravelTimeFactory(PlansCalcRouteConfigGroup plansCalcRouteConfigGroup, - Map, Double> linkSlopes) { - this.plansCalcRouteConfigGroup = plansCalcRouteConfigGroup; + public TransitWalkTravelTimeFactory(RoutingConfigGroup routingConfigGroup, + Map, Double> linkSlopes) { + this.routingConfigGroup = routingConfigGroup; this.linkSlopes = linkSlopes; - if (plansCalcRouteConfigGroup.getTeleportedModeSpeeds().get(TransportMode.transit_walk) == null) { + if (routingConfigGroup.getTeleportedModeSpeeds().get(TransportMode.transit_walk) == null) { throw new RuntimeException("No speed was found for mode transit_walk! Aborting."); } } @Override public TravelTime get() { - return new WalkTravelTime(plansCalcRouteConfigGroup.getTeleportedModeSpeeds().get(TransportMode.transit_walk), this.linkSlopes); + return new WalkTravelTime(routingConfigGroup.getTeleportedModeSpeeds().get(TransportMode.transit_walk), this.linkSlopes); } } diff --git a/contribs/multimodal/src/main/java/org/matsim/contrib/multimodal/router/util/UnknownTravelTime.java b/contribs/multimodal/src/main/java/org/matsim/contrib/multimodal/router/util/UnknownTravelTime.java index 0d6112bf75d..519cce73a34 100644 --- a/contribs/multimodal/src/main/java/org/matsim/contrib/multimodal/router/util/UnknownTravelTime.java +++ b/contribs/multimodal/src/main/java/org/matsim/contrib/multimodal/router/util/UnknownTravelTime.java @@ -22,7 +22,7 @@ import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.population.Person; -import org.matsim.core.config.groups.PlansCalcRouteConfigGroup; +import org.matsim.core.config.groups.RoutingConfigGroup; import org.matsim.core.router.util.TravelTime; import org.matsim.vehicles.Vehicle; @@ -31,18 +31,18 @@ * agent specific parameters are taken into account. */ public class UnknownTravelTime implements TravelTime { - + private final boolean speed; private final boolean speedFactor; private final double value; - - public UnknownTravelTime(String mode, PlansCalcRouteConfigGroup plansCalcRouteConfigGroup) { - - Double speed = plansCalcRouteConfigGroup.getTeleportedModeSpeeds().get(mode); - Double speedFactor = plansCalcRouteConfigGroup.getTeleportedModeFreespeedFactors().get(mode); - + + public UnknownTravelTime(String mode, RoutingConfigGroup routingConfigGroup) { + + Double speed = routingConfigGroup.getTeleportedModeSpeeds().get(mode); + Double speedFactor = routingConfigGroup.getTeleportedModeFreespeedFactors().get(mode); + if (speed != null && speedFactor != null) { - throw new RuntimeException("Speed as well as speed factor was found for mode " + mode + + throw new RuntimeException("Speed as well as speed factor was found for mode " + mode + "! Don't know which should be used. Aborting."); } else if (speed == null && speedFactor == null) { throw new RuntimeException("Neither speed nor speed factor was found for mode " + mode + "! Aborting."); @@ -56,10 +56,10 @@ public UnknownTravelTime(String mode, PlansCalcRouteConfigGroup plansCalcRouteCo this.speedFactor = true; } } - + @Override public double getLinkTravelTime(Link link, double time, Person person, Vehicle vehicle) { - if (speed) return link.getLength() / this.value; + if (speed) return link.getLength() / this.value; else if (speedFactor) return (link.getLength() / link.getFreespeed()) * this.value; else throw new RuntimeException("Neither speed nor speed factor was found! Aborting."); } diff --git a/contribs/multimodal/src/main/java/org/matsim/contrib/multimodal/router/util/UnknownTravelTimeFactory.java b/contribs/multimodal/src/main/java/org/matsim/contrib/multimodal/router/util/UnknownTravelTimeFactory.java index d78e8f2dd60..bf92cb5a15f 100644 --- a/contribs/multimodal/src/main/java/org/matsim/contrib/multimodal/router/util/UnknownTravelTimeFactory.java +++ b/contribs/multimodal/src/main/java/org/matsim/contrib/multimodal/router/util/UnknownTravelTimeFactory.java @@ -20,7 +20,7 @@ package org.matsim.contrib.multimodal.router.util; -import org.matsim.core.config.groups.PlansCalcRouteConfigGroup; +import org.matsim.core.config.groups.RoutingConfigGroup; import org.matsim.core.router.util.TravelTime; import jakarta.inject.Provider; @@ -28,15 +28,15 @@ public class UnknownTravelTimeFactory implements Provider { private final String mode; - private final PlansCalcRouteConfigGroup plansCalcRouteConfigGroup; + private final RoutingConfigGroup routingConfigGroup; - public UnknownTravelTimeFactory(String mode, PlansCalcRouteConfigGroup plansCalcRouteConfigGroup) { + public UnknownTravelTimeFactory(String mode, RoutingConfigGroup routingConfigGroup) { this.mode = mode; - this.plansCalcRouteConfigGroup = plansCalcRouteConfigGroup; + this.routingConfigGroup = routingConfigGroup; - Double speed = plansCalcRouteConfigGroup.getTeleportedModeSpeeds().get(mode); - Double speedFactor = plansCalcRouteConfigGroup.getTeleportedModeFreespeedFactors().get(mode); + Double speed = routingConfigGroup.getTeleportedModeSpeeds().get(mode); + Double speedFactor = routingConfigGroup.getTeleportedModeFreespeedFactors().get(mode); if (speed != null && speedFactor != null) { throw new RuntimeException("Speed as well as speed factor was found for mode " + mode + @@ -48,7 +48,7 @@ public UnknownTravelTimeFactory(String mode, PlansCalcRouteConfigGroup plansCalc @Override public TravelTime get() { - return new UnknownTravelTime(this.mode, this.plansCalcRouteConfigGroup); + return new UnknownTravelTime(this.mode, this.routingConfigGroup); } } diff --git a/contribs/multimodal/src/main/java/org/matsim/contrib/multimodal/router/util/WalkTravelTime.java b/contribs/multimodal/src/main/java/org/matsim/contrib/multimodal/router/util/WalkTravelTime.java index 34bbf805a7e..773a4fa81fb 100644 --- a/contribs/multimodal/src/main/java/org/matsim/contrib/multimodal/router/util/WalkTravelTime.java +++ b/contribs/multimodal/src/main/java/org/matsim/contrib/multimodal/router/util/WalkTravelTime.java @@ -26,8 +26,7 @@ import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.population.Person; -import org.matsim.api.core.v01.population.Person; -import org.matsim.core.config.groups.PlansCalcRouteConfigGroup; +import org.matsim.core.config.groups.RoutingConfigGroup; import org.matsim.core.population.PersonUtils; import org.matsim.core.router.util.TravelTime; import org.matsim.vehicles.Vehicle; @@ -40,33 +39,33 @@ /** * Data to calculate a person's travel time on a link is taken from: - * Weidmann, Ulrich (1992) Transporttechnik der Fussgänger - Transporttechnische Eigenschaften des Fussgängerverkehrs, + * Weidmann, Ulrich (1992) Transporttechnik der Fussgänger - Transporttechnische Eigenschaften des Fussgängerverkehrs, * Literaturauswertung, Schriftenreihe des IVT (90), Institut für Verkehrsplanung und Transportsysteme, Zürich. - * + * * Age data from 0..3 and from 80..100 is extrapolated. */ public class WalkTravelTime implements TravelTime { private static final Logger log = LogManager.getLogger(WalkTravelTime.class); - + /* * Cache variables for each thread accessing the object separately. */ /*package*/ final ThreadLocal personCache; /*package*/ final ThreadLocal personFactorCache; private final ThreadLocal personWalkSpeedCache; - + // Map shared between all threads accessing this object. /*package*/ final Map personFactors; - + private final double referenceWalkSpeed; // 1.34 according to Weidmann, [m/s] - + private final double maleScaleFactor = 1.41 / 1.34; // according to Weidmann private final double femaleScaleFactor = 1.27 / 1.34; // according to Weidmann - + private final double weidmannReferenceWalkSpeed = 1.34; // 1.34 according to Weidmann, [m/s] private final double weidmannScatterStandardDeviation = 0.26; // 0.26 according to Weidmann, [m/s] - + // age from 0 .. 100 private final double[] ageFactors = { 0.1940, 0.2776, 0.3582, 0.4328, 0.5075, 0.5821, 0.6567, 0.7090, 0.7687, 0.8284, @@ -96,47 +95,47 @@ public class WalkTravelTime implements TravelTime { 1.0133, 1.0033, 0.9922, 0.9801, 0.9670, 0.9530, 0.9382, 0.9227, 0.9067, 0.8903, 0.8737, 0.8570, 0.8405, 0.8242, 0.8085, 0.7935, 0.7795, 0.7667, 0.7555, 0.7460, 0.7386}; - + private final AtomicBoolean warnGender = new AtomicBoolean(true); private final AtomicBoolean warnSlopeRange = new AtomicBoolean(true); private final AtomicBoolean warnSlopeNotFound = new AtomicBoolean(true); private final AtomicBoolean warnAge = new AtomicBoolean(true); - + private final AtomicInteger genderWarnCount = new AtomicInteger(0); private final AtomicInteger slopeRangeWarnCount = new AtomicInteger(0); private final AtomicInteger slopeNotFoundWarnCount = new AtomicInteger(0); private final AtomicInteger ageWarnCount = new AtomicInteger(0); - + private final Map, Double> linkSlopes; - - public WalkTravelTime(PlansCalcRouteConfigGroup plansCalcGroup, Map, Double> linkSlopes) { + + public WalkTravelTime(RoutingConfigGroup plansCalcGroup, Map, Double> linkSlopes) { this.referenceWalkSpeed = plansCalcGroup.getTeleportedModeSpeeds().get(TransportMode.walk); this.personCache = new ThreadLocal<>(); this.personFactorCache = new ThreadLocal<>(); this.personWalkSpeedCache = new ThreadLocal<>(); - + this.personFactors = new ConcurrentHashMap<>(); this.linkSlopes = linkSlopes; } - + // when used for transit_walk /*package*/ WalkTravelTime(double referenceWalkSpeed, Map, Double> linkSlopes) { this.referenceWalkSpeed = referenceWalkSpeed; this.personCache = new ThreadLocal<>(); this.personFactorCache = new ThreadLocal<>(); this.personWalkSpeedCache = new ThreadLocal<>(); - + this.personFactors = new ConcurrentHashMap<>(); this.linkSlopes = linkSlopes; } - public WalkTravelTime(PlansCalcRouteConfigGroup plansCalcGroup) { + public WalkTravelTime(RoutingConfigGroup plansCalcGroup) { this(plansCalcGroup, null); } - + @Override - public double getLinkTravelTime(Link link, double time, Person person, Vehicle vehicle) { + public double getLinkTravelTime(Link link, double time, Person person, Vehicle vehicle) { setPerson(person); double slope = getSlope(link); double slopeFactor = getSlopeFactor(slope); @@ -147,7 +146,7 @@ public double getLinkTravelTime(Link link, double time, Person person, Vehicle v /*package*/ double getSlopeFactor(double slope) { double slopeFactor; - + if (slope > 80.0) { if (slopeRangeWarnCount.get() < 10) { incSlopeRangeWarnCount("Slope is out of expected range (-40% .. -80%). Found slope of " + slope + ". Use 80.0 instead."); @@ -159,18 +158,18 @@ public double getLinkTravelTime(Link link, double time, Person person, Vehicle v } slope = -40.0; } - slopeFactor = slopeFactors[-(int)Math.round(slope) + 80]; + slopeFactor = slopeFactors[-(int)Math.round(slope) + 80]; return slopeFactor; } - + /* * Returns the slope of a link in %. */ /*package*/ final double getSlope(Link link) { - + // if no slope information is available if (this.linkSlopes == null) return 0.0; - + Double slope = this.linkSlopes.get(link.getId()); if (slope == null) { incSlopeNotFoundWarnCount("No slope information for link " + link.getId().toString() + @@ -186,7 +185,7 @@ private void incGenderWarnCount(String text) { if (genderWarnCount.get() >= 10) warnGender.set(false); } } - + private void incSlopeRangeWarnCount(String text) { slopeRangeWarnCount.incrementAndGet(); if (warnSlopeRange.get()) { @@ -194,7 +193,7 @@ private void incSlopeRangeWarnCount(String text) { if (slopeRangeWarnCount.get() >= 10) warnSlopeRange.set(false); } } - + private void incSlopeNotFoundWarnCount(String text) { slopeNotFoundWarnCount.incrementAndGet(); if (warnSlopeNotFound.get()) { @@ -202,7 +201,7 @@ private void incSlopeNotFoundWarnCount(String text) { if (slopeNotFoundWarnCount.get() >= 10) warnSlopeNotFound.set(false); } } - + private void incAgeWarnCount(String text) { ageWarnCount.incrementAndGet(); if (warnAge.get()) { @@ -210,19 +209,19 @@ private void incAgeWarnCount(String text) { if (ageWarnCount.get() >= 10) warnAge.set(false); } } - + private void printWarning(String text, int count) { if (count >= 10) log.warn(text + " No further warnings from this type will be given!"); else log.warn(text); } - + /*package*/ void setPerson(Person person) { - /* + /* * Only recalculate the person's walk speed factor if * the person has changed and is not in the map. */ if (this.personCache.get() != null && person.getId().equals(this.personCache.get().getId())) return; - + /* * If the person's walk speed is already in the map, use that value. * Otherwise calculate it and add it to the map. @@ -235,7 +234,7 @@ private void printWarning(String text, int count) { this.personWalkSpeedCache.set(this.referenceWalkSpeed * personFactor); return; } - + double scatterFactor; double ageFactor = 1.0; double genderFactor = 1.0; @@ -244,7 +243,7 @@ private void printWarning(String text, int count) { Random random = new Random(); random.setSeed(person.getId().toString().hashCode()); for (int i = 0; i < 5; i++) random.nextDouble(); - + /* * Limit scatter factor to +/- 4 times the standard deviation. * Therefore, the scatter factor is 0.224 ... 1.777 @@ -257,10 +256,10 @@ private void printWarning(String text, int count) { scatterSpeed = weidmannReferenceWalkSpeed + scatterLimit; } scatterFactor = scatterSpeed / weidmannReferenceWalkSpeed; - + if (person instanceof Person) { Person p = person; - + // get gender factor if (PersonUtils.getSex(p) == null) { if (genderWarnCount.get() < 10) { @@ -273,9 +272,9 @@ private void printWarning(String text, int count) { incGenderWarnCount("Person's gender is not defined. Ignoring gender dependent walk speed factor."); } } - + Integer age = PersonUtils.getAge(p); - + if (age == null) { if (ageWarnCount.get() < 10) { incAgeWarnCount("Person's age is not defined. Ignoring age dependent walk speed factor."); @@ -295,12 +294,12 @@ else if (age < 0) { ageFactor = ageFactors[PersonUtils.getAge(p)]; } } - + double personFactor = scatterFactor * ageFactor * genderFactor; this.personCache.set(person); this.personFactorCache.set(personFactor); this.personWalkSpeedCache.set(this.referenceWalkSpeed * personFactor); - + this.personFactors.put(person.getId(), personFactor); } diff --git a/contribs/multimodal/src/main/java/org/matsim/contrib/multimodal/router/util/WalkTravelTimeFactory.java b/contribs/multimodal/src/main/java/org/matsim/contrib/multimodal/router/util/WalkTravelTimeFactory.java index 6498a1524b7..8520d65f3c3 100644 --- a/contribs/multimodal/src/main/java/org/matsim/contrib/multimodal/router/util/WalkTravelTimeFactory.java +++ b/contribs/multimodal/src/main/java/org/matsim/contrib/multimodal/router/util/WalkTravelTimeFactory.java @@ -23,7 +23,7 @@ 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.groups.PlansCalcRouteConfigGroup; +import org.matsim.core.config.groups.RoutingConfigGroup; import org.matsim.core.router.util.TravelTime; import jakarta.inject.Provider; @@ -31,26 +31,26 @@ public class WalkTravelTimeFactory implements Provider { - private final PlansCalcRouteConfigGroup plansCalcRouteConfigGroup; + private final RoutingConfigGroup routingConfigGroup; private final Map, Double> linkSlopes; // slope information in % - public WalkTravelTimeFactory(PlansCalcRouteConfigGroup plansCalcRouteConfigGroup) { - this(plansCalcRouteConfigGroup, null); + public WalkTravelTimeFactory(RoutingConfigGroup routingConfigGroup) { + this(routingConfigGroup, null); } - public WalkTravelTimeFactory(PlansCalcRouteConfigGroup plansCalcRouteConfigGroup, - Map, Double> linkSlopes) { - this.plansCalcRouteConfigGroup = plansCalcRouteConfigGroup; + public WalkTravelTimeFactory(RoutingConfigGroup routingConfigGroup, + Map, Double> linkSlopes) { + this.routingConfigGroup = routingConfigGroup; this.linkSlopes = linkSlopes; - if (plansCalcRouteConfigGroup.getTeleportedModeSpeeds().get(TransportMode.walk) == null) { + if (routingConfigGroup.getTeleportedModeSpeeds().get(TransportMode.walk) == null) { throw new RuntimeException("No speed was found for mode walk! Aborting."); } } @Override public TravelTime get() { - return new WalkTravelTime(this.plansCalcRouteConfigGroup, this.linkSlopes); + return new WalkTravelTime(this.routingConfigGroup, this.linkSlopes); } } diff --git a/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/MultiModalControlerListenerTest.java b/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/MultiModalControlerListenerTest.java index ad0fd81a5cb..5d2a16b4c06 100644 --- a/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/MultiModalControlerListenerTest.java +++ b/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/MultiModalControlerListenerTest.java @@ -52,8 +52,8 @@ import org.matsim.contrib.multimodal.tools.PrepareMultiModalScenario; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup.ActivityParams; -import org.matsim.core.config.groups.PlansCalcRouteConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup.ActivityParams; +import org.matsim.core.config.groups.RoutingConfigGroup; import org.matsim.core.config.groups.PlansConfigGroup; import org.matsim.core.controler.AbstractModule; import org.matsim.core.controler.Controler; @@ -69,7 +69,7 @@ public class MultiModalControlerListenerTest { private static final Logger log = LogManager.getLogger(MultiModalControlerListenerTest.class); - @Rule + @Rule public MatsimTestUtils utils = new MatsimTestUtils(); @SuppressWarnings("static-method") @@ -268,16 +268,16 @@ public void install() { LinkModeChecker linkModeChecker = new LinkModeChecker(controler.getScenario().getNetwork()); controler.getEvents().addHandler(linkModeChecker); - + controler.run(); - - /* NOTE: When I introduced access/egress legs, nearly everything in the following (besides bikeCount) changed. + + /* NOTE: When I introduced access/egress legs, nearly everything in the following (besides bikeCount) changed. * After setting removeStuckVehicles from true to false, the counts were stable. So with access/egress legs, a * different number of vehicles got lost ... which makes sense, because they enter/leave the traffic at different times. - * + * * Also, after not losing vehicles vehicles any more, the travel times for the uncongested modes bike and walk were stable. * Predictably, the travel time for the congested mode changes. - * + * * kai, feb'16 */ @@ -310,7 +310,7 @@ public void install() { LogManager.getLogger( this.getClass() ).warn( "carTravelTime: " + carTravelTime ) ; LogManager.getLogger( this.getClass() ).warn( "bikeTravelTime: " + bikeTravelTime ) ; LogManager.getLogger( this.getClass() ).warn( "walkTravelTime: " + walkTravelTime ) ; - if ( !config.plansCalcRoute().getAccessEgressType().equals(PlansCalcRouteConfigGroup.AccessEgressType.none) ) { + if ( !config.plansCalcRoute().getAccessEgressType().equals(RoutingConfigGroup.AccessEgressType.none) ) { Assert.assertEquals( "unexpected total travel time for car mode with number of threads "+numberOfThreads, 1.1186864E8, carTravelTime, MatsimTestUtils.EPSILON); @@ -407,7 +407,7 @@ public void handleEvent(VehicleEntersTrafficEvent event) { public void handleEvent(LinkLeaveEvent event) { Link link = this.network.getLinks().get(event.getLinkId()); String mode = this.vehModes.get(event.getVehicleId()); - + if (!link.getAllowedModes().contains(mode)) { log.error(mode); } diff --git a/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/MultiModalTripRouterTest.java b/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/MultiModalTripRouterTest.java index 74c236690d5..3158238cf68 100644 --- a/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/MultiModalTripRouterTest.java +++ b/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/MultiModalTripRouterTest.java @@ -39,7 +39,7 @@ import org.matsim.core.api.experimental.events.EventsManager; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; import org.matsim.core.controler.AbstractModule; import org.matsim.core.controler.Injector; import org.matsim.core.events.EventsUtils; @@ -66,7 +66,7 @@ public class MultiModalTripRouterTest { @Test public void testRouteLeg() { - + final Config config = ConfigUtils.createConfig(); config.plansCalcRoute().addParam("teleportedModeSpeed_bike", "6.01"); config.plansCalcRoute().addParam("teleportedModeFreespeedFactor_pt", "2.0"); @@ -74,15 +74,15 @@ public void testRouteLeg() { config.plansCalcRoute().addParam("teleportedModeSpeed_undefined", "13.88888888888889"); config.plansCalcRoute().addParam("teleportedModeSpeed_walk", "1.34"); - config.planCalcScore().addModeParams( new PlanCalcScoreConfigGroup.ModeParams( TransportMode.ride ) ); + config.planCalcScore().addModeParams( new ScoringConfigGroup.ModeParams( TransportMode.ride ) ); final Scenario scenario = ScenarioUtils.createScenario(config); - + createNetwork(scenario); - + MultiModalConfigGroup multiModalConfigGroup = new MultiModalConfigGroup(); config.addModule(multiModalConfigGroup); multiModalConfigGroup.setSimulatedModes(TransportMode.bike + ", " + TransportMode.walk + ", " + TransportMode.ride + ", " + TransportMode.pt); - + Map, Double> linkSlopes = new LinkSlopesReader().getLinkSlopes(multiModalConfigGroup, scenario.getNetwork()); /* @@ -90,7 +90,7 @@ public void testRouteLeg() { * - defaultDelegateFactory for the QNetsim modes * - multiModalTripRouterFactory for the multi-modal modes * - transitTripRouterFactory for transit trips - * + * * Note that a FastDijkstraFactory is used for the multiModalTripRouterFactory * since ... * - only "fast" router implementations handle sub-networks correct @@ -116,14 +116,14 @@ public void install() { TripRouter tripRouter = injector.getInstance(TripRouter.class); PlanRouter planRouter = new PlanRouter(tripRouter, injector.getInstance(TimeInterpretation.class)); - + /* * Create travel time object */ // pre-initialize the travel time calculator to be able to use it in the wrapper // TravelTimeCalculatorFactory travelTimeCalculatorFactory = new TravelTimeCalculatorFactoryImpl(); // TravelTimeCalculator travelTimeCalculator = travelTimeCalculatorFactory.createTravelTimeCalculator(scenario.getNetwork(), config.travelTimeCalculator()); - + // PlansCalcRouteConfigGroup configGroup = config.plansCalcRoute(); // Map multiModalTravelTimes = new HashMap(); // multiModalTravelTimes.put(TransportMode.car, travelTimeCalculator.getLinkTravelTimes()); @@ -131,16 +131,16 @@ public void install() { // multiModalTravelTimes.put(TransportMode.bike, new BikeTravelTimeOld(configGroup, new WalkTravelTimeOld(configGroup))); // multiModalTravelTimes.put(TransportMode.ride, new RideTravelTime(travelTimeCalculator.getLinkTravelTimes(), new WalkTravelTimeOld(configGroup))); // multiModalTravelTimes.put(TransportMode.pt, new PTTravelTime(configGroup, travelTimeCalculator.getLinkTravelTimes(), new WalkTravelTimeOld(configGroup))); - + // Map legRouters = createLegRouters(config, scenario.getNetwork(), multiModalTravelTimes); - - + + /* * check car mode */ checkMode(scenario, TransportMode.car, planRouter); - + /* * check pt mode */ @@ -150,47 +150,47 @@ public void install() { * check walk mode */ checkMode(scenario, TransportMode.walk, planRouter); - + /* * check bike mode */ checkMode(scenario, TransportMode.bike, planRouter); - + /* * check ride mode */ checkMode(scenario, TransportMode.ride, planRouter); } - + private void checkMode(Scenario scenario, String transportMode, PlanRouter planRouter) { // XXX transportMode parameter is NOT USED, hence this test is NOT DOING WHAT IT SHOULD! td oct 15 Person person = createPerson(scenario); planRouter.run(person); checkRoute((Leg) person.getSelectedPlan().getPlanElements().get(1), scenario.getNetwork()); } - + private Person createPerson(Scenario scenario) { - + Person person = scenario.getPopulation().getFactory().createPerson(Id.create("person", Person.class)); Plan plan = scenario.getPopulation().getFactory().createPlan(); person.addPlan(plan); - + Activity startActivity = scenario.getPopulation().getFactory().createActivityFromLinkId("start", Id.create("startLink", Link.class)); startActivity.setEndTime(8*3600); Leg leg = scenario.getPopulation().getFactory().createLeg(TransportMode.car); Activity endActivity = scenario.getPopulation().getFactory().createActivityFromLinkId("end", Id.create("endLink", Link.class)); - + plan.addActivity(startActivity); plan.addLeg(leg); plan.addActivity(endActivity); - + return person; } - - + + private void checkRoute(Leg leg, Network network) { NetworkRoute route = (NetworkRoute) leg.getRoute(); - + for (Id id : route.getLinkIds()) { Link link = network.getLinks().get(id); boolean validMode = false; @@ -201,10 +201,10 @@ private void checkRoute(Leg leg, Network network) { } } Assert.assertTrue(validMode); - + } } - + private void createNetwork(Scenario scenario) { /* @@ -223,12 +223,12 @@ private void createNetwork(Scenario scenario) { Node joinNode = scenario.getNetwork().getFactory().createNode(Id.create("joinNode", Node.class), new Coord(1.0, 0.0)); Node endNode = scenario.getNetwork().getFactory().createNode(Id.create("endNode", Node.class), new Coord(0.0, 0.0)); - + /* * create links */ Link startLink = scenario.getNetwork().getFactory().createLink(Id.create("startLink", Link.class), startNode, splitNode); - + Link toCarLink = scenario.getNetwork().getFactory().createLink(Id.create("toCarLink", Link.class), splitNode, carNode); Link toPtLink = scenario.getNetwork().getFactory().createLink(Id.create("toPtLink", Link.class), splitNode, ptNode); Link toWalkLink = scenario.getNetwork().getFactory().createLink(Id.create("toWalkLink", Link.class), splitNode, walkNode); @@ -240,9 +240,9 @@ private void createNetwork(Scenario scenario) { Link fromWalkLink = scenario.getNetwork().getFactory().createLink(Id.create("fromWalkLink", Link.class), walkNode, joinNode); Link fromBikeLink = scenario.getNetwork().getFactory().createLink(Id.create("fromBikeLink", Link.class), bikeNode, joinNode); Link fromRideLink = scenario.getNetwork().getFactory().createLink(Id.create("fromRideLink", Link.class), rideNode, joinNode); - + Link endLink = scenario.getNetwork().getFactory().createLink(Id.create("endLink", Link.class), joinNode, endNode); - + /* * set link parameter */ @@ -258,7 +258,7 @@ private void createNetwork(Scenario scenario) { fromBikeLink.setLength(10.0); fromRideLink.setLength(10.0); endLink.setLength(1.0); - + startLink.setFreespeed(120.0/3.6); toCarLink.setFreespeed(120.0/3.6); toPtLink.setFreespeed(120.0/3.6); @@ -282,7 +282,7 @@ private void createNetwork(Scenario scenario) { fromWalkLink.setAllowedModes(createSet(new String[]{TransportMode.walk})); fromBikeLink.setAllowedModes(createSet(new String[]{TransportMode.bike})); fromRideLink.setAllowedModes(createSet(new String[]{TransportMode.ride})); - + /* * add nodes to network */ @@ -295,7 +295,7 @@ private void createNetwork(Scenario scenario) { scenario.getNetwork().addNode(rideNode); scenario.getNetwork().addNode(joinNode); scenario.getNetwork().addNode(endNode); - + /* * add links to network */ @@ -310,9 +310,9 @@ private void createNetwork(Scenario scenario) { scenario.getNetwork().addLink(fromWalkLink); scenario.getNetwork().addLink(fromBikeLink); scenario.getNetwork().addLink(fromRideLink); - scenario.getNetwork().addLink(endLink); + scenario.getNetwork().addLink(endLink); } - + private Set createSet(String[] entries) { Set set = new HashSet<>(); Collections.addAll(set, entries); diff --git a/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/pt/MultiModalPTCombinationTest.java b/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/pt/MultiModalPTCombinationTest.java index e4398aaaf6b..ebbb7f03389 100644 --- a/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/pt/MultiModalPTCombinationTest.java +++ b/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/pt/MultiModalPTCombinationTest.java @@ -49,8 +49,8 @@ import org.matsim.contrib.multimodal.MultiModalModule; import org.matsim.contrib.multimodal.config.MultiModalConfigGroup; import org.matsim.core.config.Config; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup.ActivityParams; -import org.matsim.core.config.groups.PlansCalcRouteConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup.ActivityParams; +import org.matsim.core.config.groups.RoutingConfigGroup; import org.matsim.core.controler.Controler; import org.matsim.core.events.algorithms.Vehicle2DriverEventHandler; import org.matsim.core.events.handler.BasicEventHandler; @@ -59,40 +59,40 @@ public class MultiModalPTCombinationTest { private static final Logger log = LogManager.getLogger(MultiModalPTCombinationTest.class); - + @Rule public MatsimTestUtils utils = new MatsimTestUtils(); - + /** * Two things are tested here: * - Multi-modal simulation can handle TransitAgents (previously, the TransitAgent class did not implement * the HasPerson interface. As a result, the multi-modal simulation crashed since it could not access * the person). * - Multi-modal simulation can handle transit_walk legs (not yet ready...). - * ---> in nov'19 we are trying to replace transit_walk by normal walk and routingMode=pt, so this test is + * ---> in nov'19 we are trying to replace transit_walk by normal walk and routingMode=pt, so this test is * probably no longer very useful, there is no more special walk mode for pt agents - gl-nov'19 */ @Test public void testMultiModalPtCombination() { - + Fixture f = new Fixture(); f.init(); - + // Person ptPerson = f.createPersonAndAdd(f.scenario, "0", TransportMode.transit_walk); Person ptPerson = f.createPersonAndAdd(f.scenario, "0", TransportMode.walk, TransportMode.pt); Person walkPerson = f.createPersonAndAdd(f.scenario, "1", TransportMode.walk, TransportMode.walk); - + Scenario scenario = f.scenario; Config config = scenario.getConfig(); config.controler().setOutputDirectory(utils.getOutputDirectory()); - + MultiModalConfigGroup mmcg = new MultiModalConfigGroup(); mmcg.setMultiModalSimulationEnabled(true); mmcg.setSimulatedModes(TransportMode.walk + "," + TransportMode.transit_walk);//TODO: is this still useful if no agent can still use transit_walk? config.addModule(mmcg); - + config.qsim().setEndTime(24*3600); - + config.controler().setLastIteration(0); // doesn't matter - MultiModalModule sets the mobsim unconditionally. it just can't be something // which the ControlerDefaultsModule knows about. Try it, you will get an error. Quite safe. @@ -102,11 +102,11 @@ public void testMultiModalPtCombination() { ActivityParams homeParams = new ActivityParams("home"); homeParams.setTypicalDuration(16*3600); config.planCalcScore().addActivityParams(homeParams); - + // set default walk speed; according to Weidmann 1.34 [m/s] double defaultWalkSpeed = 1.34; config.plansCalcRoute().setTeleportedModeSpeed(TransportMode.walk, defaultWalkSpeed); - final PlansCalcRouteConfigGroup.TeleportedModeParams pt = new PlansCalcRouteConfigGroup.TeleportedModeParams( TransportMode.pt ); + final RoutingConfigGroup.TeleportedModeParams pt = new RoutingConfigGroup.TeleportedModeParams( TransportMode.pt ); pt.setTeleportedModeFreespeedFactor( 2.0 ); config.plansCalcRoute().addParameterSet( pt ); @@ -117,14 +117,14 @@ public void testMultiModalPtCombination() { controler.getConfig().controler().setDumpDataAtEnd(false); controler.getConfig().controler().setWriteEventsInterval(0); // controler.setOverwriteFiles(true); - + controler.addOverridingModule(new MultiModalModule()); LinkModeChecker linkModeChecker = new LinkModeChecker(scenario.getNetwork()); controler.getEvents().addHandler(linkModeChecker); - + controler.run(); - + /* * Assume that the agent's plan was changed from "home-pt-home" to * "home-transit_walk-pt_interact-pt-pt_interact-transit_walk-home" @@ -133,12 +133,12 @@ public void testMultiModalPtCombination() { Assert.assertEquals(ptPlan.getPlanElements().toString(), 7, ptPlan.getPlanElements().size()); Plan walkPlan = walkPerson.getSelectedPlan(); - if ( !config.plansCalcRoute().getAccessEgressType().equals(PlansCalcRouteConfigGroup.AccessEgressType.none) ) { + if ( !config.plansCalcRoute().getAccessEgressType().equals(RoutingConfigGroup.AccessEgressType.none) ) { Assert.assertEquals(walkPlan.getPlanElements().toString(), 7, walkPlan.getPlanElements().size()); } else { Assert.assertEquals(walkPlan.getPlanElements().toString(), 3, walkPlan.getPlanElements().size()); } - + /* * These tests fail since the TransitRouter (?) does not create NetworkRoutes. * As a result, the multi-modal simulation removes the pt agent from the simulation. @@ -146,16 +146,16 @@ public void testMultiModalPtCombination() { // assume that the transit_walk legs have network routes // Assert.assertEquals(true, ((Leg) plan.getPlanElements().get(1)).getRoute() instanceof NetworkRoute); // Assert.assertEquals(true, ((Leg) plan.getPlanElements().get(5)).getRoute() instanceof NetworkRoute); - + // assume that the number of arrival events is correct // Assert.assertEquals(4, linkModeChecker.arrivalCount); - + // assume that the number of link left events is correct // Assert.assertEquals(8, linkModeChecker.linkLeftCount); } - - + + private static class LinkModeChecker implements BasicEventHandler, LinkLeaveEventHandler, PersonDepartureEventHandler, PersonArrivalEventHandler, VehicleEntersTrafficEventHandler, VehicleLeavesTrafficEventHandler { @@ -164,29 +164,29 @@ private static class LinkModeChecker implements BasicEventHandler, LinkLeaveEven private final Map, Double> departures = new HashMap<>(); final Map leftCountPerMode = new HashMap<>(); final Map travelTimesPerMode = new HashMap<>(); - + private Vehicle2DriverEventHandler delegate = new Vehicle2DriverEventHandler(); - + public LinkModeChecker(Network network) { this.network = network; - + leftCountPerMode.put(TransportMode.pt, 0); leftCountPerMode.put(TransportMode.car, 0); leftCountPerMode.put(TransportMode.walk, 0); leftCountPerMode.put(TransportMode.transit_walk, 0); - + travelTimesPerMode.put(TransportMode.pt, 0.0); travelTimesPerMode.put(TransportMode.car, 0.0); travelTimesPerMode.put(TransportMode.walk, 0.0); travelTimesPerMode.put(TransportMode.transit_walk, 0.0); } - + @Override public void reset(int iteration) { delegate.reset(iteration); // nothing else to do here } - + @Override public void handleEvent(PersonDepartureEvent event) { this.modes.put(event.getPersonId(), event.getLegMode()); @@ -197,14 +197,14 @@ public void handleEvent(PersonDepartureEvent event) { public void handleEvent(LinkLeaveEvent event) { Link link = this.network.getLinks().get(event.getLinkId()); Id driverId = delegate.getDriverOfVehicle(event.getVehicleId()); - + if (!link.getAllowedModes().contains(this.modes.get(driverId))) { log.error("Found mode " + this.modes.get(driverId) + " on link " + link.getId()); } - + // assume that the agent is allowed to travel on the link Assert.assertEquals(true, link.getAllowedModes().contains(this.modes.get(driverId))); - + String mode = this.modes.get(driverId); int count = this.leftCountPerMode.get(mode); this.leftCountPerMode.put(mode, count + 1); @@ -216,7 +216,7 @@ public void handleEvent(PersonArrivalEvent event) { if ( mode.contains(TransportMode.non_network_walk ) || mode.contains(TransportMode.non_network_walk ) ) { return ; } - + double tripTravelTime = event.getTime() - this.departures.remove(event.getPersonId()); Double modeTravelTime = this.travelTimesPerMode.get(mode); if ( modeTravelTime==null ) { diff --git a/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/simengine/StuckAgentTest.java b/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/simengine/StuckAgentTest.java index 046c86a2087..921f5fba36d 100644 --- a/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/simengine/StuckAgentTest.java +++ b/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/simengine/StuckAgentTest.java @@ -46,7 +46,7 @@ import org.matsim.contrib.multimodal.config.MultiModalConfigGroup; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup.ActivityParams; +import org.matsim.core.config.groups.ScoringConfigGroup.ActivityParams; import org.matsim.core.controler.Controler; import org.matsim.core.events.handler.BasicEventHandler; import org.matsim.core.population.PersonUtils; @@ -61,17 +61,17 @@ public class StuckAgentTest { private static final Logger log = LogManager.getLogger(StuckAgentTest.class); - - @Rule + + @Rule public MatsimTestUtils utils = new MatsimTestUtils(); @Test public void testStuckEvents() { Config config = ConfigUtils.createConfig(); config.controler().setOutputDirectory(utils.getOutputDirectory()); - + config.qsim().setEndTime(24*3600); - + config.controler().setLastIteration(0); // doesn't matter - MultiModalModule sets the mobsim unconditionally. it just can't be something // which the ControlerDefaultsModule knows about. Try it, you will get an error. Quite safe. @@ -86,15 +86,15 @@ public void testStuckEvents() { ActivityParams homeParams = new ActivityParams("home"); homeParams.setTypicalDuration(16*3600); config.planCalcScore().addActivityParams(homeParams); - + // set default walk speed; according to Weidmann 1.34 [m/s] double defaultWalkSpeed = 1.34; config.plansCalcRoute().setTeleportedModeSpeed(TransportMode.walk, defaultWalkSpeed); - + // set default bike speed; Parkin and Rotheram according to 6.01 [m/s] double defaultBikeSpeed = 6.01; config.plansCalcRoute().setTeleportedModeSpeed(TransportMode.bike, defaultBikeSpeed); - + // set unkown mode speed double unknownModeSpeed = 2.0; config.plansCalcRoute().setTeleportedModeSpeed("other", unknownModeSpeed); @@ -108,22 +108,22 @@ public void testStuckEvents() { Node node2 = scenario.getNetwork().getFactory().createNode(Id.create("n2", Node.class), new Coord(2.0, 0.0)); Node node3 = scenario.getNetwork().getFactory().createNode(Id.create("n3", Node.class), new Coord(3.0, 0.0)); Node node4 = scenario.getNetwork().getFactory().createNode(Id.create("n4", Node.class), new Coord(4.0, 0.0)); - + Link link0 = scenario.getNetwork().getFactory().createLink(Id.create("l0", Link.class), node0, node1); Link link1 = scenario.getNetwork().getFactory().createLink(Id.create("l1", Link.class), node1, node2); Link link2 = scenario.getNetwork().getFactory().createLink(Id.create("l2", Link.class), node2, node3); Link link3 = scenario.getNetwork().getFactory().createLink(Id.create("l3", Link.class), node3, node4); - + link0.setLength(10000.0); link1.setLength(10000.0); link2.setLength(10000.0); link3.setLength(10000.0); - + link0.setAllowedModes(CollectionUtils.stringToSet("bike,walk")); link1.setAllowedModes(CollectionUtils.stringToSet("bike,walk")); link2.setAllowedModes(CollectionUtils.stringToSet("bike,walk")); link3.setAllowedModes(CollectionUtils.stringToSet("bike,walk")); - + scenario.getNetwork().addNode(node0); scenario.getNetwork().addNode(node1); scenario.getNetwork().addNode(node2); @@ -133,7 +133,7 @@ public void testStuckEvents() { scenario.getNetwork().addLink(link1); scenario.getNetwork().addLink(link2); scenario.getNetwork().addLink(link3); - + RouteFactory routeFactory = new LinkNetworkRouteFactory(); Route route0 = routeFactory.createRoute(Id.create("l0", Link.class), Id.create("l3", Link.class)); // missing l1 & l2 Route route1 = routeFactory.createRoute(Id.create("l0", Link.class), Id.create("l3", Link.class)); // missing l2 @@ -146,26 +146,26 @@ public void testStuckEvents() { scenario.getPopulation().addPerson(createPerson(scenario, "p2", "walk", null, 8.5*3600)); // regular scenario.getPopulation().addPerson(createPerson(scenario, "p3", "walk", null, 23.5*3600)); // en-route when simulation ends scenario.getPopulation().addPerson(createPerson(scenario, "p4", "walk", null, 24.5*3600)); // departs after simulation has ended - + Controler controler = new Controler(scenario); controler.getConfig().controler().setCreateGraphs(false); controler.getConfig().controler().setDumpDataAtEnd(false); controler.getConfig().controler().setWriteEventsInterval(0); - + controler.addOverridingModule(new MultiModalModule()); EventsCollector collector = new EventsCollector(); controler.getEvents().addHandler(collector); controler.getEvents().addHandler(new EventsPrinter()); - + controler.run(); - + int stuckCnt = 0; int stuckBeforeSimulationEnd = 0; for (Event e : collector.getEvents()) { if (e instanceof PersonStuckEvent) { stuckCnt++; - + if (e.getTime() < config.qsim().getEndTime().seconds()) stuckBeforeSimulationEnd++; } } @@ -173,10 +173,10 @@ public void testStuckEvents() { Assert.assertEquals(2, stuckBeforeSimulationEnd); Assert.assertEquals(4, stuckCnt); } - + private Person createPerson(Scenario scenario, String id, String mode, Route route, double departureTime) { Person person = scenario.getPopulation().getFactory().createPerson(Id.create(id, Person.class)); - + PersonUtils.setAge(person, 20); PersonUtils.setSex(person, "m"); @@ -187,17 +187,17 @@ private Person createPerson(Scenario scenario, String id, String mode, Route rou from.setEndTime(departureTime); leg.setDepartureTime(departureTime); - + Plan plan = scenario.getPopulation().getFactory().createPlan(); plan.addActivity(from); plan.addLeg(leg); plan.addActivity(to); - + person.addPlan(plan); - + return person; } - + // for debugging private static class EventsPrinter implements BasicEventHandler { @@ -217,8 +217,8 @@ public void handleEvent(final Event event) { eventXML.append("\" "); } eventXML.append("/>"); - + log.info(eventXML.toString()); } } -} \ No newline at end of file +} diff --git a/contribs/noise/src/main/java/org/matsim/contrib/noise/NoiseTollTimeDistanceTravelDisutilityFactory.java b/contribs/noise/src/main/java/org/matsim/contrib/noise/NoiseTollTimeDistanceTravelDisutilityFactory.java index 684eaf53428..926ed2b0441 100644 --- a/contribs/noise/src/main/java/org/matsim/contrib/noise/NoiseTollTimeDistanceTravelDisutilityFactory.java +++ b/contribs/noise/src/main/java/org/matsim/contrib/noise/NoiseTollTimeDistanceTravelDisutilityFactory.java @@ -19,7 +19,7 @@ * *********************************************************************** */ package org.matsim.contrib.noise; -import org.matsim.core.config.groups.PlansCalcRouteConfigGroup; +import org.matsim.core.config.groups.RoutingConfigGroup; import org.matsim.core.router.costcalculators.RandomizingTimeDistanceTravelDisutilityFactory; import org.matsim.core.router.costcalculators.TravelDisutilityFactory; import org.matsim.core.router.util.TravelDisutility; @@ -35,9 +35,9 @@ public final class NoiseTollTimeDistanceTravelDisutilityFactory implements TravelDisutilityFactory { private TravelDisutilityFactory travelDisutilityFactoryDelegate; - + @Inject private NoiseContext noiseContext; - @Inject private PlansCalcRouteConfigGroup plansCalcRouteConfigGroup; + @Inject private RoutingConfigGroup routingConfigGroup; public NoiseTollTimeDistanceTravelDisutilityFactory( TravelDisutilityFactory travelDisutilityFactoryDelegate ) { this.travelDisutilityFactoryDelegate = travelDisutilityFactoryDelegate; @@ -48,12 +48,12 @@ public final TravelDisutility createTravelDisutility(TravelTime timeCalculator) if ( travelDisutilityFactoryDelegate instanceof RandomizingTimeDistanceTravelDisutilityFactory ){ } - + return new NoiseTollTimeDistanceTravelDisutility( travelDisutilityFactoryDelegate.createTravelDisutility(timeCalculator ), new NoiseTollCalculator(noiseContext), this.noiseContext.getScenario().getConfig().planCalcScore().getMarginalUtilityOfMoney(), - plansCalcRouteConfigGroup.getRoutingRandomness()!=0. + routingConfigGroup.getRoutingRandomness()!=0. ); } - + } diff --git a/contribs/noise/src/test/java/org/matsim/contrib/noise/NoiseIT.java b/contribs/noise/src/test/java/org/matsim/contrib/noise/NoiseIT.java index 57523196709..1fe1a7e866a 100644 --- a/contribs/noise/src/test/java/org/matsim/contrib/noise/NoiseIT.java +++ b/contribs/noise/src/test/java/org/matsim/contrib/noise/NoiseIT.java @@ -18,7 +18,7 @@ * *********************************************************************** */ /** - * + * */ package org.matsim.contrib.noise; @@ -46,8 +46,8 @@ import org.matsim.core.api.experimental.events.EventsManager; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.PlansCalcRouteConfigGroup; -import org.matsim.core.config.groups.PlansCalcRouteConfigGroup.AccessEgressType; +import org.matsim.core.config.groups.RoutingConfigGroup; +import org.matsim.core.config.groups.RoutingConfigGroup.AccessEgressType; import org.matsim.core.controler.AbstractModule; import org.matsim.core.controler.Controler; import org.matsim.core.controler.Injector; @@ -74,23 +74,23 @@ public class NoiseIT { @Rule public MatsimTestUtils testUtils = new MatsimTestUtils(); - + // Tests the NoisSpatialInfo functionality separately for each function @Test public final void test1(){ - + String configFile = testUtils.getPackageInputDirectory() + "NoiseTest/config1.xml"; Config config = ConfigUtils.loadConfig(configFile, new NoiseConfigGroup()); config.controler().setOutputDirectory(testUtils.getOutputDirectory()); - + Scenario scenario = ScenarioUtils.loadScenario(config); - + NoiseConfigGroup noiseParameters = (NoiseConfigGroup) scenario.getConfig().getModules().get(NoiseConfigGroup.GROUP_NAME); - - noiseParameters.setReceiverPointGap(250.); + + noiseParameters.setReceiverPointGap(250.); noiseParameters.setScaleFactor(1.); - + String[] consideredActivities = {"home", "work"}; noiseParameters.setConsideredActivitiesForDamageCalculationArray(consideredActivities); @@ -104,31 +104,31 @@ public final void test1(){ // NoiseContext noiseContext = new NoiseContext(scenario); NoiseContext noiseContext = injector.getInstance( NoiseContext.class ) ; - + // test the grid of receiver points Assert.assertEquals("wrong number of receiver points", 16, noiseContext.getReceiverPoints().size(), MatsimTestUtils.EPSILON); Assert.assertEquals("wrong coord for receiver point Id '10'", new Coord((double) 500, (double) 100).toString(), noiseContext.getReceiverPoints().get(Id.create(10, ReceiverPoint.class)).getCoord().toString()); - + // test the allocation of activity coordinates to the nearest receiver point Assert.assertEquals("wrong nearest receiver point Id for coord 300/300 (x/y)", "5", noiseContext.getGrid().getActivityCoord2receiverPointId().get(new Coord((double) 300, (double) 300)).toString()); Assert.assertEquals("wrong nearest receiver point Id for coord 150/150 (x/y)", "9", noiseContext.getGrid().getActivityCoord2receiverPointId().get(new Coord((double) 150, (double) 150)).toString()); Assert.assertEquals("wrong nearest receiver point Id for coord 100/100 (x/y)", "8", noiseContext.getGrid().getActivityCoord2receiverPointId().get(new Coord((double) 100, (double) 100)).toString()); Assert.assertEquals("wrong nearest receiver point Id for coord 500/500 (x/y)", "2", noiseContext.getGrid().getActivityCoord2receiverPointId().get(new Coord((double) 500, (double) 500)).toString()); - + // test the allocation of relevant links to the receiver point Assert.assertEquals("wrong relevant link for receiver point Id '15'", 3, noiseContext.getReceiverPoints().get(Id.create("15", Link.class)).getRelevantLinks().size()); // Assert.assertEquals("wrong relevant link for receiver point Id '15'", 3, noiseContext.getReceiverPoints().get(Id.create("15", Link.class)).getLinkId2angleCorrection().size()); // test the distance correction term // Assert.assertEquals("wrong distance between receiver point Id '8' and link Id '1'", 8.749854822140838, noiseContext.getReceiverPoints().get(Id.create("8", ReceiverPoint.class)).getLinkId2distanceCorrection().get(Id.create("link0", Link.class)), MatsimTestUtils.EPSILON); - + // test the angle correction term // Assert.assertEquals("wrong immission angle correction for receiver point 14 and link1", -0.8913405699036482, noiseContext.getReceiverPoints().get(Id.create("14", ReceiverPoint.class)).getLinkId2angleCorrection().get(Id.create("link1", Link.class)), MatsimTestUtils.EPSILON); double angle0 = 180.; double immissionCorrection0 = 10 * Math.log10((angle0) / (180)); // Assert.assertEquals("wrong immission angle correction for receiver point 12 and link5", immissionCorrection0, noiseContext.getReceiverPoints().get(Id.create("12", ReceiverPoint.class)).getLinkId2angleCorrection().get(Id.create("link5", Link.class)), MatsimTestUtils.EPSILON); - + double angle = 65.39222026185993; double immissionCorrection = 10 * Math.log10((angle) / (180)); // Assert.assertEquals("wrong immission angle correction for receiver point 9 and link5", immissionCorrection, noiseContext.getReceiverPoints().get(Id.create("9", ReceiverPoint.class)).getLinkId2angleCorrection().get(Id.create("link5", Link.class)), MatsimTestUtils.EPSILON); @@ -137,16 +137,16 @@ public final void test1(){ double angle2 = 0.0000000001; double immissionCorrection2 = 10 * Math.log10((angle2) / (180)); // Assert.assertEquals("wrong immission angle correction for receiver point 8 and link5", immissionCorrection2, noiseContext.getReceiverPoints().get(Id.create("8", ReceiverPoint.class)).getLinkId2angleCorrection().get(Id.create("link5", Link.class)), MatsimTestUtils.EPSILON); - + double angle3 = 84.28940686250034; double immissionCorrection3 = 10 * Math.log10((angle3) / (180)); // Assert.assertEquals("wrong immission angle correction for receiver point 8 and link1", immissionCorrection3, noiseContext.getReceiverPoints().get(Id.create("8", ReceiverPoint.class)).getLinkId2angleCorrection().get(Id.create("link1", Link.class)), MatsimTestUtils.EPSILON); - + double angle4 = 180; double immissionCorrection4 = 10 * Math.log10((angle4) / (180)); // Assert.assertEquals("wrong immission angle correction for receiver point 8 and link0", immissionCorrection4, noiseContext.getReceiverPoints().get(Id.create("8", ReceiverPoint.class)).getLinkId2angleCorrection().get(Id.create("link0", Link.class)), MatsimTestUtils.EPSILON); } - + // tests the noise emissions, immissions, considered agent units, damages (receiver points), damages (per link), damages (per vehicle) based on the generated *.csv output // tests the noise events applying the average cost allocation approach @Test @@ -155,7 +155,7 @@ public final void test2a(){ String configFile = testUtils.getPackageInputDirectory() + "NoiseTest/config2.xml"; Config config = ConfigUtils.loadConfig(configFile ) ; config.controler().setOutputDirectory(testUtils.getOutputDirectory()); - config.plansCalcRoute().setAccessEgressType(PlansCalcRouteConfigGroup.AccessEgressType.none); + config.plansCalcRoute().setAccessEgressType(RoutingConfigGroup.AccessEgressType.none); runTest2a( config ) ; } @Test @@ -173,76 +173,76 @@ public final void test2aWAccessEgress(){ // } runTest2a( config ) ; } - + private static void runTest2a( Config runConfig ) { Controler controler = new Controler(runConfig); controler.getConfig().controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists ); controler.run(); - + // run the noise analysis for the final iteration (offline) - + String runDirectory = controler.getConfig().controler().getOutputDirectory(); if (!runDirectory.endsWith("/")) runDirectory = runDirectory + "/"; - + Config config = ConfigUtils.createConfig(new NoiseConfigGroup()); config.network().setInputFile(runDirectory + "output_network.xml.gz"); config.plans().setInputFile(runDirectory + "output_plans.xml.gz"); config.controler().setOutputDirectory(runDirectory); config.controler().setLastIteration(controler.getConfig().controler().getLastIteration()); - + NoiseConfigGroup noiseParameters = (NoiseConfigGroup) config.getModules().get(NoiseConfigGroup.GROUP_NAME); - - noiseParameters.setReceiverPointGap(250.); - + + noiseParameters.setReceiverPointGap(250.); + String[] consideredActivities = {"home", "work"}; noiseParameters.setConsideredActivitiesForDamageCalculationArray(consideredActivities); - + noiseParameters.setScaleFactor(1.); noiseParameters.setUseActualSpeedLevel(false); noiseParameters.setAllowForSpeedsOutsideTheValidRange(true); - + Scenario scenario = ScenarioUtils.loadScenario(config); - + NoiseOfflineCalculation noiseCalculation = new NoiseOfflineCalculation(scenario, runDirectory); - noiseCalculation.run(); - + noiseCalculation.run(); + EventsManager events = new ParallelEventsManager(false,1,65536); - + final Map, List> eventsPerPersonId = new HashMap, List>(); - + events.addHandler(new ActivityStartEventHandler() { - + @Override public void reset(int iteration) { - + } - + @Override public void handleEvent(ActivityStartEvent event) { - + if(!eventsPerPersonId.containsKey(event.getPersonId())){ eventsPerPersonId.put(event.getPersonId(), new ArrayList()); } eventsPerPersonId.get(event.getPersonId()).add(event); - + } }); - + events.addHandler(new ActivityEndEventHandler() { - + @Override public void reset(int iteration) { - + } - + @Override public void handleEvent(ActivityEndEvent event) { - + if(!eventsPerPersonId.containsKey(event.getPersonId())){ eventsPerPersonId.put(event.getPersonId(), new ArrayList()); } eventsPerPersonId.get(event.getPersonId()).add(event); - + } }); @@ -255,207 +255,207 @@ public void handleEvent(ActivityEndEvent event) { // ############################ // test considered agent units // ############################ - + double sevenOclock = 25200; double endTime = 39600; double ttOclock = 79200; - + String separator = ";"; String line = null; - + double[] timeSlots = {sevenOclock, endTime, ttOclock}; String pathToConsideredAgentUnitsFile; Map, List> consideredAgentsPerReceiverPoint = new HashMap, List>(); Map idxFromKey = new ConcurrentHashMap<>(); BufferedReader br; - + for(double currentTimeSlot : timeSlots){ - + pathToConsideredAgentUnitsFile = runDirectory + "noise-analysis/consideredAgentUnits/consideredAgentUnits_" + Double.toString(currentTimeSlot) + ".csv"; - + br = IOUtils.getBufferedReader(pathToConsideredAgentUnitsFile); - + try { - + line = br.readLine(); - + String[] keys = line.split(separator); for(int i = 0; i < keys.length; i++){ idxFromKey.put(keys[i], i); } - + int idxReceiverPointId = idxFromKey.get("Receiver Point Id"); int idxConsideredAgentUnits = idxFromKey.get("Considered Agent Units " + Time.writeTime(currentTimeSlot, Time.TIMEFORMAT_HHMMSS)); - + while((line = br.readLine()) != null){ - + keys = line.split(separator); if(!consideredAgentsPerReceiverPoint.containsKey(Id.create(keys[idxReceiverPointId], ReceiverPoint.class))){ consideredAgentsPerReceiverPoint.put(Id.create(keys[idxReceiverPointId], ReceiverPoint.class), new ArrayList()); } - + consideredAgentsPerReceiverPoint.get(Id.create(keys[idxReceiverPointId], ReceiverPoint.class)).add(Double.parseDouble(keys[idxConsideredAgentUnits])); - + } - + } catch (IOException e) { e.printStackTrace(); } - + } int index = 0; - + for(double currentTimeSlot : timeSlots){ final Map, Double> affectedPersonsPerReceiverPointTest = new HashMap, Double>(); - + double affectedPersons = 0.; - + for(Id personId : scenario.getPopulation().getPersons().keySet()){ - + double start = 0.; - + for(Event e : eventsPerPersonId.get(personId)){ boolean activityEnded = false; - + PersonActivityInfo actInfo = null; - + if(e.getEventType().equals("actend")){ - + ActivityEndEvent event = (ActivityEndEvent)e; - + if(event.getActType().equals("home")){ - + actInfo = new PersonActivityInfo(); actInfo.setActivityType("home"); actInfo.setStartTime(start); double end= index == 2 ? 30*3600 : event.getTime(); actInfo.setEndTime(end); - + activityEnded = true; - + } - + else if(event.getActType().equals("work")){ - + actInfo = new PersonActivityInfo(); actInfo.setActivityType("work"); actInfo.setStartTime(start); actInfo.setEndTime(event.getTime()); - + activityEnded = true; - + } - + } else if(e.getEventType().equals("actstart")){ - + ActivityStartEvent event = (ActivityStartEvent)e; - + if(event.getActType().equals("home")){ - + if(index == 0){ - + continue; - + } - + start = event.getTime(); - + } else if(event.getActType().equals("work")){ - + start = event.getTime(); - + } - + } - + if(activityEnded){ - + // test code of getDurationInWithinInterval from actInfo - + double durationInThisInterval = 0.; double timeIntervalStart = currentTimeSlot - noiseParameters.getTimeBinSizeNoiseComputation(); - + if (( actInfo.getStartTime() < currentTimeSlot) && ( actInfo.getEndTime() >= timeIntervalStart )) { - + if ((actInfo.getStartTime() <= timeIntervalStart) && actInfo.getEndTime() >= currentTimeSlot) { - + durationInThisInterval = noiseParameters.getTimeBinSizeNoiseComputation(); - + } else if (actInfo.getStartTime() <= timeIntervalStart && actInfo.getEndTime() <= currentTimeSlot) { - + durationInThisInterval = actInfo.getEndTime() - timeIntervalStart; - + } else if (actInfo.getStartTime() >= timeIntervalStart && actInfo.getEndTime() >= currentTimeSlot) { - + durationInThisInterval = currentTimeSlot - actInfo.getStartTime(); - + } else if (actInfo.getStartTime() >= timeIntervalStart && actInfo.getEndTime() <= currentTimeSlot) { - + durationInThisInterval = actInfo.getEndTime() - actInfo.getStartTime(); - - + + } else { - + throw new RuntimeException("Unknown case. Aborting..."); } - + } - - double durationInThisIntervalMethod = actInfo.getDurationWithinInterval(currentTimeSlot, noiseParameters.getTimeBinSizeNoiseComputation()); - + + double durationInThisIntervalMethod = actInfo.getDurationWithinInterval(currentTimeSlot, noiseParameters.getTimeBinSizeNoiseComputation()); + Assert.assertEquals("Durations of activities do not match!", durationInThisIntervalMethod, durationInThisInterval, MatsimTestUtils.EPSILON); - - double unitsThisPersonActivityInfo = durationInThisInterval / noiseParameters.getTimeBinSizeNoiseComputation(); + + double unitsThisPersonActivityInfo = durationInThisInterval / noiseParameters.getTimeBinSizeNoiseComputation(); affectedPersons = ( unitsThisPersonActivityInfo * noiseParameters.getScaleFactor() ); - + int outOfHomeActIdx = 2 ; - if ( !runConfig.plansCalcRoute().getAccessEgressType().equals(PlansCalcRouteConfigGroup.AccessEgressType.none) ) { + if ( !runConfig.plansCalcRoute().getAccessEgressType().equals(RoutingConfigGroup.AccessEgressType.none) ) { outOfHomeActIdx = 6 ; } Coord coord = actInfo.getActivityType().equals("home") ? ((Activity) scenario.getPopulation().getPersons().get(personId).getSelectedPlan().getPlanElements().get(0)).getCoord() : ((Activity) scenario.getPopulation().getPersons().get(personId).getSelectedPlan().getPlanElements().get(outOfHomeActIdx)).getCoord(); - + Id rpId = noiseCalculation.getNoiseContext().getGrid().getActivityCoord2receiverPointId().get(coord); if ( rpId==null ) { log.warn( "coord=" + coord ); Gbl.assertNotNull( rpId ); } - - if(!affectedPersonsPerReceiverPointTest.containsKey(rpId)){ + + if(!affectedPersonsPerReceiverPointTest.containsKey(rpId)){ affectedPersonsPerReceiverPointTest.put(rpId, affectedPersons); - - } else{ + + } else{ double n = affectedPersonsPerReceiverPointTest.get(rpId); - affectedPersonsPerReceiverPointTest.put(rpId, n + affectedPersons); + affectedPersonsPerReceiverPointTest.put(rpId, n + affectedPersons); } - + } - + } - + } - + if(currentTimeSlot == endTime){ - + if ( !runConfig.plansCalcRoute().getAccessEgressType().equals(AccessEgressType.none) ) { Assert.assertEquals("Wrong number of affected persons at receiver point 16", 2.3447222222222224, affectedPersonsPerReceiverPointTest.get(Id.create("16", ReceiverPoint.class)), MatsimTestUtils.EPSILON); // result changed after changing where agents are walking to in access/egress (July 20) - Assert.assertEquals("Wrong number of affected persons at receiver point 0", 0.479722222222222, + Assert.assertEquals("Wrong number of affected persons at receiver point 0", 0.479722222222222, affectedPersonsPerReceiverPointTest.get(Id.create("0", ReceiverPoint.class)), MatsimTestUtils.EPSILON); } else { - Assert.assertEquals("Wrong number of affected persons at receiver point 16", 2.35305555555555, + Assert.assertEquals("Wrong number of affected persons at receiver point 16", 2.35305555555555, affectedPersonsPerReceiverPointTest.get(Id.create("16", ReceiverPoint.class)), MatsimTestUtils.EPSILON); - Assert.assertEquals("Wrong number of affected persons at receiver point 0", 0.479722222222222, + Assert.assertEquals("Wrong number of affected persons at receiver point 0", 0.479722222222222, affectedPersonsPerReceiverPointTest.get(Id.create("0", ReceiverPoint.class)), MatsimTestUtils.EPSILON); } - + } - + for(Id receiverPointId : affectedPersonsPerReceiverPointTest.keySet()){ final Double expected = affectedPersonsPerReceiverPointTest.get(receiverPointId); if ( expected==null ) { @@ -478,11 +478,11 @@ else if(event.getActType().equals("work")){ } else { Assert.assertEquals("Wrong number of affected persons", expected, actual, MatsimTestUtils.EPSILON); } - + } - + index++; - + } // ################################# @@ -490,120 +490,120 @@ else if(event.getActType().equals("work")){ // ################################# line = null; - + String pathToEmissionsFile = runDirectory + "noise-analysis/emissions/emission_" + Double.toString(endTime) + ".csv"; - + Map, Double> emissionsPerLink = new HashMap, Double>(); idxFromKey = new ConcurrentHashMap(); - + br = IOUtils.getBufferedReader(pathToEmissionsFile); - + try { - + line = br.readLine(); String[] keys = line.split(separator); for(int i = 0; i < keys.length; i++){ idxFromKey.put(keys[i], i); } - + int idxLinkId = idxFromKey.get("Link Id"); int idxNoiseEmission = idxFromKey.get("Noise Emission " + Time.writeTime(endTime, Time.TIMEFORMAT_HHMMSS)); - + while((line = br.readLine()) != null){ - + keys = line.split(separator); emissionsPerLink.put(Id.create(keys[idxLinkId], Link.class), Double.parseDouble(keys[idxNoiseEmission])); - + } - + } catch (IOException e) { e.printStackTrace(); } - + Map, Integer> amountOfVehiclesPerLink = new HashMap<>(); - + for(NoiseEventCaused event: noiseCalculation.getTimeTracker().getDamageCalculation().getNoiseEventsCaused()){ - + if(event.getTimeBinEndTime() >= endTime - 3600 && event.getTimeBinEndTime() <= endTime){ - + Id linkId = event.getLinkId(); int amount = 1; - + if(amountOfVehiclesPerLink.containsKey(linkId)){ - + amount = amountOfVehiclesPerLink.get(linkId) + 1; amountOfVehiclesPerLink.put(linkId, amount); - + } else{ - + amountOfVehiclesPerLink.put(linkId, amount); - + } - + } - + } - + Map,Double> noiseEmissionsPerLink = new HashMap,Double>(); - + for(Id linkId : scenario.getNetwork().getLinks().keySet()){ noiseEmissionsPerLink.put(linkId, 0.); } - + for(Id linkId : amountOfVehiclesPerLink.keySet()){ double vCar = (scenario.getNetwork().getLinks().get(linkId).getFreespeed()) * 3.6; double vHdv = vCar; double p = 0; int n = amountOfVehiclesPerLink.size(); - + double mittelungspegel = RLS90NoiseEmission.calculateMittelungspegelLm(n, p); double Dv = RLS90NoiseEmission.calculateGeschwindigkeitskorrekturDv(vCar, vHdv, p); double noiseEmission = mittelungspegel + Dv; - + Assert.assertEquals("Wrong amount of emission!", noiseEmission, emissionsPerLink.get(linkId), MatsimTestUtils.EPSILON); noiseEmissionsPerLink.put(linkId, noiseEmission); - + } - + Assert.assertEquals("Wrong amount of emission!", 56.4418948379387, noiseEmissionsPerLink.get(Id.create("link2", Link.class)), MatsimTestUtils.EPSILON); Assert.assertEquals("Wrong amount of emission!", 86.4302864851097, noiseEmissionsPerLink.get(Id.create("linkA5", Link.class)), MatsimTestUtils.EPSILON); Assert.assertEquals("Wrong amount of emission!", 0., noiseEmissionsPerLink.get(Id.create("link4", Link.class)), MatsimTestUtils.EPSILON); - - + + // ############################################ // test immissions per receiver point and time // ############################################ line = null; - + String pathToImmissionsFile = runDirectory + "noise-analysis/immissions/immission_" + Double.toString(endTime) + ".csv"; - + Map, Double> immissionPerReceiverPointId = new HashMap, Double>(); - + idxFromKey = new ConcurrentHashMap(); - + br = IOUtils.getBufferedReader(pathToImmissionsFile); - + try { - + line = br.readLine(); - + String[] keys = line.split(separator); for(int i = 0; i < keys.length; i++){ idxFromKey.put(keys[i], i); } - + int idxReceiverPointId = idxFromKey.get("Receiver Point Id"); int idxImmission = idxFromKey.get("Immission " + Time.writeTime(endTime, Time.TIMEFORMAT_HHMMSS)); - + while((line = br.readLine()) != null){ - + keys = line.split(separator); immissionPerReceiverPointId.put(Id.create(keys[idxReceiverPointId], ReceiverPoint.class), Double.parseDouble(keys[idxImmission])); - + } - + } catch (IOException e) { e.printStackTrace(); } @@ -611,81 +611,81 @@ else if(event.getActType().equals("work")){ final RLS90NoiseImmission rls90NoiseImmission = new RLS90NoiseImmission(noiseCalculation.getNoiseContext(), null); for(NoiseReceiverPoint rp : noiseCalculation.getNoiseContext().getReceiverPoints().values()){ - + Map, Double> linkId2IsolatedImmission = new HashMap, Double>(); - + for(Id linkId : rp.getRelevantLinks()){ - + double noiseImmission = 0; - + if(emissionsPerLink.get(linkId) > 0){ - + noiseImmission = emissionsPerLink.get(linkId) + rp.getLinkCorrection(linkId); - + if(noiseImmission < 0) noiseImmission = 0; - + } - + linkId2IsolatedImmission.put(linkId, noiseImmission); - + } - + Assert.assertEquals("Wrong amount of immission!", rls90NoiseImmission.calculateResultingNoiseImmission(linkId2IsolatedImmission.values()), immissionPerReceiverPointId.get(rp.getId()), MatsimTestUtils.EPSILON); - + } - + Assert.assertEquals("Wrong amount of immission!", 77.25915342419277, immissionPerReceiverPointId.get(Id.create("15", ReceiverPoint.class)), MatsimTestUtils.EPSILON); Assert.assertEquals("Wrong amount of immission!", 67.9561670074151, immissionPerReceiverPointId.get(Id.create("31", ReceiverPoint.class)), MatsimTestUtils.EPSILON); Assert.assertEquals("Wrong amount of immission!", 0., immissionPerReceiverPointId.get(Id.create("0", ReceiverPoint.class)), MatsimTestUtils.EPSILON); - + // ############################################ // test damages per receiver point and time // ############################################ line = null; - + String pathToDamagesFile = runDirectory + "noise-analysis/damages_receiverPoint/damages_receiverPoint_" + Double.toString(endTime) + ".csv"; - + Map, Double> damagesPerReceiverPointId = new HashMap, Double>(); - + idxFromKey = new ConcurrentHashMap(); - + br = IOUtils.getBufferedReader(pathToDamagesFile); - + try { - + line = br.readLine(); - + String[] keys = line.split(separator); for(int i = 0; i < keys.length; i++){ idxFromKey.put(keys[i], i); } - + int idxReceiverPointId = idxFromKey.get("Receiver Point Id"); int idxDamages = idxFromKey.get("Damages " + Time.writeTime(endTime, Time.TIMEFORMAT_HHMMSS)); - + while((line = br.readLine()) != null){ - + keys = line.split(separator); damagesPerReceiverPointId.put(Id.create(keys[idxReceiverPointId], ReceiverPoint.class), Double.parseDouble(keys[idxDamages])); - + } - + } catch (IOException e) { e.printStackTrace(); } - + for(ReceiverPoint rp : noiseCalculation.getNoiseContext().getReceiverPoints().values()){ - + double noiseImmission = immissionPerReceiverPointId.get(rp.getId()); double affectedAgentUnits = consideredAgentsPerReceiverPoint.get(rp.getId()).get(1); - + Assert.assertEquals("Wrong damage!", NoiseDamageCalculation.calculateDamageCosts(noiseImmission, affectedAgentUnits, endTime, noiseParameters.getAnnualCostRate(), noiseParameters.getTimeBinSizeNoiseComputation()), damagesPerReceiverPointId.get(rp.getId()), MatsimTestUtils.EPSILON); - + } - + if ( !!runConfig.plansCalcRoute().getAccessEgressType().equals(AccessEgressType.none) ) { - Assert.assertEquals("Wrong damage!", 0.0664164095284536, + Assert.assertEquals("Wrong damage!", 0.0664164095284536, damagesPerReceiverPointId.get(Id.create("16", ReceiverPoint.class)), MatsimTestUtils.EPSILON); } else { Assert.assertEquals("Wrong damage!", 0.06618119616706872 , @@ -693,55 +693,55 @@ else if(event.getActType().equals("work")){ // result changed after changing walk distances } Assert.assertEquals("Wrong damage!", 0., damagesPerReceiverPointId.get(Id.create("0", ReceiverPoint.class)), MatsimTestUtils.EPSILON); - + // ############################################ // test average damages per link and time // ############################################ - + // noise level at receiver point '16': 69.65439464 - + // relevant link IDs - // link2: noise contribution: 50.45464287410944 --> share: 0.01202333 --> damage costs: 0.00079855 + // link2: noise contribution: 50.45464287410944 --> share: 0.01202333 --> damage costs: 0.00079855 // linkA5: noise contribution: 69.60186152606298 ---> share: 0.98797667 --> damage costs: 0.06561786 // linkB5: noise contribution: 0 - + line = null; - + String pathToDamageLinkFile = runDirectory + "noise-analysis/average_damages_link/average_damages_link_" + Double.toString(endTime) + ".csv"; - + Map, Double> damagesPerlinkId = new HashMap, Double>(); - + idxFromKey = new ConcurrentHashMap(); - + br = IOUtils.getBufferedReader(pathToDamageLinkFile); - + try { - + line = br.readLine(); - + String[] keys = line.split(separator); for(int i = 0; i < keys.length; i++){ idxFromKey.put(keys[i], i); } - + int idxLinkId = idxFromKey.get("Link Id"); int idxDamages = idxFromKey.get("Damages " + Time.writeTime(endTime, Time.TIMEFORMAT_HHMMSS)); - + while((line = br.readLine()) != null){ - + keys = line.split(separator); damagesPerlinkId.put(Id.create(keys[idxLinkId], Link.class), Double.parseDouble(keys[idxDamages])); - + } - + } catch (IOException e) { e.printStackTrace(); } if ( !!runConfig.plansCalcRoute().getAccessEgressType().equals(AccessEgressType.none) ) { - Assert.assertEquals("Wrong link's damage contribution!", 0.00079854651258, + Assert.assertEquals("Wrong link's damage contribution!", 0.00079854651258, damagesPerlinkId.get(Id.create("link2", Link.class)), MatsimTestUtils.EPSILON); - Assert.assertEquals("Wrong link's damage contribution!", 0.06561786301587, + Assert.assertEquals("Wrong link's damage contribution!", 0.06561786301587, damagesPerlinkId.get(Id.create("linkA5", Link.class)), MatsimTestUtils.EPSILON); } else { Assert.assertEquals("Wrong link's damage contribution!", 7.957184286235844E-4, @@ -750,48 +750,48 @@ else if(event.getActType().equals("work")){ damagesPerlinkId.get(Id.create("linkA5", Link.class)), MatsimTestUtils.EPSILON); } Assert.assertEquals("Wrong link's damage contribution!", 0., damagesPerlinkId.get(Id.create("linkB5", Link.class)), MatsimTestUtils.EPSILON); - + // ############################################ // test average damages per link, car and time // ############################################ - + line = null; - + String pathToDamageLinkCar = runDirectory + "noise-analysis/average_damages_link_car/average_damages_link_car_" + Double.toString(endTime) + ".csv"; - + Map, Double> damagesPerCar = new HashMap, Double>(); - + idxFromKey = new ConcurrentHashMap(); - + br = IOUtils.getBufferedReader(pathToDamageLinkCar); - + try { - + line = br.readLine(); - + String[] keys = line.split(separator); for(int i = 0; i < keys.length; i++){ idxFromKey.put(keys[i], i); } - + int idxlinkId = idxFromKey.get("Link Id"); int idxDamages = idxFromKey.get("Average damages per car " + Time.writeTime(endTime, Time.TIMEFORMAT_HHMMSS)); - + while((line = br.readLine()) != null){ - + keys = line.split(separator); damagesPerCar.put(Id.create(keys[idxlinkId], Link.class), Double.parseDouble(keys[idxDamages])); - + } - + } catch (IOException e) { e.printStackTrace(); } if ( !!runConfig.plansCalcRoute().getAccessEgressType().equals(AccessEgressType.none) ) { - Assert.assertEquals("Wrong damage per car per link!", 0.00079854651258 / 2.0, + Assert.assertEquals("Wrong damage per car per link!", 0.00079854651258 / 2.0, damagesPerCar.get(Id.create("link2", Link.class)), MatsimTestUtils.EPSILON); - Assert.assertEquals("Wrong damage per car per link!", 0.06561786301587 / 2.0, + Assert.assertEquals("Wrong damage per car per link!", 0.06561786301587 / 2.0, damagesPerCar.get(Id.create("linkA5", Link.class)), MatsimTestUtils.EPSILON); } else { Assert.assertEquals("Wrong damage per car per link!", 3.978592143117922E-4, @@ -799,48 +799,48 @@ else if(event.getActType().equals("work")){ Assert.assertEquals("Wrong damage per car per link!", 0.03269273886922247, damagesPerCar.get(Id.create("linkA5", Link.class)), MatsimTestUtils.EPSILON); } - Assert.assertEquals("Wrong damage per car per link!", 0., + Assert.assertEquals("Wrong damage per car per link!", 0., damagesPerCar.get(Id.create("linkB5", Link.class)), MatsimTestUtils.EPSILON); - + line = null; - + String pathToMarginalDamageLinkCar = runDirectory + "noise-analysis/marginal_damages_link_car/marginal_damages_link_car_" + Double.toString(endTime) + ".csv"; - + Map, Double> marginaldamagesPerCar = new HashMap, Double>(); - + idxFromKey = new ConcurrentHashMap(); - + br = IOUtils.getBufferedReader(pathToMarginalDamageLinkCar); - + try { - + line = br.readLine(); - + String[] keys = line.split(separator); for(int i = 0; i < keys.length; i++){ idxFromKey.put(keys[i], i); } - + int idxlinkId = idxFromKey.get("Link Id"); int idxDamages = idxFromKey.get("Marginal damages per car " + Time.writeTime(endTime, Time.TIMEFORMAT_HHMMSS)); - + while((line = br.readLine()) != null){ - + keys = line.split(separator); marginaldamagesPerCar.put(Id.create(keys[idxlinkId], Link.class), Double.parseDouble(keys[idxDamages])); - + } - + } catch (IOException e) { e.printStackTrace(); } - + if ( !!runConfig.plansCalcRoute().getAccessEgressType().equals(AccessEgressType.none) ) { - Assert.assertEquals("Wrong damage per car per link!", 0.00011994155845965193, + Assert.assertEquals("Wrong damage per car per link!", 0.00011994155845965193, marginaldamagesPerCar.get(Id.create("link2", Link.class)), MatsimTestUtils.EPSILON); - Assert.assertEquals("Wrong damage per car per link!", 0.008531432493391652, + Assert.assertEquals("Wrong damage per car per link!", 0.008531432493391652, marginaldamagesPerCar.get(Id.create("linkA5", Link.class)), MatsimTestUtils.EPSILON); - Assert.assertEquals("Wrong damage per car per link!", 3.440988380343235E-8, + Assert.assertEquals("Wrong damage per car per link!", 3.440988380343235E-8, marginaldamagesPerCar.get(Id.create("linkB5", Link.class)), MatsimTestUtils.EPSILON); } else { Assert.assertEquals("Wrong damage per car per link!", 1.1951678071236982E-4, @@ -850,7 +850,7 @@ else if(event.getActType().equals("work")){ Assert.assertEquals("Wrong damage per car per link!", 3.428802136662412E-8, marginaldamagesPerCar.get(Id.create("linkB5", Link.class)), MatsimTestUtils.EPSILON); } - + // ############################################ // test the noise-specific events // ############################################ @@ -862,7 +862,7 @@ else if(event.getActType().equals("work")){ if (event.getTimeBinEndTime() == 11 * 3600. && event.getLinkId().toString().equals(Id.create("linkA5", Link.class).toString()) && event.getCausingVehicleId().toString().equals((Id.create("person_car_test1", Vehicle.class).toString()))) { if ( !!runConfig.plansCalcRoute().getAccessEgressType().equals(AccessEgressType.none) ) { - Assert.assertEquals("wrong cost per car for the given link and time interval", 0.0328089315079348, + Assert.assertEquals("wrong cost per car for the given link and time interval", 0.0328089315079348, event.getAmount(), MatsimTestUtils.EPSILON); } else { Assert.assertEquals("wrong cost per car for the given link and time interval", 0.03269273886922247, @@ -871,7 +871,7 @@ else if(event.getActType().equals("work")){ counter++; } else if (event.getTimeBinEndTime() == 11 * 3600. && event.getLinkId().toString().equals(Id.create("linkA5", Link.class).toString()) && event.getCausingVehicleId().toString().equals((Id.create("person_car_test2", Vehicle.class).toString()))) { if ( !!runConfig.plansCalcRoute().getAccessEgressType().equals(AccessEgressType.none) ) { - Assert.assertEquals("wrong cost per car for the given link and time interval", 0.0328089315079348, + Assert.assertEquals("wrong cost per car for the given link and time interval", 0.0328089315079348, event.getAmount(), MatsimTestUtils.EPSILON); } else { Assert.assertEquals("wrong cost per car for the given link and time interval", 0.03269273886922247, @@ -880,7 +880,7 @@ else if(event.getActType().equals("work")){ counter++; } else if (event.getTimeBinEndTime() == 11 * 3600. && event.getLinkId().toString().equals(Id.create("link2", Link.class).toString()) && event.getCausingVehicleId().toString().equals((Id.create("person_car_test1", Vehicle.class).toString()))) { if ( !!runConfig.plansCalcRoute().getAccessEgressType().equals(AccessEgressType.none) ) { - Assert.assertEquals("wrong cost per car for the given link and time interval", 3.992732562920194E-4, + Assert.assertEquals("wrong cost per car for the given link and time interval", 3.992732562920194E-4, event.getAmount(), MatsimTestUtils.EPSILON); } else { Assert.assertEquals("wrong cost per car for the given link and time interval", 3.978592143117922E-4, @@ -889,7 +889,7 @@ else if(event.getActType().equals("work")){ counter++; } else if (event.getTimeBinEndTime() == 11 * 3600. && event.getLinkId().toString().equals(Id.create("link2", Link.class).toString()) && event.getCausingVehicleId().toString().equals((Id.create("person_car_test2", Vehicle.class).toString()))) { if ( !!runConfig.plansCalcRoute().getAccessEgressType().equals(AccessEgressType.none) ) { - Assert.assertEquals("wrong cost per car for the given link and time interval", 3.992732562920194E-4, + Assert.assertEquals("wrong cost per car for the given link and time interval", 3.992732562920194E-4, event.getAmount(), MatsimTestUtils.EPSILON); } else { Assert.assertEquals("wrong cost per car for the given link and time interval", 3.978592143117922E-4, @@ -900,10 +900,10 @@ else if(event.getActType().equals("work")){ log.warn(event.toString()); Assert.assertEquals("There should either be no further events, or the amount should be zero.", 0., event.getAmount(), MatsimTestUtils.EPSILON); } - } + } Assert.assertTrue("No event found to be tested.", tested); Assert.assertEquals("Wrong number of total events.", 4, counter, MatsimTestUtils.EPSILON); - + boolean tested2 = false; int counter2 = 0; for (NoiseEventAffected event : noiseCalculation.getTimeTracker().getDamageCalculation().getNoiseEventsAffected()) { @@ -911,7 +911,7 @@ else if(event.getActType().equals("work")){ if (event.getTimeBinEndTime() == 11 * 3600. && event.getrReceiverPointId().toString().equals(Id.create("16", ReceiverPoint.class).toString()) && event.getAffectedAgentId().toString().equals((Id.create("person_car_test1", Person.class).toString())) && event.getActType().equals("work") ) { if ( !!runConfig.plansCalcRoute().getAccessEgressType().equals(AccessEgressType.none) ) { - Assert.assertEquals("wrong cost per car for the given link and time interval", 0.020745817449213576, + Assert.assertEquals("wrong cost per car for the given link and time interval", 0.020745817449213576, event.getAmount(), MatsimTestUtils.EPSILON); } else { Assert.assertEquals("wrong cost per car for the given link and time interval", 0.02062821077070937, @@ -920,7 +920,7 @@ else if(event.getActType().equals("work")){ counter2++; } else if (event.getTimeBinEndTime() == 11 * 3600. && event.getrReceiverPointId().toString().equals(Id.create("16", ReceiverPoint.class).toString()) && event.getAffectedAgentId().toString().equals((Id.create("person_car_test2", Person.class).toString())) && event.getActType().equals("work")) { if ( !!runConfig.plansCalcRoute().getAccessEgressType().equals(AccessEgressType.none) ) { - Assert.assertEquals("wrong cost per car for the given link and time interval", 0.017444990107520864, + Assert.assertEquals("wrong cost per car for the given link and time interval", 0.017444990107520864, event.getAmount(), MatsimTestUtils.EPSILON); } else { Assert.assertEquals("wrong cost per car for the given link and time interval",0.017327383429596242, @@ -929,27 +929,27 @@ else if(event.getActType().equals("work")){ counter2++; } else if (event.getTimeBinEndTime() == 11 * 3600. && event.getrReceiverPointId().toString().equals(Id.create("16", ReceiverPoint.class).toString()) && event.getAffectedAgentId().toString().equals((Id.create("person_car_test3", Person.class).toString())) && event.getActType().equals("home")) { if ( !!runConfig.plansCalcRoute().getAccessEgressType().equals(AccessEgressType.none) ) { - Assert.assertEquals("wrong cost per car for the given link and time interval", 0.028225601971719153, + Assert.assertEquals("wrong cost per car for the given link and time interval", 0.028225601971719153, event.getAmount(), MatsimTestUtils.EPSILON); } else { - Assert.assertEquals("wrong cost per car for the given link and time interval", 0.028225601971719153, + Assert.assertEquals("wrong cost per car for the given link and time interval", 0.028225601971719153, event.getAmount(), MatsimTestUtils.EPSILON); } counter2++; } else { Assert.assertEquals("There should either be no further events, or the amount should be zero.", 0., event.getAmount(), MatsimTestUtils.EPSILON); } - - } + + } Assert.assertTrue("No event found to be tested.", tested2); Assert.assertEquals("Wrong number of total events.", 3, counter2, MatsimTestUtils.EPSILON); - + } - + // same test as before, but using the marginal cost approach @Test public final void test2b(){ - + String runDirectory = null; int lastIteration = -1; { @@ -958,41 +958,41 @@ public final void test2b(){ Config runConfig = ConfigUtils.loadConfig( configFile ) ; runConfig.controler().setOutputDirectory(testUtils.getOutputDirectory()); - runConfig.plansCalcRoute().setAccessEgressType(PlansCalcRouteConfigGroup.AccessEgressType.none); - // I made test2a test both versions, but I don't really want to do that work again myself. kai, feb'16 - + runConfig.plansCalcRoute().setAccessEgressType(RoutingConfigGroup.AccessEgressType.none); + // I made test2a test both versions, but I don't really want to do that work again myself. kai, feb'16 + Controler controler = new Controler(runConfig); controler.getConfig().controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists ); - controler.run(); - + controler.run(); + runDirectory = controler.getConfig().controler().getOutputDirectory() + "/"; lastIteration = controler.getConfig().controler().getLastIteration(); } - + // run the noise analysis for the final iteration (offline) - + Config config = ConfigUtils.createConfig(); config.network().setInputFile(runDirectory + "output_network.xml.gz"); config.plans().setInputFile(runDirectory + "output_plans.xml.gz"); config.controler().setOutputDirectory(runDirectory); config.controler().setLastIteration(lastIteration); - + // adjust the default noise parameters NoiseConfigGroup noiseParameters = ConfigUtils.addOrGetModule(config, NoiseConfigGroup.class); - noiseParameters.setReceiverPointGap(250.); - + noiseParameters.setReceiverPointGap(250.); + String[] consideredActivities = {"home", "work"}; noiseParameters.setConsideredActivitiesForDamageCalculationArray(consideredActivities); - + noiseParameters.setScaleFactor(1.); noiseParameters.setNoiseAllocationApproach(NoiseConfigGroup.NoiseAllocationApproach.MarginalCost); noiseParameters.setUseActualSpeedLevel(false); noiseParameters.setAllowForSpeedsOutsideTheValidRange(true); Scenario scenario = ScenarioUtils.loadScenario(config); - + NoiseOfflineCalculation noiseCalculation = new NoiseOfflineCalculation(scenario, runDirectory); - noiseCalculation.run(); - + noiseCalculation.run(); + // ############################################ // test the noise-specific events // ############################################ @@ -1017,10 +1017,10 @@ public final void test2b(){ } else { Assert.assertEquals("There should either be no further events, or the amount should be zero.", 0., event.getAmount(), MatsimTestUtils.EPSILON); } - } + } Assert.assertTrue("No event found to be tested.", tested); Assert.assertEquals("Wrong number of total events.", 4, counter, MatsimTestUtils.EPSILON); - + boolean tested2 = false; int counter2 = 0; for (NoiseEventAffected event : noiseCalculation.getTimeTracker().getDamageCalculation().getNoiseEventsAffected()) { @@ -1038,26 +1038,26 @@ public final void test2b(){ } else { Assert.assertEquals("There should either be no further events, or the amount should be zero.", 0., event.getAmount(), MatsimTestUtils.EPSILON); } - - } + + } Assert.assertTrue("No event found to be tested.", tested2); Assert.assertEquals("Wrong number of total events.", 3, counter2, MatsimTestUtils.EPSILON); - + } - + // same test as 2a, but using the actual speed level @Test public final void test2c(){ - + // start a simple MATSim run with a single iteration String configFile = testUtils.getPackageInputDirectory() + "NoiseTest/config2.xml"; Controler controler = new Controler(configFile); controler.getConfig().controler().setOutputDirectory(testUtils.getOutputDirectory()); controler.getConfig().controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists ); controler.run(); - + // run the noise analysis for the final iteration (offline) - + String runDirectory = controler.getConfig().controler().getOutputDirectory() + "/"; Config config = ConfigUtils.createConfig(new NoiseConfigGroup()); @@ -1065,70 +1065,70 @@ public final void test2c(){ config.plans().setInputFile(runDirectory + "output_plans.xml.gz"); config.controler().setOutputDirectory(runDirectory); config.controler().setLastIteration(controler.getConfig().controler().getLastIteration()); - + // adjust the default noise parameters NoiseConfigGroup noiseParameters = (NoiseConfigGroup) config.getModules().get(NoiseConfigGroup.GROUP_NAME); - noiseParameters.setReceiverPointGap(250.); - + noiseParameters.setReceiverPointGap(250.); + String[] consideredActivities = {"home", "work"}; noiseParameters.setConsideredActivitiesForDamageCalculationArray(consideredActivities); - + noiseParameters.setScaleFactor(1.); noiseParameters.setUseActualSpeedLevel(true); noiseParameters.setAllowForSpeedsOutsideTheValidRange(true); Scenario scenario = ScenarioUtils.loadScenario(config); - + NoiseOfflineCalculation noiseCalculation = new NoiseOfflineCalculation(scenario, runDirectory); - noiseCalculation.run(); - + noiseCalculation.run(); + EventsManager events = EventsUtils.createEventsManager(); - + final Map, List> eventsPerPersonId = new HashMap, List>(); - + events.addHandler(new ActivityStartEventHandler() { - + @Override public void reset(int iteration) { - + } - + @Override public void handleEvent(ActivityStartEvent event) { - + if(!eventsPerPersonId.containsKey(event.getPersonId())){ eventsPerPersonId.put(event.getPersonId(), new ArrayList()); } eventsPerPersonId.get(event.getPersonId()).add(event); - + } }); - + events.addHandler(new ActivityEndEventHandler() { - + @Override public void reset(int iteration) { - + } - + @Override public void handleEvent(ActivityEndEvent event) { - + if(!eventsPerPersonId.containsKey(event.getPersonId())){ eventsPerPersonId.put(event.getPersonId(), new ArrayList()); } eventsPerPersonId.get(event.getPersonId()).add(event); - + } }); - + MatsimEventsReader reader = new MatsimEventsReader(events); reader.readFile(runDirectory + "ITERS/it." + config.controler().getLastIteration() + "/" + config.controler().getLastIteration() + ".events.xml.gz"); - + double endTime = 39600; - + String separator = ";"; String line = null; - + Map idxFromKey = new ConcurrentHashMap(); BufferedReader br; @@ -1137,82 +1137,82 @@ public void handleEvent(ActivityEndEvent event) { // ################################# line = null; - + String pathToEmissionsFile = runDirectory + "noise-analysis/emissions/emission_" + Double.toString(endTime) + ".csv"; - + Map, Double> emissionsPerLink = new HashMap, Double>(); idxFromKey = new ConcurrentHashMap(); - + br = IOUtils.getBufferedReader(pathToEmissionsFile); - + try { - + line = br.readLine(); String[] keys = line.split(separator); for(int i = 0; i < keys.length; i++){ idxFromKey.put(keys[i], i); } - + int idxLinkId = idxFromKey.get("Link Id"); int idxNoiseEmission = idxFromKey.get("Noise Emission " + Time.writeTime(endTime, Time.TIMEFORMAT_HHMMSS)); - + while((line = br.readLine()) != null){ - + keys = line.split(separator); emissionsPerLink.put(Id.create(keys[idxLinkId], Link.class), Double.parseDouble(keys[idxNoiseEmission])); - + } - + Assert.assertEquals("Wrong amount of emission!", 56.4418948379387, emissionsPerLink.get(Id.create("link2", Link.class)), MatsimTestUtils.EPSILON); Assert.assertEquals("Wrong amount of emission!", 77.3994680630406, emissionsPerLink.get(Id.create("linkA5", Link.class)), MatsimTestUtils.EPSILON); Assert.assertEquals("Wrong amount of emission!", 0., emissionsPerLink.get(Id.create("link4", Link.class)), MatsimTestUtils.EPSILON); - + } catch (IOException e) { e.printStackTrace(); } } - + // tests the static methods within class "noiseEquations" @Test public final void test3(){ - + double p = 0; double pInPercent = 0; double vCar = 100; double vHgv = vCar; - + // test speed correction term double eCar = 27.7 + 10 * Math.log10( 1 + Math.pow((0.02 * vCar), 3) ); double eHgv = 23.1 + 12.5 * Math.log10( vHgv ); - + double expectedEcar = 37.2424250943932; double expectedEhgv = 48.1; - + Assert.assertEquals("Error in deviation term for speed correction (car)", expectedEcar, eCar, MatsimTestUtils.EPSILON); Assert.assertEquals("Error in deviation term for speed correction (car)", expectedEcar, RLS90NoiseEmission.calculateLCar(vCar), MatsimTestUtils.EPSILON); Assert.assertEquals("Error in deviation term for speed correction (hgv)", expectedEhgv, eHgv, MatsimTestUtils.EPSILON); Assert.assertEquals("Error in deviation term for speed correction (hgv)", expectedEhgv, RLS90NoiseEmission.calculateLHdv(vHgv), MatsimTestUtils.EPSILON); - + Assert.assertTrue("Error in deviation term for speed correction (eCar > eHgv)", eCar < eHgv); - + // test mittelungspegel and speed correction - + for(double nHgvs = 0; nHgvs < 3; nHgvs++){ - + for(double nCars = 0; nCars < 3; nCars++){ - + int n = (int) (nCars + nHgvs); - + if(n > 0){ p = nHgvs / n; pInPercent = 100 * p; } - + // test computation of mittelungspegel double mittelungspegel = 37.3 + 10 * Math.log10( n * ( 1 + 0.082 * pInPercent ) ); - + double expectedMittelungspegel = Double.NEGATIVE_INFINITY; - + if(nHgvs == 0){ if(nCars == 1) expectedMittelungspegel = 37.3; else if(nCars == 2) expectedMittelungspegel = 40.3102999566398; @@ -1228,51 +1228,51 @@ else if( nHgvs == 2){ else if( nCars == 2) expectedMittelungspegel = 50.396301674259; } } - + Assert.assertEquals("Error while calculating Mittelungspegel for " + nCars + " car(s) and " + nHgvs + " hgv(s)!", expectedMittelungspegel, mittelungspegel, MatsimTestUtils.EPSILON); Assert.assertEquals("Error while calculating Mittelungspegel for " + nCars + " car(s) and " + nHgvs + " hgv(s)!", expectedMittelungspegel, RLS90NoiseEmission.calculateMittelungspegelLm(n, p), MatsimTestUtils.EPSILON); - + //test speed correction double speedCorrection = expectedEcar - 37.3 + 10 * Math.log10( (100 + ( Math.pow(10, 0.1*(expectedEhgv - expectedEcar)) - 1 ) * pInPercent ) / (100 + 8.23*pInPercent) ); - + double expectedSpeedCorrection = -0.0575749056067494; - + if(p == 1./3.) expectedSpeedCorrection = 0.956336446449128; else if(p == 0.5) expectedSpeedCorrection = 1.04384127904235; else if(p == 2./3.) expectedSpeedCorrection = 1.09354779994927; else if( p == 1) expectedSpeedCorrection = 1.14798298974089; - + Assert.assertEquals("Error while calculating speed correction term for p = " + p + "!", expectedSpeedCorrection, speedCorrection, MatsimTestUtils.EPSILON); Assert.assertEquals("Error while calculating speed correction term for p = " + p + "!", expectedSpeedCorrection, RLS90NoiseEmission.calculateGeschwindigkeitskorrekturDv(vCar, vHgv, p), MatsimTestUtils.EPSILON); } - + } - + // test distance correction term for(double distance = 5.; distance <= 140; distance += 45.){ - + double distanceCorrection = 15.8 - 10 * Math.log10( distance ) - 0.0142 * Math.pow(distance, 0.9); - + double expectedDistanceCorrection = 0.; - + if(distance == 5) expectedDistanceCorrection = 8.74985482214084; else if(distance == 50) expectedDistanceCorrection = -1.66983281320262; else if(distance == 95) expectedDistanceCorrection = -4.8327746143211; else if(distance == 140) expectedDistanceCorrection = -6.87412053759382; - + Assert.assertEquals("Error while calculating distance correction term!", expectedDistanceCorrection, distanceCorrection, MatsimTestUtils.EPSILON); Assert.assertEquals("Error while calculating distance correction term!", expectedDistanceCorrection, RLS90NoiseImmission.calculateDistanceCorrection(distance), MatsimTestUtils.EPSILON); - + } // test angle correction term for(double angle = 45; angle <= 360; angle += 45){ - + double angleCorrection = 10 * Math.log10( angle / 180 ); - + double expectedAngleCorrection = 0.; - + if(angle == 45) expectedAngleCorrection = -6.02059991327962; else if(angle == 90) expectedAngleCorrection = -3.01029995663981; else if(angle == 135) expectedAngleCorrection = -1.249387366083; @@ -1281,12 +1281,12 @@ else if( nHgvs == 2){ else if(angle == 270) expectedAngleCorrection = 1.76091259055681; else if(angle == 315) expectedAngleCorrection = 2.43038048686294; else if(angle == 360) expectedAngleCorrection = 3.01029995663981; - + Assert.assertEquals("Error while calculating angle correction term!", expectedAngleCorrection, angleCorrection, MatsimTestUtils.EPSILON); Assert.assertEquals("Error while calculating angle correction term!", expectedAngleCorrection, RLS90NoiseImmission.calculateAngleCorrection(angle), MatsimTestUtils.EPSILON); - + } - + //test resulting noise immission double distance1 = 120; double angle1 = 120; @@ -1297,34 +1297,34 @@ else if( nHgvs == 2){ double distance3 = 399; double angle3 = 10; double emission3 = 50; - + double distanceCorrection1 = 15.8 - 10 * Math.log10( distance1 ) - 0.0142 * Math.pow(distance1, 0.9); double angleCorrection1 = 10 * Math.log10( angle1 / 180 ); double distanceCorrection2 = 15.8 - 10 * Math.log10( distance2 ) - 0.0142 * Math.pow(distance2, 0.9); double angleCorrection2 = 10 * Math.log10( angle2 / 180 ); double distanceCorrection3 = 15.8 - 10 * Math.log10( distance3 ) - 0.0142 * Math.pow(distance3, 0.9); double angleCorrection3 = 10 * Math.log10( angle3 / 180 ); - + double i1 = emission1 + distanceCorrection1 + angleCorrection1; double i2 = emission2 + distanceCorrection2 + angleCorrection2; double i3 = emission3 + distanceCorrection3 + angleCorrection3; - + double[] immissionsArray = {i1,i2,i3}; - + List immissions = new ArrayList(); immissions.add(i1); immissions.add(i2); immissions.add(i3); - + double tmp = 0.; - + for(double d : immissionsArray){ tmp += Math.pow(10, 0.1*d); } - + double resultingNoiseImmission = 10*Math.log10(tmp); double expectedResultingNoiseImmission = 41.279204220881; - + Assert.assertEquals("Error in noise immission calculation!", expectedResultingNoiseImmission, resultingNoiseImmission, MatsimTestUtils.EPSILON); double resultingNoiseImmission1 = 0.; @@ -1341,124 +1341,124 @@ else if( nHgvs == 2){ } } Assert.assertEquals("Error in noise immission calculation!", expectedResultingNoiseImmission, resultingNoiseImmission1, MatsimTestUtils.EPSILON); - + //test noise damage double annualCostRate = (85.0/(1.95583)) * (Math.pow(1.02, (2014-1995))); - + double thresholdDay = 50; double thresholdEvening = 45; double thresholdNight = 40; - + int nPersons = 4; - + double costsDay = resultingNoiseImmission > thresholdDay ? annualCostRate * 3600/(365*24) * nPersons/3600 * Math.pow(2, 0.1 * (resultingNoiseImmission - thresholdDay)) : 0.; double costsEvening = resultingNoiseImmission > thresholdEvening ? annualCostRate * 3600/(365*24) * nPersons/3600 * Math.pow(2, 0.1 * (resultingNoiseImmission - thresholdEvening)) : 0.; double costsNight = resultingNoiseImmission > thresholdNight ? annualCostRate * 3600/(365*24) * nPersons/3600 * Math.pow(2, 0.1 * (resultingNoiseImmission - thresholdNight)) : 0.; - + double expectedCostsDay = 0.; double expectedCostsEvening = 0.; double expectedCostsNight = 0.031590380365211; - + Assert.assertEquals("Error in damage calculation!", expectedCostsDay, costsDay , MatsimTestUtils.EPSILON); Assert.assertEquals("Error in damage calculation!", expectedCostsDay, NoiseDamageCalculation.calculateDamageCosts(resultingNoiseImmission, nPersons, 7.*3600, annualCostRate, 3600.) , MatsimTestUtils.EPSILON); Assert.assertEquals("Error in damage calculation!", expectedCostsEvening, costsEvening, MatsimTestUtils.EPSILON); Assert.assertEquals("Error in damage calculation!", expectedCostsEvening, NoiseDamageCalculation.calculateDamageCosts(resultingNoiseImmission, nPersons, 19.*3600, annualCostRate, 3600.), MatsimTestUtils.EPSILON); Assert.assertEquals("Error in damage calculation!", expectedCostsNight, costsNight, MatsimTestUtils.EPSILON); Assert.assertEquals("Error in damage calculation!", expectedCostsNight, NoiseDamageCalculation.calculateDamageCosts(resultingNoiseImmission, nPersons, 23.*3600, annualCostRate, 3600.), MatsimTestUtils.EPSILON); - } - + } + // tests the static methods within class "noiseEquations" @Test public final void test4(){ - + double vCar = 0.0496757749985181; double vHGV = 0.0478758773550055; int nCar = 119; int nHGV = 4; - + int n = (nCar + nHGV) * 10; - - double p = ( (double) nHGV / (double) (nCar + nHGV)); - + + double p = ( (double) nHGV / (double) (nCar + nHGV)); + double mittelungspegel = RLS90NoiseEmission.calculateMittelungspegelLm(n, p); Assert.assertEquals("Wrong mittelungspegel for n="+ n + " and p=" + p + "!", 69.22567453336540, mittelungspegel, MatsimTestUtils.EPSILON); - + double lCar = RLS90NoiseEmission.calculateLCar(vCar); Assert.assertEquals("Wrong LCar for vCar="+ vCar + "!", 27.70000000425900, lCar, MatsimTestUtils.EPSILON); - + double lHGV = RLS90NoiseEmission.calculateLHdv(vHGV); Assert.assertEquals("Wrong LHGV for vHGV="+ vHGV + "!", 6.60145932205085, lHGV, MatsimTestUtils.EPSILON); double dV = RLS90NoiseEmission.calculateGeschwindigkeitskorrekturDv(vCar, vHGV, p); Assert.assertEquals("Wrong Dv!", -10.772415234056300, dV, MatsimTestUtils.EPSILON); - + double emission = mittelungspegel + dV; Assert.assertEquals("Wrong emission!", 58.453259299309124, emission, MatsimTestUtils.EPSILON); - + // plus one car - + int nPlusOneCar = (nCar+1 + nHGV) * 10; - double pPlusOneCar = ( (double) nHGV / (double) ((nCar + 1) + nHGV)); + double pPlusOneCar = ( (double) nHGV / (double) ((nCar + 1) + nHGV)); double mittelungspegelPlusOneCar = RLS90NoiseEmission.calculateMittelungspegelLm(nPlusOneCar, pPlusOneCar); double dVPlusOneCar = RLS90NoiseEmission.calculateGeschwindigkeitskorrekturDv(vCar, vHGV, pPlusOneCar); double emissionPlusOneCar = mittelungspegelPlusOneCar + dVPlusOneCar; Assert.assertEquals("Wrong emission!", 58.4896140186478, emissionPlusOneCar, MatsimTestUtils.EPSILON); - + // plus one HGV - + int nPlusOneHGV = (nCar + nHGV + 1) * 10; - double pPlusOneHGV = ( (double) (nHGV + 1) / (double) (nCar + (nHGV + 1))); + double pPlusOneHGV = ( (double) (nHGV + 1) / (double) (nCar + (nHGV + 1))); double mittelungspegelPlusOneHGV = RLS90NoiseEmission.calculateMittelungspegelLm(nPlusOneHGV, pPlusOneHGV); double dVPlusOneHGV = RLS90NoiseEmission.calculateGeschwindigkeitskorrekturDv(vCar, vHGV, pPlusOneHGV); double emissionPlusOneHGV = mittelungspegelPlusOneHGV + dVPlusOneHGV; Assert.assertEquals("Wrong emission!", 58.4529399949061, emissionPlusOneHGV, MatsimTestUtils.EPSILON); } - + // tests the static methods within class "noiseEquations" - other speed levels @Test public final void test5(){ - + double vCar = 30; double vHGV = 30; int nCar = 119; int nHGV = 4; - + int n = (nCar + nHGV) * 10; - - double p = ( (double) nHGV / (double) (nCar + nHGV)); - + + double p = ( (double) nHGV / (double) (nCar + nHGV)); + double mittelungspegel = RLS90NoiseEmission.calculateMittelungspegelLm(n, p); Assert.assertEquals("Wrong mittelungspegel for n="+ n + " and p=" + p + "!", 69.22567453336540, mittelungspegel, MatsimTestUtils.EPSILON); - + double lCar = RLS90NoiseEmission.calculateLCar(vCar); Assert.assertEquals("Wrong LCar for vCar="+ vCar + "!", 28.54933574936720, lCar, MatsimTestUtils.EPSILON); - + double lHGV = RLS90NoiseEmission.calculateLHdv(vHGV); Assert.assertEquals("Wrong LHGV for vHGV="+ vHGV + "!", 41.56401568399580, lHGV, MatsimTestUtils.EPSILON); double dV = RLS90NoiseEmission.calculateGeschwindigkeitskorrekturDv(vCar, vHGV, p); Assert.assertEquals("Wrong Dv!", -7.689390421466860, dV, MatsimTestUtils.EPSILON); - + double emission = mittelungspegel + dV; Assert.assertEquals("Wrong emission!", 61.5362841118986, emission, MatsimTestUtils.EPSILON); - + // plus one car - + int nPlusOneCar = (nCar+1 + nHGV) * 10; - double pPlusOneCar = ( (double) nHGV / (double) ((nCar + 1) + nHGV)); + double pPlusOneCar = ( (double) nHGV / (double) ((nCar + 1) + nHGV)); double mittelungspegelPlusOneCar = RLS90NoiseEmission.calculateMittelungspegelLm(nPlusOneCar, pPlusOneCar); double dVPlusOneCar = RLS90NoiseEmission.calculateGeschwindigkeitskorrekturDv(vCar, vHGV, pPlusOneCar); double emissionPlusOneCar = mittelungspegelPlusOneCar + dVPlusOneCar; Assert.assertEquals("Wrong emission!", 61.5580658162266, emissionPlusOneCar, MatsimTestUtils.EPSILON); - + // plus one HGV - + int nPlusOneHGV = (nCar + nHGV + 1) * 10; - double pPlusOneHGV = ( (double) (nHGV + 1) / (double) (nCar + (nHGV + 1))); + double pPlusOneHGV = ( (double) (nHGV + 1) / (double) (nCar + (nHGV + 1))); double mittelungspegelPlusOneHGV = RLS90NoiseEmission.calculateMittelungspegelLm(nPlusOneHGV, pPlusOneHGV); double dVPlusOneHGV = RLS90NoiseEmission.calculateGeschwindigkeitskorrekturDv(vCar, vHGV, pPlusOneHGV); double emissionPlusOneHGV = mittelungspegelPlusOneHGV + dVPlusOneHGV; - Assert.assertEquals("Wrong emission!", 61.9518310976080, emissionPlusOneHGV, MatsimTestUtils.EPSILON); + Assert.assertEquals("Wrong emission!", 61.9518310976080, emissionPlusOneHGV, MatsimTestUtils.EPSILON); } } diff --git a/contribs/otfvis/src/main/java/org/matsim/contrib/otfvis/OTFVisFileWriterModule.java b/contribs/otfvis/src/main/java/org/matsim/contrib/otfvis/OTFVisFileWriterModule.java index 0475b256630..0d4ca15b752 100644 --- a/contribs/otfvis/src/main/java/org/matsim/contrib/otfvis/OTFVisFileWriterModule.java +++ b/contribs/otfvis/src/main/java/org/matsim/contrib/otfvis/OTFVisFileWriterModule.java @@ -23,12 +23,11 @@ package org.matsim.contrib.otfvis; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.ControlerConfigGroup; import org.matsim.core.controler.AbstractModule; import org.matsim.vis.otfvis.OTFFileWriterFactory; import org.matsim.vis.otfvis.OTFVisConfigGroup; -import static org.matsim.core.config.groups.ControlerConfigGroup.*; +import static org.matsim.core.config.groups.ControllerConfigGroup.*; public class OTFVisFileWriterModule extends AbstractModule { @Override diff --git a/contribs/otfvis/src/test/java/org/matsim/contrib/otfvis/OTFVisIT.java b/contribs/otfvis/src/test/java/org/matsim/contrib/otfvis/OTFVisIT.java index e178622e938..5675aa0a980 100644 --- a/contribs/otfvis/src/test/java/org/matsim/contrib/otfvis/OTFVisIT.java +++ b/contribs/otfvis/src/test/java/org/matsim/contrib/otfvis/OTFVisIT.java @@ -19,7 +19,7 @@ * *********************************************************************** */ /** - * + * */ package org.matsim.contrib.otfvis; @@ -28,7 +28,6 @@ import org.junit.Test; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.ControlerConfigGroup; import org.matsim.core.config.groups.QSimConfigGroup; import org.matsim.core.config.groups.QSimConfigGroup.SnapshotStyle; import org.matsim.core.controler.Controler; @@ -36,17 +35,16 @@ import org.matsim.testcases.MatsimTestUtils; import java.io.File; -import java.util.Arrays; import java.util.Collections; -import static org.matsim.core.config.groups.ControlerConfigGroup.*; +import static org.matsim.core.config.groups.ControllerConfigGroup.*; /** * Simple test case to ensure the converting from eventsfile to .mvi-file * Needs somehow a bunch of memory - please use "-Xmx630m"! - * + * * @author yu - * + * */ public class OTFVisIT { diff --git a/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingproxy/run/RunWithParkingProxy.java b/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingproxy/run/RunWithParkingProxy.java index 0f243e6e035..0239f36bd11 100644 --- a/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingproxy/run/RunWithParkingProxy.java +++ b/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingproxy/run/RunWithParkingProxy.java @@ -22,7 +22,7 @@ import org.matsim.contrib.parking.parkingproxy.ParkingProxyModule; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.PlansCalcRouteConfigGroup.AccessEgressType; +import org.matsim.core.config.groups.RoutingConfigGroup.AccessEgressType; import org.matsim.core.controler.Controler; import org.matsim.core.controler.OutputDirectoryHierarchy.OverwriteFileSetting; import org.matsim.core.scenario.ScenarioUtils; @@ -31,7 +31,7 @@ public class RunWithParkingProxy { public static void main(String[] args) { - + ParkingProxyConfigGroup parkingConfig = new ParkingProxyConfigGroup(); Config config = ConfigUtils.loadConfig(args, parkingConfig); @@ -39,13 +39,13 @@ public static void main(String[] args) { config.controler().setOverwriteFileSetting(OverwriteFileSetting.overwriteExistingFiles); config.plansCalcRoute().setAccessEgressType(AccessEgressType.accessEgressModeToLink); config.planCalcScore().setWriteExperiencedPlans(true); - + Scenario scen = ScenarioUtils.loadScenario(config); - + Controler controler = new Controler(scen); - + controler.addOverridingModule(new ParkingProxyModule(scen) ); - + controler.run(); } diff --git a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/distributed/MasterControler.java b/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/distributed/MasterControler.java index 9e1e85a8450..7883813d134 100644 --- a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/distributed/MasterControler.java +++ b/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/distributed/MasterControler.java @@ -33,7 +33,7 @@ import org.matsim.contrib.pseudosimulation.util.CollectionUtils; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.StrategyConfigGroup; +import org.matsim.core.config.groups.ReplanningConfigGroup; import org.matsim.core.controler.AbstractModule; import org.matsim.core.controler.Controler; import org.matsim.core.controler.MatsimServices; @@ -229,12 +229,12 @@ private void setReplanningWeights(Config config, double masterMutationRate, doub borrowingRate = 0.9999 * borrowingRate / (masterMutationRate + borrowingRate); masterMutationRate = 0.9999 * masterMutationRate / (masterMutationRate + borrowingRate); } - List strategySettings = new ArrayList<>(); + List strategySettings = new ArrayList<>(); strategySettings.addAll(config.strategy().getStrategySettings()); Map selectors = new HashMap<>(); Map mutators = new HashMap<>(); for (int i = 0; i < strategySettings.size(); i++) { - StrategyConfigGroup.StrategySettings setting = strategySettings.get(i); + ReplanningConfigGroup.StrategySettings setting = strategySettings.get(i); if (DistributedPlanStrategyTranslationAndRegistration.SupportedSelectors.keySet().contains(setting.getStrategyName())) selectors.put(i, setting.getWeight()); else { @@ -254,11 +254,11 @@ private void setReplanningWeights(Config config, double masterMutationRate, doub } //put it back in the config config.strategy().clearStrategySettings(); - for (StrategyConfigGroup.StrategySettings strategySetting : strategySettings) { + for (ReplanningConfigGroup.StrategySettings strategySetting : strategySettings) { config.strategy().addStrategySettings(strategySetting); } // add the borrowing rate entry - StrategyConfigGroup.StrategySettings borrowingSetting = new StrategyConfigGroup.StrategySettings(); + ReplanningConfigGroup.StrategySettings borrowingSetting = new ReplanningConfigGroup.StrategySettings(); borrowingSetting.setWeight(borrowingRate); borrowingSetting.setStrategyName("ReplacePlanFromSlave"); borrowingSetting.setDisableAfter(maximumIterationForMutationDisabling > 0 ? maximumIterationForMutationDisabling : disableAfterIteration); diff --git a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/distributed/SlaveControler.java b/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/distributed/SlaveControler.java index a45f80ba4d6..02a8fd67231 100644 --- a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/distributed/SlaveControler.java +++ b/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/distributed/SlaveControler.java @@ -41,7 +41,7 @@ import org.matsim.contrib.pseudosimulation.util.CollectionUtils; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.StrategyConfigGroup; +import org.matsim.core.config.groups.ReplanningConfigGroup; import org.matsim.core.controler.AbstractModule; import org.matsim.core.controler.Controler; import org.matsim.core.controler.OutputDirectoryHierarchy; @@ -630,12 +630,12 @@ public void notifyIterationEnds(IterationEndsEvent event) { private void setReplanningWeights(Config config, double mutationRate) { if (mutationRate > 1) mutationRate = 0.9999; - List strategySettings = new ArrayList<>(); + List strategySettings = new ArrayList<>(); strategySettings.addAll(config.strategy().getStrategySettings()); Map selectors = new HashMap<>(); Map mutators = new HashMap<>(); for (int i = 0; i < strategySettings.size(); i++) { - StrategyConfigGroup.StrategySettings setting = strategySettings.get(i); + ReplanningConfigGroup.StrategySettings setting = strategySettings.get(i); if (DistributedPlanStrategyTranslationAndRegistration.SupportedSelectors.keySet().contains(setting.getStrategyName())) selectors.put(i, setting.getWeight()); else { @@ -654,7 +654,7 @@ private void setReplanningWeights(Config config, double mutationRate) { } //put it back in the config config.strategy().clearStrategySettings(); - for (StrategyConfigGroup.StrategySettings strategySetting : strategySettings) { + for (ReplanningConfigGroup.StrategySettings strategySetting : strategySettings) { config.strategy().addStrategySettings(strategySetting); } } diff --git a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/replanning/DistributedPlanStrategyTranslationAndRegistration.java b/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/replanning/DistributedPlanStrategyTranslationAndRegistration.java index 148ead7b851..4475c332bca 100644 --- a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/replanning/DistributedPlanStrategyTranslationAndRegistration.java +++ b/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/replanning/DistributedPlanStrategyTranslationAndRegistration.java @@ -4,7 +4,7 @@ import org.matsim.contrib.pseudosimulation.replanning.factories.DistributedPlanMutatorStrategyFactory; import org.matsim.contrib.pseudosimulation.replanning.factories.DistributedPlanSelectorStrategyFactory; import org.matsim.core.config.Config; -import org.matsim.core.config.groups.StrategyConfigGroup; +import org.matsim.core.config.groups.ReplanningConfigGroup; import org.matsim.core.controler.AbstractModule; import org.matsim.core.controler.Controler; import org.matsim.core.replanning.PlanStrategy; @@ -115,7 +115,7 @@ public static boolean isStrategySupported(String name) { } public static void substituteStrategies(Config config, boolean quickReplanning, int selectionInflationFactor) { - for (StrategyConfigGroup.StrategySettings settings : config.strategy().getStrategySettings()) { + for (ReplanningConfigGroup.StrategySettings settings : config.strategy().getStrategySettings()) { String classname = settings.getStrategyName(); diff --git a/contribs/pseudosimulation/src/test/java/org/matsim/contrib/pseudosimulation/RunPSimTest.java b/contribs/pseudosimulation/src/test/java/org/matsim/contrib/pseudosimulation/RunPSimTest.java index 994a35e162e..6426412c6eb 100644 --- a/contribs/pseudosimulation/src/test/java/org/matsim/contrib/pseudosimulation/RunPSimTest.java +++ b/contribs/pseudosimulation/src/test/java/org/matsim/contrib/pseudosimulation/RunPSimTest.java @@ -18,8 +18,7 @@ import org.matsim.contrib.pseudosimulation.mobsim.transitperformance.TransitEmulator; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.StrategyConfigGroup; -import org.matsim.core.config.groups.PlansConfigGroup.HandlingOfPlansWithoutRoutingMode; +import org.matsim.core.config.groups.ReplanningConfigGroup; import org.matsim.core.controler.AbstractModule; import org.matsim.core.controler.Controler; import org.matsim.core.controler.MatsimServices; @@ -72,7 +71,7 @@ public void testA() { selectorNames.add( DefaultPlanStrategiesModule.DefaultSelector.SelectExpBeta ); //lower the weight of non-selector strategies, as we will run many iters - for( StrategyConfigGroup.StrategySettings settings : config.strategy().getStrategySettings() ){ + for( ReplanningConfigGroup.StrategySettings settings : config.strategy().getStrategySettings() ){ if( !selectorNames.contains( settings.getStrategyName() ) ){ logger.warn( settings.getStrategyName() ); settings.setWeight( settings.getWeight() * 20 ); diff --git a/contribs/railsim/src/test/java/ch/sbb/matsim/contrib/railsim/integration/SnzActivities.java b/contribs/railsim/src/test/java/ch/sbb/matsim/contrib/railsim/integration/SnzActivities.java index 9c21fd13385..544d770b4bc 100644 --- a/contribs/railsim/src/test/java/ch/sbb/matsim/contrib/railsim/integration/SnzActivities.java +++ b/contribs/railsim/src/test/java/ch/sbb/matsim/contrib/railsim/integration/SnzActivities.java @@ -5,7 +5,7 @@ package ch.sbb.matsim.contrib.railsim.integration; import org.matsim.core.config.Config; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; /** * Defines available activities and open- and closing times in Snz scenarios at vsp. @@ -58,7 +58,7 @@ public enum SnzActivities { /** * Apply start and end time to params. */ - public PlanCalcScoreConfigGroup.ActivityParams apply(PlanCalcScoreConfigGroup.ActivityParams params) { + public ScoringConfigGroup.ActivityParams apply(ScoringConfigGroup.ActivityParams params) { if (start >= 0) params = params.setOpeningTime(start * 3600.); if (end >= 0) @@ -74,18 +74,18 @@ public static void addScoringParams(Config config) { for (SnzActivities value : SnzActivities.values()) { for (long ii = 600; ii <= 97200; ii += 600) { - config.planCalcScore().addActivityParams(value.apply(new PlanCalcScoreConfigGroup.ActivityParams(value.name() + "_" + ii).setTypicalDuration(ii))); + config.planCalcScore().addActivityParams(value.apply(new ScoringConfigGroup.ActivityParams(value.name() + "_" + ii).setTypicalDuration(ii))); } } - config.planCalcScore().addActivityParams(new PlanCalcScoreConfigGroup.ActivityParams("car interaction").setTypicalDuration(60)); - config.planCalcScore().addActivityParams(new PlanCalcScoreConfigGroup.ActivityParams("ride interaction").setTypicalDuration(60)); - config.planCalcScore().addActivityParams(new PlanCalcScoreConfigGroup.ActivityParams("bike interaction").setTypicalDuration(60)); + config.planCalcScore().addActivityParams(new ScoringConfigGroup.ActivityParams("car interaction").setTypicalDuration(60)); + config.planCalcScore().addActivityParams(new ScoringConfigGroup.ActivityParams("ride interaction").setTypicalDuration(60)); + config.planCalcScore().addActivityParams(new ScoringConfigGroup.ActivityParams("bike interaction").setTypicalDuration(60)); - config.planCalcScore().addActivityParams(new PlanCalcScoreConfigGroup.ActivityParams("other").setTypicalDuration(600 * 3)); + config.planCalcScore().addActivityParams(new ScoringConfigGroup.ActivityParams("other").setTypicalDuration(600 * 3)); - config.planCalcScore().addActivityParams(new PlanCalcScoreConfigGroup.ActivityParams("freight_start").setTypicalDuration(60 * 15)); - config.planCalcScore().addActivityParams(new PlanCalcScoreConfigGroup.ActivityParams("freight_end").setTypicalDuration(60 * 15)); + config.planCalcScore().addActivityParams(new ScoringConfigGroup.ActivityParams("freight_start").setTypicalDuration(60 * 15)); + config.planCalcScore().addActivityParams(new ScoringConfigGroup.ActivityParams("freight_end").setTypicalDuration(60 * 15)); } } diff --git a/contribs/roadpricing/src/main/java/org/matsim/contrib/roadpricing/RoadPricingNetworkRouting.java b/contribs/roadpricing/src/main/java/org/matsim/contrib/roadpricing/RoadPricingNetworkRouting.java index cd6a1b1906f..20fa27be345 100644 --- a/contribs/roadpricing/src/main/java/org/matsim/contrib/roadpricing/RoadPricingNetworkRouting.java +++ b/contribs/roadpricing/src/main/java/org/matsim/contrib/roadpricing/RoadPricingNetworkRouting.java @@ -4,8 +4,8 @@ import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Network; import org.matsim.api.core.v01.population.PopulationFactory; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; -import org.matsim.core.config.groups.PlansCalcRouteConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; +import org.matsim.core.config.groups.RoutingConfigGroup; import org.matsim.core.network.NetworkUtils; import org.matsim.core.network.algorithms.TransportModeNetworkFilter; import org.matsim.core.router.DefaultRoutingModules; @@ -48,10 +48,10 @@ class RoadPricingNetworkRouting implements Provider { SingleModeNetworksCache singleModeNetworksCache; @Inject - PlanCalcScoreConfigGroup planCalcScoreConfigGroup; + ScoringConfigGroup scoringConfigGroup; @Inject - PlansCalcRouteConfigGroup plansCalcRouteConfigGroup; + RoutingConfigGroup routingConfigGroup; @Inject Network network; @@ -94,7 +94,7 @@ public RoutingModule get() { filteredNetwork, travelDisutilityFactory.createTravelDisutility(travelTime), travelTime); - if (!plansCalcRouteConfigGroup.getAccessEgressType().equals(PlansCalcRouteConfigGroup.AccessEgressType.none)) { + if (!routingConfigGroup.getAccessEgressType().equals(RoutingConfigGroup.AccessEgressType.none)) { return DefaultRoutingModules.createAccessEgressNetworkRouter(TransportMode.car, routeAlgo, scenario, filteredNetwork, walkRouter, timeInterpretation, multimodalLinkChooser ); } else { diff --git a/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/PlansCalcRouteWithTollOrNotTest.java b/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/PlansCalcRouteWithTollOrNotTest.java index f2d0ed25808..d4ffb4f91fc 100644 --- a/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/PlansCalcRouteWithTollOrNotTest.java +++ b/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/PlansCalcRouteWithTollOrNotTest.java @@ -36,7 +36,7 @@ import org.matsim.api.core.v01.population.PlanElement; import org.matsim.api.core.v01.population.Population; import org.matsim.core.config.Config; -import org.matsim.core.config.groups.PlansCalcRouteConfigGroup.AccessEgressType; +import org.matsim.core.config.groups.RoutingConfigGroup.AccessEgressType; import org.matsim.core.controler.Injector; import org.matsim.core.controler.NewControlerModule; import org.matsim.core.controler.OutputDirectoryHierarchy; @@ -68,7 +68,7 @@ public class PlansCalcRouteWithTollOrNotTest { public MatsimTestUtils matsimTestUtils = new MatsimTestUtils(); /** - * Tests a few cases where the router can decide if it is better to pay the + * Tests a few cases where the router can decide if it is better to pay the * toll or not. */ @Test @@ -163,11 +163,11 @@ private PlansCalcRouteWithTollOrNot testee(final Scenario scenario, final RoadPr // new ControlerDefaultCoreListenersModule(), // new NewControlerModule()) // .getInstance(PlansCalcRouteWithTollOrNot.class); - + Provider tripRouterProvider = Injector.createInjector(scenario.getConfig(), - new RoadPricingModuleDefaults(toll), + new RoadPricingModuleDefaults(toll), new ScenarioByInstanceModule(scenario), - new ControlerDefaultCoreListenersModule(), + new ControlerDefaultCoreListenersModule(), new NewControlerModule()).getProvider(TripRouter.class); return new PlansCalcRouteWithTollOrNot( toll, tripRouterProvider, TimeInterpretation.create(scenario.getConfig()) ) ; diff --git a/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/TollTravelCostCalculatorTest.java b/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/TollTravelCostCalculatorTest.java index 4e90d000787..b8b3f9acee6 100644 --- a/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/TollTravelCostCalculatorTest.java +++ b/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/TollTravelCostCalculatorTest.java @@ -42,7 +42,7 @@ import org.matsim.contrib.roadpricing.RoadPricingSchemeImpl.Cost; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.PlansCalcRouteConfigGroup; +import org.matsim.core.config.groups.RoutingConfigGroup; import org.matsim.core.controler.ControlerDefaults; import org.matsim.core.population.algorithms.PersonAlgorithm; import org.matsim.core.population.routes.NetworkRoute; @@ -147,7 +147,7 @@ public void testDistanceTollRouter() { commonRouterData.run(network); int carLegIndex = 1 ; - if ( !config.plansCalcRoute().getAccessEgressType().equals(PlansCalcRouteConfigGroup.AccessEgressType.none) ) { + if ( !config.plansCalcRoute().getAccessEgressType().equals(RoutingConfigGroup.AccessEgressType.none) ) { carLegIndex = 3 ; } @@ -229,7 +229,7 @@ public void testLinkTollRouter() { commonRouterData.run(network); int carLegIndex = 1 ; - if (! config.plansCalcRoute().getAccessEgressType().equals(PlansCalcRouteConfigGroup.AccessEgressType.none) ) { + if (! config.plansCalcRoute().getAccessEgressType().equals(RoutingConfigGroup.AccessEgressType.none) ) { carLegIndex = 3 ; } @@ -322,7 +322,7 @@ public void testCordonTollRouter() { AStarLandmarksFactory routerFactory = new AStarLandmarksFactory(2); int carLegIndex = 1 ; - if ( !config.plansCalcRoute().getAccessEgressType().equals(PlansCalcRouteConfigGroup.AccessEgressType.none) ) { + if ( !config.plansCalcRoute().getAccessEgressType().equals(RoutingConfigGroup.AccessEgressType.none) ) { carLegIndex = 3 ; } diff --git a/contribs/shared_mobility/src/main/java/org/matsim/contrib/shared_mobility/examples/RunCarsharing.java b/contribs/shared_mobility/src/main/java/org/matsim/contrib/shared_mobility/examples/RunCarsharing.java index 114870703bf..0c5a2951b08 100644 --- a/contribs/shared_mobility/src/main/java/org/matsim/contrib/shared_mobility/examples/RunCarsharing.java +++ b/contribs/shared_mobility/src/main/java/org/matsim/contrib/shared_mobility/examples/RunCarsharing.java @@ -13,11 +13,11 @@ import org.matsim.core.config.CommandLine.ConfigurationException; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup.ActivityParams; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup.ModeParams; +import org.matsim.core.config.groups.ScoringConfigGroup.ActivityParams; +import org.matsim.core.config.groups.ScoringConfigGroup.ModeParams; import org.matsim.core.controler.Controler; /** - * + * * This is an example of a station-based oneway car-sharing service * siouxfalls-2014 can be used to run the simulation with the provided example * input file in the resources/example * @@ -66,7 +66,7 @@ static public void main(String[] args) throws ConfigurationException { ActivityParams dropoffParams = new ActivityParams(SharingUtils.DROPOFF_ACTIVITY); dropoffParams.setScoringThisActivityAtAll(false); config.planCalcScore().addActivityParams(dropoffParams); - + ActivityParams bookingParams = new ActivityParams(SharingUtils.BOOKING_ACTIVITY); bookingParams.setScoringThisActivityAtAll(false); config.planCalcScore().addActivityParams(bookingParams); diff --git a/contribs/shared_mobility/src/main/java/org/matsim/contrib/shared_mobility/examples/RunParisVelib.java b/contribs/shared_mobility/src/main/java/org/matsim/contrib/shared_mobility/examples/RunParisVelib.java index f5625e1445d..d095a453139 100644 --- a/contribs/shared_mobility/src/main/java/org/matsim/contrib/shared_mobility/examples/RunParisVelib.java +++ b/contribs/shared_mobility/src/main/java/org/matsim/contrib/shared_mobility/examples/RunParisVelib.java @@ -13,8 +13,8 @@ import org.matsim.core.config.CommandLine.ConfigurationException; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup.ActivityParams; -import org.matsim.core.config.groups.StrategyConfigGroup.StrategySettings; +import org.matsim.core.config.groups.ScoringConfigGroup.ActivityParams; +import org.matsim.core.config.groups.ReplanningConfigGroup.StrategySettings; import org.matsim.core.controler.Controler; public class RunParisVelib { diff --git a/contribs/shared_mobility/src/main/java/org/matsim/contrib/shared_mobility/examples/RunTeleportationBikesharing.java b/contribs/shared_mobility/src/main/java/org/matsim/contrib/shared_mobility/examples/RunTeleportationBikesharing.java index 7d1c01f0ec1..d772f1581f0 100644 --- a/contribs/shared_mobility/src/main/java/org/matsim/contrib/shared_mobility/examples/RunTeleportationBikesharing.java +++ b/contribs/shared_mobility/src/main/java/org/matsim/contrib/shared_mobility/examples/RunTeleportationBikesharing.java @@ -13,9 +13,9 @@ import org.matsim.core.config.CommandLine.ConfigurationException; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup.ActivityParams; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup.ModeParams; -import org.matsim.core.config.groups.PlansCalcRouteConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup.ActivityParams; +import org.matsim.core.config.groups.ScoringConfigGroup.ModeParams; +import org.matsim.core.config.groups.RoutingConfigGroup; import org.matsim.core.controler.Controler; /** @@ -34,13 +34,13 @@ static public void main(String[] args) throws ConfigurationException { Config config = ConfigUtils.loadConfig(cmd.getOptionStrict("config-path")); // We define bike to be routed based on Euclidean distance. - PlansCalcRouteConfigGroup.TeleportedModeParams bikeRoutingParams = new PlansCalcRouteConfigGroup.TeleportedModeParams("bike"); + RoutingConfigGroup.TeleportedModeParams bikeRoutingParams = new RoutingConfigGroup.TeleportedModeParams("bike"); bikeRoutingParams.setTeleportedModeSpeed(5.0); bikeRoutingParams.setBeelineDistanceFactor(1.3); config.plansCalcRoute().addTeleportedModeParams(bikeRoutingParams); // Walk is deleted by adding bike here, we need to re-add it ... - PlansCalcRouteConfigGroup.TeleportedModeParams walkRoutingParams = new PlansCalcRouteConfigGroup.TeleportedModeParams("walk"); + RoutingConfigGroup.TeleportedModeParams walkRoutingParams = new RoutingConfigGroup.TeleportedModeParams("walk"); walkRoutingParams.setTeleportedModeSpeed(2.0); walkRoutingParams.setBeelineDistanceFactor(1.3); config.plansCalcRoute().addTeleportedModeParams(walkRoutingParams); diff --git a/contribs/shared_mobility/src/test/java/org/matsim/contrib/shared_mobility/RunIT.java b/contribs/shared_mobility/src/test/java/org/matsim/contrib/shared_mobility/RunIT.java index a7279182dc9..6200a54e88c 100644 --- a/contribs/shared_mobility/src/test/java/org/matsim/contrib/shared_mobility/RunIT.java +++ b/contribs/shared_mobility/src/test/java/org/matsim/contrib/shared_mobility/RunIT.java @@ -26,8 +26,8 @@ import org.matsim.core.config.Config; import org.matsim.core.config.ConfigGroup; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup.ActivityParams; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup.ModeParams; +import org.matsim.core.config.groups.ScoringConfigGroup.ActivityParams; +import org.matsim.core.config.groups.ScoringConfigGroup.ModeParams; import org.matsim.core.controler.Controler; import org.matsim.core.controler.OutputDirectoryHierarchy.OverwriteFileSetting; import org.matsim.core.events.EventsUtils; diff --git a/contribs/signals/src/main/java/org/matsim/codeexamples/simpleResponsiveSignalEngine/RunSimpleResponsiveSignalExample.java b/contribs/signals/src/main/java/org/matsim/codeexamples/simpleResponsiveSignalEngine/RunSimpleResponsiveSignalExample.java index 02859e2a582..a0b08f2895d 100644 --- a/contribs/signals/src/main/java/org/matsim/codeexamples/simpleResponsiveSignalEngine/RunSimpleResponsiveSignalExample.java +++ b/contribs/signals/src/main/java/org/matsim/codeexamples/simpleResponsiveSignalEngine/RunSimpleResponsiveSignalExample.java @@ -55,8 +55,8 @@ import org.matsim.contrib.signals.utils.SignalUtils; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup.ActivityParams; -import org.matsim.core.config.groups.StrategyConfigGroup.StrategySettings; +import org.matsim.core.config.groups.ScoringConfigGroup.ActivityParams; +import org.matsim.core.config.groups.ReplanningConfigGroup.StrategySettings; import org.matsim.core.controler.Controler; import org.matsim.core.controler.OutputDirectoryHierarchy.OverwriteFileSetting; import org.matsim.core.replanning.strategies.DefaultPlanStrategiesModule.DefaultSelector; @@ -64,12 +64,12 @@ /** * Creates a simple one-crossing-scenario and starts it with the simple responsive signal from this package. - * + * * @author tthunig * */ public class RunSimpleResponsiveSignalExample { - + private final Controler controler; public static void main(String[] args) { @@ -81,12 +81,12 @@ public RunSimpleResponsiveSignalExample() { final Scenario scenario = defineScenario(config); controler = new Controler(scenario); - /* the signals extensions works for planbased, sylvia and laemmer signal controller + /* the signals extensions works for planbased, sylvia and laemmer signal controller * by default and is pluggable for your own signal controller like this: */ new Configurator(controler).addSignalControllerFactory(SimpleResponsiveSignal.IDENTIFIER, SimpleResponsiveSignal.SimpleResponsiveSignalFactory.class); } - + public void run(){ controler.run(); } @@ -108,7 +108,7 @@ private static Scenario defineScenario(Config config) { } /** creates a network like this: - * + * * 6 * ^ * | @@ -125,14 +125,14 @@ private static Scenario defineScenario(Config config) { * ^ * | * v - * 9 - * + * 9 + * * @param scenario */ private static void createNetwork(Scenario scenario) { Network net = scenario.getNetwork(); NetworkFactory fac = net.getFactory(); - + net.addNode(fac.createNode(Id.createNodeId(1), new Coord(-2000, 0))); net.addNode(fac.createNode(Id.createNodeId(2), new Coord(-1000, 0))); net.addNode(fac.createNode(Id.createNodeId(3), new Coord(0, 0))); @@ -142,15 +142,15 @@ private static void createNetwork(Scenario scenario) { net.addNode(fac.createNode(Id.createNodeId(7), new Coord(0, 1000))); net.addNode(fac.createNode(Id.createNodeId(8), new Coord(0, -1000))); net.addNode(fac.createNode(Id.createNodeId(9), new Coord(0, -2000))); - - String[] links = {"1_2", "2_1", "2_3", "3_2", "3_4", "4_3", "4_5", "5_4", + + String[] links = {"1_2", "2_1", "2_3", "3_2", "3_4", "4_3", "4_5", "5_4", "6_7", "7_6", "7_3", "3_7", "3_8", "8_3", "8_9", "9_8"}; - + for (String linkId : links){ String fromNodeId = linkId.split("_")[0]; String toNodeId = linkId.split("_")[1]; - Link link = fac.createLink(Id.createLinkId(linkId), - net.getNodes().get(Id.createNodeId(fromNodeId)), + Link link = fac.createLink(Id.createLinkId(linkId), + net.getNodes().get(Id.createNodeId(fromNodeId)), net.getNodes().get(Id.createNodeId(toNodeId))); link.setCapacity(7200); link.setLength(1000); @@ -161,32 +161,32 @@ private static void createNetwork(Scenario scenario) { private static void createPopulation(Scenario scenario) { Population population = scenario.getPopulation(); - + String[] odRelations = {"1_2-4_5", "4_5-2_1", "6_7-8_9", "9_8-7_6"}; - + for (String od : odRelations) { String fromLinkId = od.split("-")[0]; String toLinkId = od.split("-")[1]; - + for (int i = 0; i < 3600; i++) { // create a person Person person = population.getFactory().createPerson(Id.createPersonId(od + "-" + i)); population.addPerson(person); - + // create a plan for the person that contains all this // information Plan plan = population.getFactory().createPlan(); person.addPlan(plan); - + // create a start activity at the from link Activity startAct = population.getFactory().createActivityFromLinkId("dummy", Id.createLinkId(fromLinkId)); // distribute agents uniformly during one hour. startAct.setEndTime(i); plan.addActivity(startAct); - + // create a dummy leg plan.addLeg(population.getFactory().createLeg(TransportMode.car)); - + // create a drain activity at the to link Activity drainAct = population.getFactory().createActivityFromLinkId("dummy", Id.createLinkId(toLinkId)); plan.addActivity(drainAct); @@ -201,19 +201,19 @@ private static void createSignals(Scenario scenario) { SignalGroupsData signalGroups = signalsData.getSignalGroupsData(); SignalControlData signalControl = signalsData.getSignalControlData(); SignalControlDataFactory conFac = new SignalControlDataFactoryImpl(); - + // create signal system Id signalSystemId = Id.create("SignalSystem1", SignalSystem.class); SignalSystemData signalSystem = sysFac.createSignalSystemData(signalSystemId); signalSystems.addSignalSystemData(signalSystem); - + // create a signal for every inLink for (Id inLinkId : scenario.getNetwork().getNodes().get(Id.createNodeId(3)).getInLinks().keySet()) { SignalData signal = sysFac.createSignalData(Id.create("Signal" + inLinkId, Signal.class)); signalSystem.addSignalData(signal); signal.setLinkId(inLinkId); } - + // group signals with non conflicting streams Id signalGroupId1 = Id.create("SignalGroup1", SignalGroup.class); SignalGroupData signalGroup1 = signalGroups.getFactory() @@ -221,23 +221,23 @@ private static void createSignals(Scenario scenario) { signalGroup1.addSignalId(Id.create("Signal2_3", Signal.class)); signalGroup1.addSignalId(Id.create("Signal4_3", Signal.class)); signalGroups.addSignalGroupData(signalGroup1); - + Id signalGroupId2 = Id.create("SignalGroup2", SignalGroup.class); SignalGroupData signalGroup2 = signalGroups.getFactory() .createSignalGroupData(signalSystemId, signalGroupId2); signalGroup2.addSignalId(Id.create("Signal7_3", Signal.class)); signalGroup2.addSignalId(Id.create("Signal8_3", Signal.class)); signalGroups.addSignalGroupData(signalGroup2); - + // create the signal control SignalSystemControllerData signalSystemControl = conFac.createSignalSystemControllerData(signalSystemId); signalSystemControl.setControllerIdentifier(SimpleResponsiveSignal.IDENTIFIER); signalControl.addSignalSystemControllerData(signalSystemControl); - + // create a plan for the signal system (with defined cycle time and offset 0) SignalPlanData signalPlan = SignalUtils.createSignalPlan(conFac, 60, 0, Id.create("SignalPlan1", SignalPlan.class)); signalSystemControl.addSignalPlanData(signalPlan); - + // specify signal group settings for both signal groups signalPlan.addSignalGroupSettings(SignalUtils.createSetting4SignalGroup(conFac, signalGroupId1, 0, 5)); signalPlan.addSignalGroupSettings(SignalUtils.createSetting4SignalGroup(conFac, signalGroupId2, 10, 55)); @@ -253,7 +253,7 @@ private static Config defineConfig() { config.qsim().setStartTime(0); config.qsim().setEndTime(3600 * 5); config.qsim().setUsingFastCapacityUpdate(false); - + SignalSystemsConfigGroup signalConfigGroup = ConfigUtils.addOrGetModule(config, SignalSystemsConfigGroup.GROUP_NAME, SignalSystemsConfigGroup.class); signalConfigGroup.setUseSignalSystems(true); diff --git a/contribs/signals/src/test/java/org/matsim/contrib/signals/builder/Fixture.java b/contribs/signals/src/test/java/org/matsim/contrib/signals/builder/Fixture.java index 5a761cbe2f8..d0318865a4e 100644 --- a/contribs/signals/src/test/java/org/matsim/contrib/signals/builder/Fixture.java +++ b/contribs/signals/src/test/java/org/matsim/contrib/signals/builder/Fixture.java @@ -45,8 +45,8 @@ import org.matsim.contrib.signals.model.SignalSystem; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup.ActivityParams; -import org.matsim.core.config.groups.StrategyConfigGroup.StrategySettings; +import org.matsim.core.config.groups.ScoringConfigGroup.ActivityParams; +import org.matsim.core.config.groups.ReplanningConfigGroup.StrategySettings; import org.matsim.core.controler.OutputDirectoryHierarchy.OverwriteFileSetting; import org.matsim.core.scenario.ScenarioUtils; import org.matsim.lanes.Lane; diff --git a/contribs/signals/src/test/java/org/matsim/contrib/signals/controller/fixedTime/DefaultPlanbasedSignalSystemControllerIT.java b/contribs/signals/src/test/java/org/matsim/contrib/signals/controller/fixedTime/DefaultPlanbasedSignalSystemControllerIT.java index 86e74ce1dba..b6994271e62 100644 --- a/contribs/signals/src/test/java/org/matsim/contrib/signals/controller/fixedTime/DefaultPlanbasedSignalSystemControllerIT.java +++ b/contribs/signals/src/test/java/org/matsim/contrib/signals/controller/fixedTime/DefaultPlanbasedSignalSystemControllerIT.java @@ -61,8 +61,8 @@ import org.matsim.contrib.signals.utils.SignalUtils; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup.ActivityParams; -import org.matsim.core.config.groups.StrategyConfigGroup.StrategySettings; +import org.matsim.core.config.groups.ScoringConfigGroup.ActivityParams; +import org.matsim.core.config.groups.ReplanningConfigGroup.StrategySettings; import org.matsim.core.controler.AbstractModule; import org.matsim.core.controler.Controler; import org.matsim.core.controler.OutputDirectoryHierarchy.OverwriteFileSetting; @@ -73,14 +73,14 @@ /** * Tests fixed-time control, especially for multiple fixed-time plans over a day. - * + * * @author tthunig * */ public class DefaultPlanbasedSignalSystemControllerIT { private static final Logger log = LogManager.getLogger(DefaultPlanbasedSignalSystemControllerIT.class); - + @Rule public MatsimTestUtils testUtils = new MatsimTestUtils(); @@ -89,7 +89,7 @@ public void test2SequentialPlansCompleteDay(){ ScenarioRunner runner = new ScenarioRunner(0.0, 3600*1.0, 3600*1.0, 3600*24.0); runner.setNoSimHours(1); SignalEventAnalyzer signalAnalyzer = runner.run(); - + log.info("First signal event at time " + signalAnalyzer.getFirstSignalEventTime()); log.info("Last start plan event at time " + signalAnalyzer.getLastPlanStartEventTime()); log.info("Number of start plan events " + signalAnalyzer.getNumberOfPlanStartEvents()); @@ -99,19 +99,19 @@ public void test2SequentialPlansCompleteDay(){ log.info("First cycle time after 1am " + signalAnalyzer.getCycleTimeOfFirstCycleInHour(1)); // test time when signal plans are switched on and off Assert.assertEquals("First signal state event unexpected.", 0.0, signalAnalyzer.getFirstSignalEventTime(), MatsimTestUtils.EPSILON); -// Assert.assertEquals("Number of plan start events is wrong.", 2, signalAnalyzer.getNumberOfPlanStartEvents()); -// Assert.assertEquals("Time when last plan starts is wrong.", 3600*1, signalAnalyzer.getLastPlanStartEventTime(), MatsimTestUtils.EPSILON); +// Assert.assertEquals("Number of plan start events is wrong.", 2, signalAnalyzer.getNumberOfPlanStartEvents()); +// Assert.assertEquals("Time when last plan starts is wrong.", 3600*1, signalAnalyzer.getLastPlanStartEventTime(), MatsimTestUtils.EPSILON); Assert.assertNull("There was an unexpected event that switches off signals.", signalAnalyzer.getLastSignalOffEventTime()); - Assert.assertEquals("Number of signal off events is wrong.", 0, signalAnalyzer.getNumberOfOffEvents()); + Assert.assertEquals("Number of signal off events is wrong.", 0, signalAnalyzer.getNumberOfOffEvents()); // test if signal plans are both running Assert.assertEquals("Cycle time of first signal plan wrong.", 120, signalAnalyzer.getCycleTimeOfFirstCycleInHour(0), MatsimTestUtils.EPSILON); Assert.assertEquals("Cycle time of second signal plan wrong.", 60, signalAnalyzer.getCycleTimeOfFirstCycleInHour(1), MatsimTestUtils.EPSILON); } - + @Test public void test2SequentialPlansUncompleteDayEnd(){ SignalEventAnalyzer signalAnalyzer = (new ScenarioRunner(0.0, 3600*1.0, 3600*1.0, 3600*2.0)).run(); - + log.info("First signal event at time " + signalAnalyzer.getFirstSignalEventTime()); log.info("Last start plan event at time " + signalAnalyzer.getLastPlanStartEventTime()); log.info("Number of start plan events " + signalAnalyzer.getNumberOfPlanStartEvents()); @@ -123,9 +123,9 @@ public void test2SequentialPlansUncompleteDayEnd(){ log.info("Number of signal events after 2am " + signalAnalyzer.getNumberOfSignalEventsInHour(2)); // test time when signal plans are switched on and off Assert.assertEquals("First signal state event unexpected.", 0.0, signalAnalyzer.getFirstSignalEventTime(), MatsimTestUtils.EPSILON); -// Assert.assertEquals("Number of plan start events is wrong.", 2, signalAnalyzer.getNumberOfPlanStartEvents()); -// Assert.assertEquals("Time when last plan starts is wrong.", 3600*1, signalAnalyzer.getLastPlanStartEventTime(), MatsimTestUtils.EPSILON); - Assert.assertEquals("Time when signals are finally switched off is wrong.", 3600*2, signalAnalyzer.getLastSignalOffEventTime(), 5 + MatsimTestUtils.EPSILON); +// Assert.assertEquals("Number of plan start events is wrong.", 2, signalAnalyzer.getNumberOfPlanStartEvents()); +// Assert.assertEquals("Time when last plan starts is wrong.", 3600*1, signalAnalyzer.getLastPlanStartEventTime(), MatsimTestUtils.EPSILON); + Assert.assertEquals("Time when signals are finally switched off is wrong.", 3600*2, signalAnalyzer.getLastSignalOffEventTime(), 5 + MatsimTestUtils.EPSILON); /* "5 + " because there is SignalSystemImpl.SWITCH_OFF_SEQUENCE_LENGTH of 5 seconds that is added to each signal plans end time as buffer */ Assert.assertEquals("Number of signal off events is wrong.", 1, signalAnalyzer.getNumberOfOffEvents()); Assert.assertEquals("Signals where unexpectedly switched on after 2am.", 0, signalAnalyzer.getCycleTimeOfFirstCycleInHour(2), MatsimTestUtils.EPSILON); @@ -135,11 +135,11 @@ public void test2SequentialPlansUncompleteDayEnd(){ Assert.assertEquals("Cycle time of first signal plan wrong.", 120, signalAnalyzer.getCycleTimeOfFirstCycleInHour(0), MatsimTestUtils.EPSILON); Assert.assertEquals("Cycle time of second signal plan wrong.", 60, signalAnalyzer.getCycleTimeOfFirstCycleInHour(1), MatsimTestUtils.EPSILON); } - + @Test public void test2SequentialPlansUncompleteDayStart(){ SignalEventAnalyzer signalAnalyzer = (new ScenarioRunner(3600*1.0, 3600*2.0, 3600*2.0, 3600*24.0)).run(); - + log.info("First signal event at time " + signalAnalyzer.getFirstSignalEventTime()); log.info("Last start plan event at time " + signalAnalyzer.getLastPlanStartEventTime()); log.info("Number of start plan events " + signalAnalyzer.getNumberOfPlanStartEvents()); @@ -148,13 +148,13 @@ public void test2SequentialPlansUncompleteDayStart(){ log.info("First cycle time after 0am " + signalAnalyzer.getCycleTimeOfFirstCycleInHour(0)); log.info("First cycle time after 1am " + signalAnalyzer.getCycleTimeOfFirstCycleInHour(1)); log.info("First cycle time after 2am " + signalAnalyzer.getCycleTimeOfFirstCycleInHour(2)); - log.info("Number of signal events between 0am and 1am " + signalAnalyzer.getNumberOfSignalEventsInHour(0)); + log.info("Number of signal events between 0am and 1am " + signalAnalyzer.getNumberOfSignalEventsInHour(0)); // test time when signal plans are switched on and off Assert.assertEquals("First signal state event unexpected.", 3600*1, signalAnalyzer.getFirstSignalEventTime(), MatsimTestUtils.EPSILON); -// Assert.assertEquals("Number of plan start events is wrong.", 2, signalAnalyzer.getNumberOfPlanStartEvents()); -// Assert.assertEquals("Time when last plan starts is wrong.", 3600*2, signalAnalyzer.getLastPlanStartEventTime(), MatsimTestUtils.EPSILON); +// Assert.assertEquals("Number of plan start events is wrong.", 2, signalAnalyzer.getNumberOfPlanStartEvents()); +// Assert.assertEquals("Time when last plan starts is wrong.", 3600*2, signalAnalyzer.getLastPlanStartEventTime(), MatsimTestUtils.EPSILON); Assert.assertNull("There was an unexpected event that switches off signals.", signalAnalyzer.getLastSignalOffEventTime()); - Assert.assertEquals("Number of signal off events is wrong.", 0, signalAnalyzer.getNumberOfOffEvents()); + Assert.assertEquals("Number of signal off events is wrong.", 0, signalAnalyzer.getNumberOfOffEvents()); // test if first hour is simulated correctly without signals Assert.assertEquals("Signals where unexpectedly switched on between 0am and 1am.", 0, signalAnalyzer.getCycleTimeOfFirstCycleInHour(0), MatsimTestUtils.EPSILON); Assert.assertTrue("Signals where unexpectedly switched on between 0am and 1am.", 1 > signalAnalyzer.getNumberOfSignalEventsInHour(0)); @@ -163,13 +163,13 @@ public void test2SequentialPlansUncompleteDayStart(){ Assert.assertEquals("Cycle time of first signal plan wrong.", 120, signalAnalyzer.getCycleTimeOfFirstCycleInHour(1), MatsimTestUtils.EPSILON); Assert.assertEquals("Cycle time of second signal plan wrong.", 60, signalAnalyzer.getCycleTimeOfFirstCycleInHour(2), MatsimTestUtils.EPSILON); } - + @Test public void test2SequentialPlans1SecGap(){ ScenarioRunner runner = new ScenarioRunner(0.0, 3600*1.0, 3600*1.0+1, 3600*24.0); runner.setNoSimHours(1); SignalEventAnalyzer signalAnalyzer = runner.run(); - + log.info("First signal event at time " + signalAnalyzer.getFirstSignalEventTime()); log.info("Last start plan event at time " + signalAnalyzer.getLastPlanStartEventTime()); log.info("Number of start plan events " + signalAnalyzer.getNumberOfPlanStartEvents()); @@ -179,19 +179,19 @@ public void test2SequentialPlans1SecGap(){ log.info("First cycle time after 1am " + signalAnalyzer.getCycleTimeOfFirstCycleInHour(1)); // test time when signal plans are switched on and off Assert.assertEquals("First signal state event unexpected.", 0.0, signalAnalyzer.getFirstSignalEventTime(), MatsimTestUtils.EPSILON); -// Assert.assertEquals("Number of plan start events is wrong.", 2, signalAnalyzer.getNumberOfPlanStartEvents()); -// Assert.assertEquals("Time when last plan starts is wrong.", 3600*1+1, signalAnalyzer.getLastPlanStartEventTime(), MatsimTestUtils.EPSILON); +// Assert.assertEquals("Number of plan start events is wrong.", 2, signalAnalyzer.getNumberOfPlanStartEvents()); +// Assert.assertEquals("Time when last plan starts is wrong.", 3600*1+1, signalAnalyzer.getLastPlanStartEventTime(), MatsimTestUtils.EPSILON); Assert.assertNull("There was an unexpected event that switches off signals.", signalAnalyzer.getLastSignalOffEventTime()); - Assert.assertEquals("Number of signal off events is wrong.", 0, signalAnalyzer.getNumberOfOffEvents()); + Assert.assertEquals("Number of signal off events is wrong.", 0, signalAnalyzer.getNumberOfOffEvents()); // test if signal plans are both running Assert.assertEquals("Cycle time of first signal plan wrong.", 120, signalAnalyzer.getCycleTimeOfFirstCycleInHour(0), MatsimTestUtils.EPSILON); Assert.assertEquals("Cycle time of second signal plan wrong.", 60, signalAnalyzer.getCycleTimeOfFirstCycleInHour(1), MatsimTestUtils.EPSILON); } - + @Test public void test2SequentialPlans1HourGap(){ SignalEventAnalyzer signalAnalyzer = (new ScenarioRunner(3600*0.0, 3600*1.0, 3600*2.0, 3600*24.0)).run(); - + log.info("First signal event at time " + signalAnalyzer.getFirstSignalEventTime()); log.info("Last start plan event at time " + signalAnalyzer.getLastPlanStartEventTime()); log.info("Number of start plan events " + signalAnalyzer.getNumberOfPlanStartEvents()); @@ -203,11 +203,11 @@ public void test2SequentialPlans1HourGap(){ log.info("Number of signal events between 1am and 2am " + signalAnalyzer.getNumberOfSignalEventsInHour(1)); // test time when signal plans are switched on and off Assert.assertEquals("First signal state event unexpected.", 0.0, signalAnalyzer.getFirstSignalEventTime(), MatsimTestUtils.EPSILON); -// Assert.assertEquals("Number of plan start events is wrong.", 2, signalAnalyzer.getNumberOfPlanStartEvents()); -// Assert.assertEquals("Time when last plan starts is wrong.", 3600*2, signalAnalyzer.getLastPlanStartEventTime(), MatsimTestUtils.EPSILON); - Assert.assertEquals("Time when signals are finally switched off is wrong.", 3600*1, signalAnalyzer.getLastSignalOffEventTime(), 5 + MatsimTestUtils.EPSILON); +// Assert.assertEquals("Number of plan start events is wrong.", 2, signalAnalyzer.getNumberOfPlanStartEvents()); +// Assert.assertEquals("Time when last plan starts is wrong.", 3600*2, signalAnalyzer.getLastPlanStartEventTime(), MatsimTestUtils.EPSILON); + Assert.assertEquals("Time when signals are finally switched off is wrong.", 3600*1, signalAnalyzer.getLastSignalOffEventTime(), 5 + MatsimTestUtils.EPSILON); /* "5 + " because there is SignalSystemImpl.SWITCH_OFF_SEQUENCE_LENGTH of 5 seconds that is added to each signal plans end time as buffer */ - Assert.assertEquals("Number of signal off events is wrong.", 1, signalAnalyzer.getNumberOfOffEvents()); + Assert.assertEquals("Number of signal off events is wrong.", 1, signalAnalyzer.getNumberOfOffEvents()); // test if break between signal plans is simulated correctly Assert.assertEquals("Signals where unexpectedly switched on between the signal plans.", 0, signalAnalyzer.getCycleTimeOfFirstCycleInHour(1), MatsimTestUtils.EPSILON); Assert.assertTrue("Signals where unexpectedly switched on between the signal plans.", 3 > signalAnalyzer.getNumberOfSignalEventsInHour(1)); @@ -216,13 +216,13 @@ public void test2SequentialPlans1HourGap(){ Assert.assertEquals("Cycle time of first signal plan wrong.", 120, signalAnalyzer.getCycleTimeOfFirstCycleInHour(0), MatsimTestUtils.EPSILON); Assert.assertEquals("Cycle time of second signal plan wrong.", 60, signalAnalyzer.getCycleTimeOfFirstCycleInHour(2), MatsimTestUtils.EPSILON); } - + @Test public void test2SequentialPlans1HourGap2TimesOff(){ ScenarioRunner runner = new ScenarioRunner(3600*0.0, 3600*1.0, 3600*2.0, 3600*3.0); runner.setNoSimHours(3); SignalEventAnalyzer signalAnalyzer = runner.run(); - + log.info("First signal event at time " + signalAnalyzer.getFirstSignalEventTime()); log.info("Last start plan event at time " + signalAnalyzer.getLastPlanStartEventTime()); log.info("Number of start plan events " + signalAnalyzer.getNumberOfPlanStartEvents()); @@ -238,7 +238,7 @@ public void test2SequentialPlans1HourGap2TimesOff(){ Assert.assertEquals("First signal state event unexpected.", 0.0, signalAnalyzer.getFirstSignalEventTime(), MatsimTestUtils.EPSILON); Assert.assertEquals("Time when signals are finally switched off is wrong.", 3600*3, signalAnalyzer.getLastSignalOffEventTime(), 5 + MatsimTestUtils.EPSILON); /* "5 + " because there is SignalSystemImpl.SWITCH_OFF_SEQUENCE_LENGTH of 5 seconds that is added to each signal plans end time as buffer */ - Assert.assertEquals("Number of signal off events is wrong.", 2, signalAnalyzer.getNumberOfOffEvents()); + Assert.assertEquals("Number of signal off events is wrong.", 2, signalAnalyzer.getNumberOfOffEvents()); Assert.assertEquals("Signals where unexpectedly switched on between the signal plans.", 0, signalAnalyzer.getCycleTimeOfFirstCycleInHour(1), MatsimTestUtils.EPSILON); Assert.assertTrue("Signals where unexpectedly switched on between the signal plans.", 3 > signalAnalyzer.getNumberOfSignalEventsInHour(1)); /* "3 >" because last signal switches of the first plan are allowed at 1am and switch off is only after 5 seconds (in 1:00:05 am) */ @@ -249,11 +249,11 @@ public void test2SequentialPlans1HourGap2TimesOff(){ Assert.assertEquals("Cycle time of first signal plan wrong.", 120, signalAnalyzer.getCycleTimeOfFirstCycleInHour(0), MatsimTestUtils.EPSILON); Assert.assertEquals("Cycle time of second signal plan wrong.", 60, signalAnalyzer.getCycleTimeOfFirstCycleInHour(2), MatsimTestUtils.EPSILON); } - + @Test public void test2SequentialPlansOverMidnight(){ SignalEventAnalyzer signalAnalyzer = (new ScenarioRunner(3600*22.0, 3600*1.0, 3600*1.0, 3600*22.0)).run(); - + log.info("First signal event at time " + signalAnalyzer.getFirstSignalEventTime()); log.info("Last start plan event at time " + signalAnalyzer.getLastPlanStartEventTime()); log.info("Number of start plan events " + signalAnalyzer.getNumberOfPlanStartEvents()); @@ -263,19 +263,19 @@ public void test2SequentialPlansOverMidnight(){ log.info("First cycle time after 1am " + signalAnalyzer.getCycleTimeOfFirstCycleInHour(1)); // test time when signal plans are switched on and off Assert.assertEquals("First signal state event unexpected.", 0.0, signalAnalyzer.getFirstSignalEventTime(), MatsimTestUtils.EPSILON); -// Assert.assertEquals("Number of plan start events is wrong.", 2, signalAnalyzer.getNumberOfPlanStartEvents()); -// Assert.assertEquals("Time when last plan starts is wrong.", 3600*1, signalAnalyzer.getLastPlanStartEventTime(), MatsimTestUtils.EPSILON); +// Assert.assertEquals("Number of plan start events is wrong.", 2, signalAnalyzer.getNumberOfPlanStartEvents()); +// Assert.assertEquals("Time when last plan starts is wrong.", 3600*1, signalAnalyzer.getLastPlanStartEventTime(), MatsimTestUtils.EPSILON); Assert.assertNull("There was an unexpected event that switches off signals.", signalAnalyzer.getLastSignalOffEventTime()); Assert.assertEquals("Number of signal off events is wrong.", 0, signalAnalyzer.getNumberOfOffEvents()); // test if signal plans are both running Assert.assertEquals("Cycle time of first signal plan wrong.", 120, signalAnalyzer.getCycleTimeOfFirstCycleInHour(0), MatsimTestUtils.EPSILON); Assert.assertEquals("Cycle time of second signal plan wrong.", 60, signalAnalyzer.getCycleTimeOfFirstCycleInHour(1), MatsimTestUtils.EPSILON); } - + @Test public void test1SignalPlanUncompleteDay(){ SignalEventAnalyzer signalAnalyzer = (new ScenarioRunner(3600*1.0, 3600*2.0, null, null)).run(); - + log.info("First signal event at time " + signalAnalyzer.getFirstSignalEventTime()); log.info("Last start plan event at time " + signalAnalyzer.getLastPlanStartEventTime()); log.info("Number of start plan events " + signalAnalyzer.getNumberOfPlanStartEvents()); @@ -288,9 +288,9 @@ public void test1SignalPlanUncompleteDay(){ log.info("Number of signal events after 2am " + signalAnalyzer.getNumberOfSignalEventsInHour(2)); // test time when signal plan is switched on and off Assert.assertEquals("First signal state event unexpected.", 3600.0, signalAnalyzer.getFirstSignalEventTime(), MatsimTestUtils.EPSILON); -// Assert.assertEquals("Number of plan start events is wrong.", 1, signalAnalyzer.getNumberOfPlanStartEvents()); -// Assert.assertEquals("Time when last plan starts is wrong.", 3600*1, signalAnalyzer.getLastPlanStartEventTime(), MatsimTestUtils.EPSILON); - Assert.assertEquals("Time when signals are finally switched off is wrong.", 3600*2, signalAnalyzer.getLastSignalOffEventTime(), 5 + MatsimTestUtils.EPSILON); +// Assert.assertEquals("Number of plan start events is wrong.", 1, signalAnalyzer.getNumberOfPlanStartEvents()); +// Assert.assertEquals("Time when last plan starts is wrong.", 3600*1, signalAnalyzer.getLastPlanStartEventTime(), MatsimTestUtils.EPSILON); + Assert.assertEquals("Time when signals are finally switched off is wrong.", 3600*2, signalAnalyzer.getLastSignalOffEventTime(), 5 + MatsimTestUtils.EPSILON); Assert.assertEquals("Number of signal off events is wrong.", 1, signalAnalyzer.getNumberOfOffEvents()); Assert.assertEquals("Signals where unexpectedly switched on before 1am.", 0, signalAnalyzer.getCycleTimeOfFirstCycleInHour(0), MatsimTestUtils.EPSILON); Assert.assertTrue("Signals where unexpectedly switched on before 1am.", 1 > signalAnalyzer.getNumberOfSignalEventsInHour(0)); @@ -300,7 +300,7 @@ public void test1SignalPlanUncompleteDay(){ Assert.assertTrue("Signals where unexpectedly switched on after 2am.", 3 > signalAnalyzer.getNumberOfSignalEventsInHour(2)); /* "3 >" because last signal switches of the first plan are allowed at 2am and switch off is only after 5 seconds (in 2:00:05 am) */ } - + /** * test * 1. one signal plan with default start and end times. should give all day signal plan @@ -311,7 +311,7 @@ public void test1AllDaySignalPlanOverMidnightLateStart(){ ScenarioRunner runner = new ScenarioRunner(null, null, null, null); // i.e. new ScenarioRunner(0.0, 0.0, null, null); runner.setSimStart_h(23); SignalEventAnalyzer signalAnalyzer = runner.run(); - + log.info("First signal event at time " + signalAnalyzer.getFirstSignalEventTime()); log.info("Last start plan event at time " + signalAnalyzer.getLastPlanStartEventTime()); log.info("Number of start plan events " + signalAnalyzer.getNumberOfPlanStartEvents()); @@ -321,15 +321,15 @@ public void test1AllDaySignalPlanOverMidnightLateStart(){ log.info("First cycle time after 0am next day " + signalAnalyzer.getCycleTimeOfFirstCycleInHour(24)); // test time when signal plan is switched on and off Assert.assertEquals("First signal state event unexpected.", 3600*23, signalAnalyzer.getFirstSignalEventTime(), MatsimTestUtils.EPSILON); -// Assert.assertEquals("Number of plan start events is wrong.", 2, signalAnalyzer.getNumberOfPlanStartEvents()); -// Assert.assertEquals("Time when last plan starts is wrong.", 3600*24, signalAnalyzer.getLastPlanStartEventTime(), MatsimTestUtils.EPSILON); +// Assert.assertEquals("Number of plan start events is wrong.", 2, signalAnalyzer.getNumberOfPlanStartEvents()); +// Assert.assertEquals("Time when last plan starts is wrong.", 3600*24, signalAnalyzer.getLastPlanStartEventTime(), MatsimTestUtils.EPSILON); Assert.assertNull("There was an unexpected event that switches off signals.", signalAnalyzer.getLastSignalOffEventTime()); Assert.assertEquals("Number of signal off events is wrong.", 0, signalAnalyzer.getNumberOfOffEvents()); // test if signal plan is running for more than 24h Assert.assertEquals("Signal plan is not active between 11pmam and 12pm.", 120, signalAnalyzer.getCycleTimeOfFirstCycleInHour(23), MatsimTestUtils.EPSILON); Assert.assertEquals("Signal plan is not active anymore after 0am next day.", 120, signalAnalyzer.getCycleTimeOfFirstCycleInHour(24), MatsimTestUtils.EPSILON); } - + /** * test * 1. one signal plan with default start and end times. should give all day signal plan @@ -338,7 +338,7 @@ public void test1AllDaySignalPlanOverMidnightLateStart(){ @Test public void test1AllDaySignalPlanMidnightStart(){ SignalEventAnalyzer signalAnalyzer = (new ScenarioRunner(null, null, null, null)).run(); // i.e. new ScenarioRunner(0.0, 0.0, null, null); - + log.info("First signal event at time " + signalAnalyzer.getFirstSignalEventTime()); log.info("Last start plan event at time " + signalAnalyzer.getLastPlanStartEventTime()); log.info("Number of start plan events " + signalAnalyzer.getNumberOfPlanStartEvents()); @@ -347,20 +347,20 @@ public void test1AllDaySignalPlanMidnightStart(){ log.info("First cycle time after 0am " + signalAnalyzer.getCycleTimeOfFirstCycleInHour(0)); // test time when signal plan is switched on and off Assert.assertEquals("First signal state event unexpected.", 0.0, signalAnalyzer.getFirstSignalEventTime(), MatsimTestUtils.EPSILON); -// Assert.assertEquals("Number of plan start events is wrong.", 1, signalAnalyzer.getNumberOfPlanStartEvents()); -// Assert.assertEquals("Time when last plan starts is wrong.", 0.0, signalAnalyzer.getLastPlanStartEventTime(), MatsimTestUtils.EPSILON); +// Assert.assertEquals("Number of plan start events is wrong.", 1, signalAnalyzer.getNumberOfPlanStartEvents()); +// Assert.assertEquals("Time when last plan starts is wrong.", 0.0, signalAnalyzer.getLastPlanStartEventTime(), MatsimTestUtils.EPSILON); Assert.assertNull("There was an unexpected event that switches off signals.", signalAnalyzer.getLastSignalOffEventTime()); Assert.assertEquals("Number of signal off events is wrong.", 0, signalAnalyzer.getNumberOfOffEvents()); // test if signal plan is running for more than 24h Assert.assertEquals("Signal plan is not active between 0am and 1am.", 120, signalAnalyzer.getCycleTimeOfFirstCycleInHour(0), MatsimTestUtils.EPSILON); } - + @Test public void test2SignalPlanFor25h(){ ScenarioRunner runner = new ScenarioRunner(3600*0.0, 3600*12.0, 3600*12.0, 3600*24.0); runner.setNoSimHours(25); SignalEventAnalyzer signalAnalyzer = runner.run(); - + log.info("First signal event at time " + signalAnalyzer.getFirstSignalEventTime()); log.info("Last start plan event at time " + signalAnalyzer.getLastPlanStartEventTime()); log.info("Number of start plan events " + signalAnalyzer.getNumberOfPlanStartEvents()); @@ -371,8 +371,8 @@ public void test2SignalPlanFor25h(){ log.info("First cycle time after 0am next day " + signalAnalyzer.getCycleTimeOfFirstCycleInHour(24)); // test time when signal plans are switched on and off Assert.assertEquals("First signal state event unexpected.", 0.0, signalAnalyzer.getFirstSignalEventTime(), MatsimTestUtils.EPSILON); -// Assert.assertEquals("Number of plan start events is wrong.", 3, signalAnalyzer.getNumberOfPlanStartEvents()); -// Assert.assertEquals("Time when last plan starts is wrong.", 3600*24, signalAnalyzer.getLastPlanStartEventTime(), MatsimTestUtils.EPSILON); +// Assert.assertEquals("Number of plan start events is wrong.", 3, signalAnalyzer.getNumberOfPlanStartEvents()); +// Assert.assertEquals("Time when last plan starts is wrong.", 3600*24, signalAnalyzer.getLastPlanStartEventTime(), MatsimTestUtils.EPSILON); Assert.assertNull("There was an unexpected event that switches off signals.", signalAnalyzer.getLastSignalOffEventTime()); Assert.assertEquals("Number of signal off events is wrong.", 0, signalAnalyzer.getNumberOfOffEvents()); // test if signal plans are correctly running for more than 24h @@ -380,14 +380,14 @@ public void test2SignalPlanFor25h(){ Assert.assertEquals("Second signal plan is not active between 12am and 1pm.", 60, signalAnalyzer.getCycleTimeOfFirstCycleInHour(12), MatsimTestUtils.EPSILON); Assert.assertEquals("First signal plan is not active again after 0am next day.", 120, signalAnalyzer.getCycleTimeOfFirstCycleInHour(24), MatsimTestUtils.EPSILON); } - + @Test public void testSimStartAfterFirstDayPlan(){ ScenarioRunner runner = new ScenarioRunner(3600*0.0, 3600*1.0, 3600*23.0, 3600*24.0); runner.setSimStart_h(23); runner.setNoSimHours(3); SignalEventAnalyzer signalAnalyzer = runner.run(); - + log.info("First signal event at time " + signalAnalyzer.getFirstSignalEventTime()); log.info("Last start plan event at time " + signalAnalyzer.getLastPlanStartEventTime()); log.info("Number of start plan events " + signalAnalyzer.getNumberOfPlanStartEvents()); @@ -401,9 +401,9 @@ public void testSimStartAfterFirstDayPlan(){ log.info("Number of signal events after 1am next day " + signalAnalyzer.getNumberOfSignalEventsInHour(25)); // test time when signal plans are switched on and off Assert.assertEquals("First signal state event unexpected.", 23*3600, signalAnalyzer.getFirstSignalEventTime(), MatsimTestUtils.EPSILON); -// Assert.assertEquals("Number of plan start events is wrong.", 2, signalAnalyzer.getNumberOfPlanStartEvents()); -// Assert.assertEquals("Time when last plan starts is wrong.", 3600*24, signalAnalyzer.getLastPlanStartEventTime(), MatsimTestUtils.EPSILON); - Assert.assertEquals("Time when signals are finally switched off is wrong.", 3600*25, signalAnalyzer.getLastSignalOffEventTime(), 5 + MatsimTestUtils.EPSILON); +// Assert.assertEquals("Number of plan start events is wrong.", 2, signalAnalyzer.getNumberOfPlanStartEvents()); +// Assert.assertEquals("Time when last plan starts is wrong.", 3600*24, signalAnalyzer.getLastPlanStartEventTime(), MatsimTestUtils.EPSILON); + Assert.assertEquals("Time when signals are finally switched off is wrong.", 3600*25, signalAnalyzer.getLastSignalOffEventTime(), 5 + MatsimTestUtils.EPSILON); Assert.assertEquals("Number of signal off events is wrong.", 1, signalAnalyzer.getNumberOfOffEvents()); Assert.assertEquals("Signals where unexpectedly switched on before 11pm.", 0, signalAnalyzer.getCycleTimeOfFirstCycleInHour(22), MatsimTestUtils.EPSILON); Assert.assertTrue("Signals where unexpectedly switched on before 11pm.", 1 > signalAnalyzer.getNumberOfSignalEventsInHour(22)); @@ -413,7 +413,7 @@ public void testSimStartAfterFirstDayPlan(){ Assert.assertEquals("Second signal plan is not active between 11pm and 12pm.", 60, signalAnalyzer.getCycleTimeOfFirstCycleInHour(23), MatsimTestUtils.EPSILON); Assert.assertEquals("First signal plan is not active between 0am and 1pm next day.", 120, signalAnalyzer.getCycleTimeOfFirstCycleInHour(24), MatsimTestUtils.EPSILON); } - + /** * tests: * 1. overlapping signal plans (uncomplete day) result in an exception @@ -421,7 +421,7 @@ public void testSimStartAfterFirstDayPlan(){ @Test public void test2PlansSameTimesUncompleteDay(){ final String exceptionMessageOverlapping21 = "Signal plans SignalPlan2 and SignalPlan1 of signal system SignalSystem-3 overlap."; - + try{ (new ScenarioRunner(0.0, 1.0, 0.0, 1.0)).run(); Assert.fail("The simulation has not stopped with an exception although the signal plans overlap."); @@ -430,7 +430,7 @@ public void test2PlansSameTimesUncompleteDay(){ Assert.assertEquals("Wrong exception message.", exceptionMessageOverlapping21, e.getMessage()); } } - + /** * tests: * 1. overlapping signal plans (complete day) result in an exception @@ -439,7 +439,7 @@ public void test2PlansSameTimesUncompleteDay(){ public void test2PlansSameTimesCompleteDay(){ final String exceptionMessageHoleDay = "Signal system SignalSystem-3 has multiple plans but at least one of them covers the hole day. " + "If multiple signal plans are used, they are not allowed to overlap."; - + try{ (new ScenarioRunner(0.0, 0.0, 0.0, 0.0)).run(); // (new ScenarioRunner(1.0, 1.0, 1.0, 1.0)).run(); // alternativ. produces same results @@ -449,11 +449,11 @@ public void test2PlansSameTimesCompleteDay(){ Assert.assertEquals("Wrong exception message.", exceptionMessageHoleDay, e.getMessage()); } } - + @Test public void test2OverlappingPlans(){ final String exceptionMessageOverlapping12 = "Signal plans SignalPlan1 and SignalPlan2 of signal system SignalSystem-3 overlap."; - + try{ (new ScenarioRunner(0.0, 2.0, 1.0, 3.0)).run(); Assert.fail("The simulation has not stopped with an exception although the signal plans overlap."); @@ -462,83 +462,83 @@ public void test2OverlappingPlans(){ Assert.assertEquals("Wrong exception message.", exceptionMessageOverlapping12, e.getMessage()); } } - + @Test public void testNegativeOffset() { //plan1 is valid all day ScenarioRunner sr = new ScenarioRunner(0.0, 0.0, null, null); int offset1 = -3; - - sr.setOffsetPlan1(offset1); + + sr.setOffsetPlan1(offset1); SignalEventAnalyzer signalAnalyzer = sr.run(); // in this case, the first event should be a RED-switch at second 57 - log.info("Offset " + offset1 + " leads to the first signal event at second: " + signalAnalyzer.getFirstSignalEventTime()); + log.info("Offset " + offset1 + " leads to the first signal event at second: " + signalAnalyzer.getFirstSignalEventTime()); Assert.assertEquals("The first signal event should be at the first second after simulation start corresponding to offset, " - + "cycle time and plan start time. Also if the offset is negative!", 60+offset1 , signalAnalyzer.getFirstSignalEventTime() , MatsimTestUtils.EPSILON); + + "cycle time and plan start time. Also if the offset is negative!", 60+offset1 , signalAnalyzer.getFirstSignalEventTime() , MatsimTestUtils.EPSILON); } - + @Test public void testNegativeOffsetEqualCycleTime() { //plan1 is valid all day ScenarioRunner sr = new ScenarioRunner(0.0, 0.0, null, null); int offset1 = -120; - - sr.setOffsetPlan1(offset1); + + sr.setOffsetPlan1(offset1); SignalEventAnalyzer signalAnalyzer = sr.run(); - + // in this case, the first event should be a GREEN-switch at second 0 - log.info("Offset " + offset1 + " leads to the first signal event at second: " + signalAnalyzer.getFirstSignalEventTime()); + log.info("Offset " + offset1 + " leads to the first signal event at second: " + signalAnalyzer.getFirstSignalEventTime()); Assert.assertEquals("The first signal event should be at the first second after simulation start corresponding to offset, " - + "cycle time and plan start time. Also if the offset is negative!", 120+offset1 , signalAnalyzer.getFirstSignalEventTime() , MatsimTestUtils.EPSILON); + + "cycle time and plan start time. Also if the offset is negative!", 120+offset1 , signalAnalyzer.getFirstSignalEventTime() , MatsimTestUtils.EPSILON); } - + @Test public void testTwoPlansWithNegativeOffsets(){ ScenarioRunner sr = new ScenarioRunner(0.0*3600, 1.0*3600, 1.0*3600, 2.*3600 ); - + int offset1 = -3; int offset2 = -5; - + sr.setOffsetPlan1(offset1); sr.setOffsetPlan2(offset2); - + //Simulation starts 1h late int simStart_s = 3600; sr.setSimStart_h(simStart_s/3600); - + SignalEventAnalyzer signalAnalyzer = sr.run(); - + // in this case, the first event should be a RED-switch at second 3625 log.info("Offsets " + offset1 + " and " + offset2 + " with a simulation start at second " + simStart_s + " lead to the first signal event at second: " + signalAnalyzer.getFirstSignalEventTime()); Assert.assertEquals("The first signal event should be at the first second after simulation start corresponding to offset, " - + "cycle time and plan start time. Also if the offset is negative!", simStart_s+30+offset2 , signalAnalyzer.getFirstSignalEventTime() , MatsimTestUtils.EPSILON); + + "cycle time and plan start time. Also if the offset is negative!", simStart_s+30+offset2 , signalAnalyzer.getFirstSignalEventTime() , MatsimTestUtils.EPSILON); } - + @Test public void testTwoPlansWithNegativeOffsetsEqualCycleTime(){ ScenarioRunner sr = new ScenarioRunner(0.0*3600, 1.0*3600, 1.0*3600, 2.*3600 ); - + int offset1 = -3; int offset2 = -60; - + sr.setOffsetPlan1(offset1); sr.setOffsetPlan2(offset2); - + //Simulation starts 1h late int simStart_s = 3600; sr.setSimStart_h(simStart_s/3600); - + SignalEventAnalyzer signalAnalyzer = sr.run(); - + // in this case, the first event should be a GREEN-switch at second 3600 log.info("Offsets " + offset1 + " and " + offset2 + " with a simulation start at second " + simStart_s + " lead to the first signal event at second: " + signalAnalyzer.getFirstSignalEventTime()); Assert.assertEquals("The first signal event should be at the first second after simulation start corresponding to offset, " - + "cycle time and plan start time. Also if the offset is negative!", simStart_s+60+offset2 , signalAnalyzer.getFirstSignalEventTime() , MatsimTestUtils.EPSILON); + + "cycle time and plan start time. Also if the offset is negative!", simStart_s+60+offset2 , signalAnalyzer.getFirstSignalEventTime() , MatsimTestUtils.EPSILON); } - + private class ScenarioRunner{ - + private Double plan1StartTime; private Double plan1EndTime; private Double plan2StartTime; @@ -547,11 +547,11 @@ private class ScenarioRunner{ private int simStart_h= 0; private int offsetPlan1 = 0; private int offsetPlan2 = 0; - + private Scenario scenario; - + /** - * Create a scenario with two signal plans with given start end end times. + * Create a scenario with two signal plans with given start end end times. * If start and end times of second signal plan are null, only one signal plan is created. */ /* package */ ScenarioRunner(Double plan1StartTime, Double plan1EndTime, Double plan2StartTime, Double plan2EndTime) { @@ -560,78 +560,78 @@ private class ScenarioRunner{ this.plan2StartTime = plan2StartTime; this.plan2EndTime = plan2EndTime; } - + /* package */ void setNoSimHours(int hours) { this.noSimHours = hours; } - + /* package */ void setSimStart_h(int simStart_h) { this.simStart_h = simStart_h; } - + /* package */ void setOffsetPlan1(int offset) { this.offsetPlan1 = offset; } - + /* package */ void setOffsetPlan2(int offset) { this.offsetPlan2 = offset; } - + /* package */ SignalEventAnalyzer run() { Config config = defineConfig(); - - scenario = ScenarioUtils.loadScenario(config); + + scenario = ScenarioUtils.loadScenario(config); // add missing scenario elements scenario.addScenarioElement(SignalsData.ELEMENT_NAME, new SignalsDataLoader(config).loadSignalsData()); - + createScenarioElements(scenario); - + Controler controler = new Controler(scenario); // add missing modules // controler.addOverridingModule(new SignalsModule()); Signals.configure(controler); - + // add signal analysis tool final SignalEventAnalyzer signalAnalyzer = new SignalEventAnalyzer(); - controler.addOverridingModule(new AbstractModule() { + controler.addOverridingModule(new AbstractModule() { @Override public void install() { this.addEventHandlerBinding().toInstance(signalAnalyzer); } }); - + controler.run(); return signalAnalyzer; } - + private void createScenarioElements(Scenario scenario) { createNetwork(); createPopulation(); createSignals(); } - + /** * Creates a network like this: - * + * * 1 ----> 2 ----> 3 ----> 4 ----> 5 */ private void createNetwork() { Network net = scenario.getNetwork(); NetworkFactory fac = net.getFactory(); - + net.addNode(fac.createNode(Id.createNodeId(1), new Coord(-2000, 0))); net.addNode(fac.createNode(Id.createNodeId(2), new Coord(-1000, 0))); net.addNode(fac.createNode(Id.createNodeId(3), new Coord(0, 0))); net.addNode(fac.createNode(Id.createNodeId(4), new Coord(1000, 0))); net.addNode(fac.createNode(Id.createNodeId(5), new Coord(2000, 0))); - + String[] links = {"1_2", "2_3", "3_4", "4_5"}; - + for (String linkId : links){ String fromNodeId = linkId.split("_")[0]; String toNodeId = linkId.split("_")[1]; - Link link = fac.createLink(Id.createLinkId(linkId), - net.getNodes().get(Id.createNodeId(fromNodeId)), + Link link = fac.createLink(Id.createLinkId(linkId), + net.getNodes().get(Id.createNodeId(fromNodeId)), net.getNodes().get(Id.createNodeId(toNodeId))); link.setCapacity(7200); link.setLength(1000); @@ -641,12 +641,12 @@ private void createNetwork() { } /** - * Creates a dummy population going from left to right + * Creates a dummy population going from left to right * with one agent starting every second. */ private void createPopulation() { Population pop = scenario.getPopulation(); - + // one person every half an hour for (int i = simStart_h*3600; i <= simStart_h*3600 + noSimHours*3600; i+=1800) { // create a person @@ -677,35 +677,35 @@ private void createSignals() { SignalGroupsData signalGroups = signalsData.getSignalGroupsData(); SignalControlData signalControl = signalsData.getSignalControlData(); SignalControlDataFactory conFac = new SignalControlDataFactoryImpl(); - + // create signal system at node 3 Id signalSystemId = Id.create("SignalSystem-3", SignalSystem.class); SignalSystemData signalSystem = sysFac.createSignalSystemData(signalSystemId); signalSystems.addSignalSystemData(signalSystem); - + // create a signal for inLink 2_3 SignalData signal = sysFac.createSignalData(Id.create("Signal-2_3", Signal.class)); signalSystem.addSignalData(signal); signal.setLinkId(Id.createLinkId("2_3")); - + // create an one element group for the signal Id signalGroupId1 = Id.create("SignalGroup-2_3", SignalGroup.class); SignalGroupData signalGroup1 = signalGroups.getFactory().createSignalGroupData(signalSystemId, signalGroupId1); signalGroup1.addSignalId(Id.create("Signal-2_3", Signal.class)); signalGroups.addSignalGroupData(signalGroup1); - + // create the signal control SignalSystemControllerData signalSystemControl = conFac.createSignalSystemControllerData(signalSystemId); signalSystemControl.setControllerIdentifier(DefaultPlanbasedSignalSystemController.IDENTIFIER); signalControl.addSignalSystemControllerData(signalSystemControl); - + // create a first plan for the signal system (with cycle time 120) SignalPlanData signalPlan1 = SignalUtils.createSignalPlan(conFac, 120, offsetPlan1, Id.create("SignalPlan1", SignalPlan.class)); if (plan1StartTime != null) signalPlan1.setStartTime(plan1StartTime); if (plan1EndTime != null) signalPlan1.setEndTime(plan1EndTime); signalSystemControl.addSignalPlanData(signalPlan1); signalPlan1.addSignalGroupSettings(SignalUtils.createSetting4SignalGroup(conFac, signalGroupId1, 0, 60)); - + if (plan2StartTime != null && plan2EndTime != null) { // create a second plan for the signal system (with cycle time 60) if start and end times are not null SignalPlanData signalPlan2 = SignalUtils.createSignalPlan(conFac, 60, offsetPlan2, Id.create("SignalPlan2", SignalPlan.class)); @@ -719,17 +719,17 @@ private void createSignals() { private Config defineConfig() { Config config = ConfigUtils.createConfig(); config.controler().setOutputDirectory(testUtils.getOutputDirectory()); - + // set number of iterations config.controler().setLastIteration(0); - + config.qsim().setStartTime(simStart_h*3600); config.qsim().setUsingFastCapacityUpdate(false); - + // able or enable signals and lanes SignalSystemsConfigGroup signalConfigGroup = ConfigUtils.addOrGetModule(config, SignalSystemsConfigGroup.GROUP_NAME, SignalSystemsConfigGroup.class); signalConfigGroup.setUseSignalSystems( true ); - + // define strategies: { StrategySettings strat = new StrategySettings(); @@ -737,19 +737,19 @@ private Config defineConfig() { strat.setWeight(1); strat.setDisableAfter(config.controler().getLastIteration()); config.strategy().addStrategySettings(strat); - } + } config.qsim().setStuckTime( 3600 ); config.qsim().setRemoveStuckVehicles(false); - + config.controler().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); - + config.vspExperimental().setWritingOutputEvents(false); config.planCalcScore().setWriteExperiencedPlans(false); config.controler().setCreateGraphs(false); config.controler().setDumpDataAtEnd(false); config.controler().setWriteEventsInterval(config.controler().getLastIteration()); config.controler().setWritePlansInterval(config.controler().getLastIteration()); - + // define activity types { ActivityParams dummyAct = new ActivityParams("dummy"); @@ -758,7 +758,7 @@ private Config defineConfig() { } return config; } - + } private class SignalEventAnalyzer implements SignalGroupStateChangedEventHandler{ @@ -770,9 +770,9 @@ private class SignalEventAnalyzer implements SignalGroupStateChangedEventHandler Double firstSignalEventTime = null; double[] cycleTimesOfFirstCyclePerHour = new double[30]; int[] noSignalEventsPerHour = new int[30]; - + Double lastGreenSwitchOfThisCycle = null; - + @Override public void reset(int iteration) { } @@ -784,23 +784,23 @@ public double getCycleTimeOfFirstCycleInHour(int hourOfDay) { public Double getFirstSignalEventTime() { return firstSignalEventTime; } - + public Double getLastSignalOffEventTime() { return lastSignalOffEventTime; } - + public int getNumberOfSignalEventsInHour(int hourOfDay){ return noSignalEventsPerHour[hourOfDay]; } - + public int getNumberOfOffEvents() { return noOffEvents; } - + public Double getLastPlanStartEventTime() { return lastPlanStartEventTime; } - + public int getNumberOfPlanStartEvents() { return noPlanStartEvents; } @@ -810,11 +810,11 @@ public void handleEvent(SignalGroupStateChangedEvent event) { int hourOfDay = (int) (event.getTime() / 3600); // count number of signal events per hour noSignalEventsPerHour[hourOfDay]++; - + if (firstSignalEventTime == null){ firstSignalEventTime = event.getTime(); } - + if (event.getNewState().equals(SignalGroupState.OFF)){ lastSignalOffEventTime = event.getTime(); noOffEvents++; @@ -824,7 +824,7 @@ public void handleEvent(SignalGroupStateChangedEvent event) { noPlanStartEvents++; return; } - + // fill cycle time array if (cycleTimesOfFirstCyclePerHour[hourOfDay] == 0.0){ // first cycle time of this hour not yet determined @@ -840,7 +840,7 @@ public void handleEvent(SignalGroupStateChangedEvent event) { } } } - + } - + } diff --git a/contribs/signals/src/test/java/org/matsim/contrib/signals/controller/laemmerFix/LaemmerIT.java b/contribs/signals/src/test/java/org/matsim/contrib/signals/controller/laemmerFix/LaemmerIT.java index 2dde98241f7..f72b596c231 100644 --- a/contribs/signals/src/test/java/org/matsim/contrib/signals/controller/laemmerFix/LaemmerIT.java +++ b/contribs/signals/src/test/java/org/matsim/contrib/signals/controller/laemmerFix/LaemmerIT.java @@ -46,7 +46,7 @@ import org.matsim.contrib.signals.model.SignalSystem; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.StrategyConfigGroup.StrategySettings; +import org.matsim.core.config.groups.ReplanningConfigGroup.StrategySettings; import org.matsim.core.controler.AbstractModule; import org.matsim.core.controler.Controler; import org.matsim.core.replanning.strategies.DefaultPlanStrategiesModule.DefaultSelector; @@ -66,14 +66,14 @@ public class LaemmerIT { @Rule public MatsimTestUtils testUtils = new MatsimTestUtils(); - + private static final int maxCycleTime = 90; private static final int cycleIntergreenTime = 10; private final Id signalGroupId1 = Id.create("SignalGroup1", SignalGroup.class); private final Id signalGroupId1l = Id.create("SignalGroup1l", SignalGroup.class); private final Id signalGroupId2 = Id.create("SignalGroup2", SignalGroup.class); private final Id signalSystemId = Id.create("SignalSystem1", SignalSystem.class); - + /** * single intersection with demand (equals flow capacity) only in NS-direction. signals should show green only for the NS-direction. */ @@ -89,19 +89,19 @@ public void testSingleCrossingScenarioDemandNS() { Map, Double> avgDelayPerLink = generalAnalyzer.getAvgDelayPerLink(); Double avgDelayWE = avgDelayPerLink.get(Id.createLinkId("2_3")); Double avgDelayNS = avgDelayPerLink.get(Id.createLinkId("7_3")); - + log.info("total signal green times: " + totalSignalGreenTimes.get(signalGroupId1) + ", " + totalSignalGreenTimes.get(signalGroupId2)); log.info("avg signal green times per cycle: " + avgSignalGreenTimePerCycle.get(signalGroupId1) + ", " + avgSignalGreenTimePerCycle.get(signalGroupId2)); log.info("avg cycle time per system: " + avgCycleTimePerSystem.get(signalSystemId)); log.info("avg delay per link: " + avgDelayWE + ", " + avgDelayNS); - + Assert.assertNull("signal group 1 should show no green", avgSignalGreenTimePerCycle.get(signalGroupId1)); Assert.assertNotNull("signal group 2 should show green", avgSignalGreenTimePerCycle.get(signalGroupId2)); Assert.assertEquals("avg delay at NS-direction should be zero", 0.0, avgDelayNS, MatsimTestUtils.EPSILON); } - + /** * Test minimum green time: * single intersection with high demand in WE-direction, very low demand in NS-direction but minimum green time. I.e. the NS-signal should show green for exactly this 5 seconds per cycle. @@ -111,30 +111,30 @@ public void testSingleCrossingScenarioLowVsHighDemandWithMinG(){ Fixture fixture = new Fixture(90, 1800, 5.0, Regime.COMBINED); SignalAnalysisTool signalAnalyzer = new SignalAnalysisTool(); DelayAnalysisTool generalAnalyzer = fixture.run(signalAnalyzer); - - Map, Double> totalSignalGreenTimes = signalAnalyzer.getTotalSignalGreenTime(); - Map, Double> avgSignalGreenTimePerCycle = signalAnalyzer.calculateAvgSignalGreenTimePerFlexibleCycle(); - Map, Double> avgCycleTimePerSystem = signalAnalyzer.calculateAvgFlexibleCycleTimePerSignalSystem(); + + Map, Double> totalSignalGreenTimes = signalAnalyzer.getTotalSignalGreenTime(); + Map, Double> avgSignalGreenTimePerCycle = signalAnalyzer.calculateAvgSignalGreenTimePerFlexibleCycle(); + Map, Double> avgCycleTimePerSystem = signalAnalyzer.calculateAvgFlexibleCycleTimePerSignalSystem(); Map, Double> avgDelayPerLink = generalAnalyzer.getAvgDelayPerLink(); Double avgDelayWE = avgDelayPerLink.get(Id.createLinkId("2_3")); Double avgDelayNS = avgDelayPerLink.get(Id.createLinkId("7_3")); - + log.info("total signal green times: " + totalSignalGreenTimes.get(signalGroupId1) + ", " + totalSignalGreenTimes.get(signalGroupId2)); log.info("avg signal green times per cycle: " + avgSignalGreenTimePerCycle.get(signalGroupId1) + ", " + avgSignalGreenTimePerCycle.get(signalGroupId2)); log.info("avg cycle time per system: " + avgCycleTimePerSystem.get(signalSystemId)); log.info("avg delay per link: " + avgDelayWE + ", " + avgDelayNS); - - Assert.assertTrue("total signal green time of WE-direction should be higher than NS-direction", + + Assert.assertTrue("total signal green time of WE-direction should be higher than NS-direction", totalSignalGreenTimes.get(signalGroupId1)-totalSignalGreenTimes.get(signalGroupId2) > 0); - Assert.assertTrue("avg signal green time per cycle of WE-direction should be higher than NS-direction", + Assert.assertTrue("avg signal green time per cycle of WE-direction should be higher than NS-direction", avgSignalGreenTimePerCycle.get(signalGroupId1)-avgSignalGreenTimePerCycle.get(signalGroupId2) > 0); - Assert.assertEquals("avg signal green time per cycle of NS-direction should be the minimum green time of 5 seconds", + Assert.assertEquals("avg signal green time per cycle of NS-direction should be the minimum green time of 5 seconds", 5.0, avgSignalGreenTimePerCycle.get(signalGroupId2), MatsimTestUtils.EPSILON); Assert.assertTrue("cycle time should stay below 90 seconds", avgCycleTimePerSystem.get(signalSystemId) <= 90); Assert.assertTrue("avg delay per vehicle on WS-direction should be less than on NS-direction", avgDelayWE, Double> totalSignalGreenTimes = signalAnalyzer.getTotalSignalGreenTime(); - Map, Double> avgSignalGreenTimePerCycle = signalAnalyzer.calculateAvgSignalGreenTimePerFlexibleCycle(); - Map, Double> avgCycleTimePerSystem = signalAnalyzer.calculateAvgFlexibleCycleTimePerSignalSystem(); + + Map, Double> totalSignalGreenTimes = signalAnalyzer.getTotalSignalGreenTime(); + Map, Double> avgSignalGreenTimePerCycle = signalAnalyzer.calculateAvgSignalGreenTimePerFlexibleCycle(); + Map, Double> avgCycleTimePerSystem = signalAnalyzer.calculateAvgFlexibleCycleTimePerSignalSystem(); Map, Double> avgDelayPerLink = generalAnalyzer.getAvgDelayPerLink(); Double avgDelayWE = avgDelayPerLink.get(Id.createLinkId("2_3")); Double avgDelayNS = avgDelayPerLink.get(Id.createLinkId("7_3")); - + log.info("total signal green times: " + totalSignalGreenTimes.get(signalGroupId1) + ", " + totalSignalGreenTimes.get(signalGroupId2)); log.info("avg signal green times per cycle: " + avgSignalGreenTimePerCycle.get(signalGroupId1) + ", " + avgSignalGreenTimePerCycle.get(signalGroupId2)); log.info("avg cycle time per system: " + avgCycleTimePerSystem.get(signalSystemId)); log.info("avg delay per link: " + avgDelayWE + ", " + avgDelayNS); - - Assert.assertTrue("total signal green time of WE-direction should be higher than NS-direction", + + Assert.assertTrue("total signal green time of WE-direction should be higher than NS-direction", totalSignalGreenTimes.get(signalGroupId1)-totalSignalGreenTimes.get(signalGroupId2) > 0); - Assert.assertTrue("avg signal green time per cycle of WE-direction should be higher than NS-direction", + Assert.assertTrue("avg signal green time per cycle of WE-direction should be higher than NS-direction", avgSignalGreenTimePerCycle.get(signalGroupId1)-avgSignalGreenTimePerCycle.get(signalGroupId2) > 0); Assert.assertTrue("avg signal green time per cycle of NS-direction should be less than 5 seconds", avgSignalGreenTimePerCycle.get(signalGroupId2) < 5.0); Assert.assertTrue("cycle time should stay below 90 seconds", avgCycleTimePerSystem.get(signalSystemId) <= 90); Assert.assertTrue("avg delay per vehicle on WS-direction should be less than on NS-direction", avgDelayWE, Double> totalSignalGreenTimes = signalAnalyzer.getTotalSignalGreenTime(); - Map, Double> avgSignalGreenTimePerCycle = signalAnalyzer.calculateAvgSignalGreenTimePerFlexibleCycle(); - Map, Double> avgCycleTimePerSystem = signalAnalyzer.calculateAvgFlexibleCycleTimePerSignalSystem(); + + Map, Double> totalSignalGreenTimes = signalAnalyzer.getTotalSignalGreenTime(); + Map, Double> avgSignalGreenTimePerCycle = signalAnalyzer.calculateAvgSignalGreenTimePerFlexibleCycle(); + Map, Double> avgCycleTimePerSystem = signalAnalyzer.calculateAvgFlexibleCycleTimePerSignalSystem(); Map, Double> avgDelayPerLink = generalAnalyzer.getAvgDelayPerLink(); Double avgDelayWE = avgDelayPerLink.get(Id.createLinkId("2_3")); Double avgDelayNS = avgDelayPerLink.get(Id.createLinkId("7_3")); - + log.info("total signal green times: " + totalSignalGreenTimes.get(signalGroupId1) + ", " + totalSignalGreenTimes.get(signalGroupId2)); log.info("avg signal green times per cycle: " + avgSignalGreenTimePerCycle.get(signalGroupId1) + ", " + avgSignalGreenTimePerCycle.get(signalGroupId2)); log.info("avg cycle time per system: " + avgCycleTimePerSystem.get(signalSystemId)); log.info("avg delay per link: " + avgDelayWE + ", " + avgDelayNS); - - Assert.assertEquals("total signal green times should not differ more than 1%", 1, + + Assert.assertEquals("total signal green times should not differ more than 1%", 1, totalSignalGreenTimes.get(signalGroupId1)/totalSignalGreenTimes.get(signalGroupId2), 0.01); - Assert.assertEquals("avg signal green times per cycle should not differ more than 1%", + Assert.assertEquals("avg signal green times per cycle should not differ more than 1%", 1, avgSignalGreenTimePerCycle.get(signalGroupId1)/avgSignalGreenTimePerCycle.get(signalGroupId2), 0.01); // Assert.assertEquals("avg delay per vehicle per link should not differ more than 5%", 1, avgDelayWE/avgDelayNS, 0.05); /* I commented the last line out because the delay strongly depends on the stabilizing regime, namely the arrival rates that are used. @@ -218,40 +218,40 @@ public void testSingleCrossingScenarioStabilizingVsOptimizingRegimeLowDemand(){ Fixture fixtureComb = new Fixture(360, 1440, 0.0, Regime.COMBINED); SignalAnalysisTool signalAnalyzerComb = new SignalAnalysisTool(); DelayAnalysisTool generalAnalyzerComb = fixtureComb.run(signalAnalyzerComb); - - Map, Double> avgSignalGreenTimePerCycleStab = signalAnalyzerStab.calculateAvgSignalGreenTimePerFlexibleCycle(); - Map, Double> avgCycleTimePerSystemStab = signalAnalyzerStab.calculateAvgFlexibleCycleTimePerSignalSystem(); + + Map, Double> avgSignalGreenTimePerCycleStab = signalAnalyzerStab.calculateAvgSignalGreenTimePerFlexibleCycle(); + Map, Double> avgCycleTimePerSystemStab = signalAnalyzerStab.calculateAvgFlexibleCycleTimePerSignalSystem(); Map, Double> avgDelayPerLinkStab = generalAnalyzerStab.getAvgDelayPerLink(); - + log.info("demand 360,1440 (i.e. 0.5) -- results for the stabilizing regime:"); log.info("avg signal green times per cycle: " + avgSignalGreenTimePerCycleStab.get(signalGroupId1) + ", " + avgSignalGreenTimePerCycleStab.get(signalGroupId2)); log.info("avg cycle time per system: " + avgCycleTimePerSystemStab.get(signalSystemId)); log.info("avg delay per link: " + avgDelayPerLinkStab.get(Id.createLinkId("2_3")) + ", " + avgDelayPerLinkStab.get(Id.createLinkId("7_3"))); log.info("Total delay: " + generalAnalyzerStab.getTotalDelay()); - - Map, Double> avgSignalGreenTimePerCycleOpt = signalAnalyzerOpt.calculateAvgSignalGreenTimePerFlexibleCycle(); - Map, Double> avgCycleTimePerSystemOpt = signalAnalyzerOpt.calculateAvgFlexibleCycleTimePerSignalSystem(); + + Map, Double> avgSignalGreenTimePerCycleOpt = signalAnalyzerOpt.calculateAvgSignalGreenTimePerFlexibleCycle(); + Map, Double> avgCycleTimePerSystemOpt = signalAnalyzerOpt.calculateAvgFlexibleCycleTimePerSignalSystem(); Map, Double> avgDelayPerLinkOpt = generalAnalyzerOpt.getAvgDelayPerLink(); - + log.info("demand 360,1440 (i.e. 0.5) -- results for the optimizing regime:"); log.info("avg signal green times per cycle: " + avgSignalGreenTimePerCycleOpt.get(signalGroupId1) + ", " + avgSignalGreenTimePerCycleOpt.get(signalGroupId2)); log.info("avg cycle time per system: " + avgCycleTimePerSystemOpt.get(signalSystemId)); log.info("avg delay per link: " + avgDelayPerLinkOpt.get(Id.createLinkId("2_3")) + ", " + avgDelayPerLinkOpt.get(Id.createLinkId("7_3"))); log.info("Total delay: " + generalAnalyzerOpt.getTotalDelay()); - - Map, Double> avgSignalGreenTimePerCycleComb = signalAnalyzerComb.calculateAvgSignalGreenTimePerFlexibleCycle(); - Map, Double> avgCycleTimePerSystemComb = signalAnalyzerComb.calculateAvgFlexibleCycleTimePerSignalSystem(); + + Map, Double> avgSignalGreenTimePerCycleComb = signalAnalyzerComb.calculateAvgSignalGreenTimePerFlexibleCycle(); + Map, Double> avgCycleTimePerSystemComb = signalAnalyzerComb.calculateAvgFlexibleCycleTimePerSignalSystem(); Map, Double> avgDelayPerLinkComb = generalAnalyzerComb.getAvgDelayPerLink(); - + log.info("demand 360,1440 (i.e. 0.5) -- results for the combined regime:"); log.info("avg signal green times per cycle: " + avgSignalGreenTimePerCycleComb.get(signalGroupId1) + ", " + avgSignalGreenTimePerCycleComb.get(signalGroupId2)); log.info("avg cycle time per system: " + avgCycleTimePerSystemComb.get(signalSystemId)); log.info("avg delay per link: " + avgDelayPerLinkComb.get(Id.createLinkId("2_3")) + ", " + avgDelayPerLinkComb.get(Id.createLinkId("7_3"))); log.info("Total delay: " + generalAnalyzerComb.getTotalDelay()); - + // Test Stabilizing Regime: for (Id linkId : avgDelayPerLinkStab.keySet()) { Assert.assertTrue("stab: avg delay per link should be below a threshold (i.e. still stable)", avgDelayPerLinkStab.get(linkId) < maxCycleTime); @@ -260,36 +260,36 @@ public void testSingleCrossingScenarioStabilizingVsOptimizingRegimeLowDemand(){ Assert.assertTrue("stab: total delay should be higher than for the other regimes", generalAnalyzerStab.getTotalDelay() > generalAnalyzerComb.getTotalDelay()); Assert.assertTrue("the stabilizing regime should satisfy the maximum cycle time", avgCycleTimePerSystemStab.get(signalSystemId) < maxCycleTime); // stabilizing regime only shows green when number of vehicles beyond a critical number, i.e. some of the cycle time is given away (all signals show red) - Assert.assertTrue("stab: sum of green times per cycle plus 10 seconds intergreen time should be more than 10 seconds less than the avg cycle time", - avgSignalGreenTimePerCycleStab.get(signalGroupId1) + avgSignalGreenTimePerCycleStab.get(signalGroupId2) + cycleIntergreenTime + Assert.assertTrue("stab: sum of green times per cycle plus 10 seconds intergreen time should be more than 10 seconds less than the avg cycle time", + avgSignalGreenTimePerCycleStab.get(signalGroupId1) + avgSignalGreenTimePerCycleStab.get(signalGroupId2) + cycleIntergreenTime < avgCycleTimePerSystemStab.get(signalSystemId) - 10); - + // Test Optimizing Regime: for (Id linkId : avgDelayPerLinkOpt.keySet()) { Assert.assertTrue("opt: avg delay per link should be below a threshold (i.e. still stable)", avgDelayPerLinkOpt.get(linkId) < maxCycleTime); } - Assert.assertEquals("sum of green times per cycle plus 10 seconds intergreen time should be more or less equal to the avg cycle time", - avgCycleTimePerSystemOpt.get(signalSystemId), - avgSignalGreenTimePerCycleOpt.get(signalGroupId1) + avgSignalGreenTimePerCycleOpt.get(signalGroupId2) + cycleIntergreenTime, + Assert.assertEquals("sum of green times per cycle plus 10 seconds intergreen time should be more or less equal to the avg cycle time", + avgCycleTimePerSystemOpt.get(signalSystemId), + avgSignalGreenTimePerCycleOpt.get(signalGroupId1) + avgSignalGreenTimePerCycleOpt.get(signalGroupId2) + cycleIntergreenTime, 2); - Assert.assertTrue("for this demand, the cycle time of the optimizing regime should be still reasonable, i.e. below a threshold", + Assert.assertTrue("for this demand, the cycle time of the optimizing regime should be still reasonable, i.e. below a threshold", avgCycleTimePerSystemOpt.get(signalSystemId) < maxCycleTime); - + // Test Combined Regime: for (Id linkId : avgDelayPerLinkComb.keySet()) { Assert.assertTrue("avg delay per link should be below a threshold (i.e. still stable)", avgDelayPerLinkComb.get(linkId) < maxCycleTime); } - Assert.assertEquals("comb: sum of green times per cycle plus 10 seconds intergreen time should be more or less equal to the avg cycle time", - avgCycleTimePerSystemComb.get(signalSystemId), - avgSignalGreenTimePerCycleComb.get(signalGroupId1) + avgSignalGreenTimePerCycleComb.get(signalGroupId2) + cycleIntergreenTime, + Assert.assertEquals("comb: sum of green times per cycle plus 10 seconds intergreen time should be more or less equal to the avg cycle time", + avgCycleTimePerSystemComb.get(signalSystemId), + avgSignalGreenTimePerCycleComb.get(signalGroupId1) + avgSignalGreenTimePerCycleComb.get(signalGroupId2) + cycleIntergreenTime, 2); Assert.assertTrue("the combined regime should satisfy the maximum cycle time", avgCycleTimePerSystemComb.get(signalSystemId) < maxCycleTime); Assert.assertTrue("total delay with the combined regime should be the lowest", generalAnalyzerOpt.getTotalDelay() > generalAnalyzerComb.getTotalDelay()); } - + /** * compare different regimes for laemmer: stabilizing, optimizing and combination of both (combined) - * for high demand, i.e. an occupancy rate of 0.6 in the example of nico kuehnel's master thesis, the optimizing regime should no longer be stable (high delays, high travel time, + * for high demand, i.e. an occupancy rate of 0.6 in the example of nico kuehnel's master thesis, the optimizing regime should no longer be stable (high delays, high travel time, * no standard cycle pattern). The stabilizing regime should still be stable, the combined regime should be the best. */ @Test @@ -305,63 +305,63 @@ public void testSingleCrossingScenarioStabilizingVsOptimizingRegimeHighDemand(){ Fixture fixtureComb = new Fixture(360, 1800, 0.0, Regime.COMBINED); SignalAnalysisTool signalAnalyzerComb = new SignalAnalysisTool(); DelayAnalysisTool generalAnalyzerComb = fixtureComb.run(signalAnalyzerComb); - - Map, Double> avgSignalGreenTimePerCycleStab = signalAnalyzerStab.calculateAvgSignalGreenTimePerFlexibleCycle(); - Map, Double> avgCycleTimePerSystemStab = signalAnalyzerStab.calculateAvgFlexibleCycleTimePerSignalSystem(); + + Map, Double> avgSignalGreenTimePerCycleStab = signalAnalyzerStab.calculateAvgSignalGreenTimePerFlexibleCycle(); + Map, Double> avgCycleTimePerSystemStab = signalAnalyzerStab.calculateAvgFlexibleCycleTimePerSignalSystem(); Map, Double> avgDelayPerLinkStab = generalAnalyzerStab.getAvgDelayPerLink(); - + log.info("demand 360,1800 (i.e. 0.6) -- results for the stabilizing regime:"); log.info("avg signal green times per cycle: " + avgSignalGreenTimePerCycleStab.get(signalGroupId1) + ", " + avgSignalGreenTimePerCycleStab.get(signalGroupId2)); log.info("avg cycle time per system: " + avgCycleTimePerSystemStab.get(signalSystemId)); log.info("avg delay per link: " + avgDelayPerLinkStab.get(Id.createLinkId("2_3")) + ", " + avgDelayPerLinkStab.get(Id.createLinkId("7_3"))); log.info("Total delay: " + generalAnalyzerStab.getTotalDelay()); - - Map, Double> avgSignalGreenTimePerCycleOpt = signalAnalyzerOpt.calculateAvgSignalGreenTimePerFlexibleCycle(); - Map, Double> avgCycleTimePerSystemOpt = signalAnalyzerOpt.calculateAvgFlexibleCycleTimePerSignalSystem(); + + Map, Double> avgSignalGreenTimePerCycleOpt = signalAnalyzerOpt.calculateAvgSignalGreenTimePerFlexibleCycle(); + Map, Double> avgCycleTimePerSystemOpt = signalAnalyzerOpt.calculateAvgFlexibleCycleTimePerSignalSystem(); Map, Double> avgDelayPerLinkOpt = generalAnalyzerOpt.getAvgDelayPerLink(); - + log.info("demand 360,1800 (i.e. 0.6) -- results for the optimizing regime:"); log.info("avg signal green times per cycle: " + avgSignalGreenTimePerCycleOpt.get(signalGroupId1) + ", " + avgSignalGreenTimePerCycleOpt.get(signalGroupId2)); log.info("avg cycle time per system: " + avgCycleTimePerSystemOpt.get(signalSystemId)); log.info("avg delay per link: " + avgDelayPerLinkOpt.get(Id.createLinkId("2_3")) + ", " + avgDelayPerLinkOpt.get(Id.createLinkId("7_3"))); log.info("Total delay: " + generalAnalyzerOpt.getTotalDelay()); - - Map, Double> avgSignalGreenTimePerCycleComb = signalAnalyzerComb.calculateAvgSignalGreenTimePerFlexibleCycle(); - Map, Double> avgCycleTimePerSystemComb = signalAnalyzerComb.calculateAvgFlexibleCycleTimePerSignalSystem(); + + Map, Double> avgSignalGreenTimePerCycleComb = signalAnalyzerComb.calculateAvgSignalGreenTimePerFlexibleCycle(); + Map, Double> avgCycleTimePerSystemComb = signalAnalyzerComb.calculateAvgFlexibleCycleTimePerSignalSystem(); Map, Double> avgDelayPerLinkComb = generalAnalyzerComb.getAvgDelayPerLink(); - + log.info("demand 360,1800 (i.e. 0.6) -- results for the combined regime:"); log.info("avg signal green times per cycle: " + avgSignalGreenTimePerCycleComb.get(signalGroupId1) + ", " + avgSignalGreenTimePerCycleComb.get(signalGroupId2)); log.info("avg cycle time per system: " + avgCycleTimePerSystemComb.get(signalSystemId)); log.info("avg delay per link: " + avgDelayPerLinkComb.get(Id.createLinkId("2_3")) + ", " + avgDelayPerLinkComb.get(Id.createLinkId("7_3"))); log.info("Total delay: " + generalAnalyzerComb.getTotalDelay()); - + // Test Stabilizing Regime: for (Id linkId : avgDelayPerLinkStab.keySet()) { Assert.assertTrue("stab: avg delay per link should be below a threshold (i.e. still stable)", avgDelayPerLinkStab.get(linkId) < maxCycleTime); } Assert.assertTrue("the stabilizing regime should satisfy the maximum cycle time", avgCycleTimePerSystemStab.get(signalSystemId) < maxCycleTime); // stabilizing regime only shows green when number of vehicles beyond a critical number, i.e. some of the cycle time is given away (all signals show red) - Assert.assertTrue("stab: sum of green times per cycle plus 10 seconds intergreen time should be more than 9 seconds less than the avg cycle time", - avgSignalGreenTimePerCycleStab.get(signalGroupId1) + avgSignalGreenTimePerCycleStab.get(signalGroupId2) + cycleIntergreenTime + Assert.assertTrue("stab: sum of green times per cycle plus 10 seconds intergreen time should be more than 9 seconds less than the avg cycle time", + avgSignalGreenTimePerCycleStab.get(signalGroupId1) + avgSignalGreenTimePerCycleStab.get(signalGroupId2) + cycleIntergreenTime < avgCycleTimePerSystemStab.get(signalSystemId) - 9); - + // Test Optimizing Regime: Assert.assertTrue("avg delay for NS-direction should be very high for the optimizing regime with high demand", avgDelayPerLinkOpt.get(Id.createLinkId("7_3")) > maxCycleTime); Assert.assertTrue("total delay of optimizing regime should be the highest", generalAnalyzerStab.getTotalDelay() < generalAnalyzerOpt.getTotalDelay()); - Assert.assertTrue("for this demand, the cycle time of the optimizing regime should be very high, i.e. not stable anymore", + Assert.assertTrue("for this demand, the cycle time of the optimizing regime should be very high, i.e. not stable anymore", avgCycleTimePerSystemOpt.get(signalSystemId) > 10*maxCycleTime); - + // Test Combined Regime: for (Id linkId : avgDelayPerLinkComb.keySet()) { Assert.assertTrue("avg delay per link should be below a threshold (i.e. still stable)", avgDelayPerLinkComb.get(linkId) < maxCycleTime); } - Assert.assertEquals("comb: sum of green times per cycle plus 10 seconds intergreen time should be more or less equal to the avg cycle time", - avgCycleTimePerSystemComb.get(signalSystemId), - avgSignalGreenTimePerCycleComb.get(signalGroupId1) + avgSignalGreenTimePerCycleComb.get(signalGroupId2) + cycleIntergreenTime, + Assert.assertEquals("comb: sum of green times per cycle plus 10 seconds intergreen time should be more or less equal to the avg cycle time", + avgCycleTimePerSystemComb.get(signalSystemId), + avgSignalGreenTimePerCycleComb.get(signalGroupId1) + avgSignalGreenTimePerCycleComb.get(signalGroupId2) + cycleIntergreenTime, 2); Assert.assertTrue("the combined regime should satisfy the maximum cycle time", avgCycleTimePerSystemComb.get(signalSystemId) < maxCycleTime); Assert.assertTrue("total delay with the combined regime should be the lowest", generalAnalyzerOpt.getTotalDelay() > generalAnalyzerComb.getTotalDelay()); @@ -378,17 +378,17 @@ public void testSingleCrossingScenarioWithDifferentFlowCapacityFactors(){ Fixture fixtureFlowCap1 = new Fixture(360, 1800, 0.0, Regime.COMBINED); SignalAnalysisTool signalAnalyzerFlowCap1 = new SignalAnalysisTool(); DelayAnalysisTool generalAnalyzerFlowCap1 = fixtureFlowCap1.run(signalAnalyzerFlowCap1); - + Fixture fixtureFlowCap2 = new Fixture(360, 1800, 0.0, Regime.COMBINED); fixtureFlowCap2.doublePopulation(); SignalAnalysisTool signalAnalyzerFlowCap2 = new SignalAnalysisTool(); DelayAnalysisTool generalAnalyzerFlowCap2 = fixtureFlowCap2.run(signalAnalyzerFlowCap2); - - Map, Double> totalSignalGreenTimesFlowCap2 = signalAnalyzerFlowCap2.getTotalSignalGreenTime(); - Map, Double> avgSignalGreenTimePerCycleFlowCap2 = signalAnalyzerFlowCap2.calculateAvgSignalGreenTimePerFlexibleCycle(); - Map, Double> avgCycleTimePerSystemFlowCap2 = signalAnalyzerFlowCap2.calculateAvgFlexibleCycleTimePerSignalSystem(); + + Map, Double> totalSignalGreenTimesFlowCap2 = signalAnalyzerFlowCap2.getTotalSignalGreenTime(); + Map, Double> avgSignalGreenTimePerCycleFlowCap2 = signalAnalyzerFlowCap2.calculateAvgSignalGreenTimePerFlexibleCycle(); + Map, Double> avgCycleTimePerSystemFlowCap2 = signalAnalyzerFlowCap2.calculateAvgFlexibleCycleTimePerSignalSystem(); Map, Double> avgDelayPerLinkFlowCap2 = generalAnalyzerFlowCap2.getAvgDelayPerLink(); - + log.info("*** flow capacity 2.0 ***"); log.info("total signal green times: " + totalSignalGreenTimesFlowCap2.get(signalGroupId1) + ", " + totalSignalGreenTimesFlowCap2.get(signalGroupId2)); log.info("avg signal green times per cycle: " + avgSignalGreenTimePerCycleFlowCap2.get(signalGroupId1) + ", " @@ -396,10 +396,10 @@ public void testSingleCrossingScenarioWithDifferentFlowCapacityFactors(){ log.info("avg cycle time per system: " + avgCycleTimePerSystemFlowCap2.get(signalSystemId)); log.info("avg delay per link: " + avgDelayPerLinkFlowCap2.get(Id.createLinkId("2_3")) + ", " + avgDelayPerLinkFlowCap2.get(Id.createLinkId("7_3"))); log.info("Total delay: " + generalAnalyzerFlowCap2.getTotalDelay()); - - Map, Double> totalSignalGreenTimesFlowCap1 = signalAnalyzerFlowCap1.getTotalSignalGreenTime(); - Map, Double> avgSignalGreenTimePerCycleFlowCap1 = signalAnalyzerFlowCap1.calculateAvgSignalGreenTimePerFlexibleCycle(); - Map, Double> avgCycleTimePerSystemFlowCap1 = signalAnalyzerFlowCap1.calculateAvgFlexibleCycleTimePerSignalSystem(); + + Map, Double> totalSignalGreenTimesFlowCap1 = signalAnalyzerFlowCap1.getTotalSignalGreenTime(); + Map, Double> avgSignalGreenTimePerCycleFlowCap1 = signalAnalyzerFlowCap1.calculateAvgSignalGreenTimePerFlexibleCycle(); + Map, Double> avgCycleTimePerSystemFlowCap1 = signalAnalyzerFlowCap1.calculateAvgFlexibleCycleTimePerSignalSystem(); Map, Double> avgDelayPerLinkFlowCap1 = generalAnalyzerFlowCap1.getAvgDelayPerLink(); log.info("*** flow capacity 1.0 ***"); @@ -409,24 +409,24 @@ public void testSingleCrossingScenarioWithDifferentFlowCapacityFactors(){ log.info("avg cycle time per system: " + avgCycleTimePerSystemFlowCap1.get(signalSystemId)); log.info("avg delay per link: " + avgDelayPerLinkFlowCap1.get(Id.createLinkId("2_3")) + ", " + avgDelayPerLinkFlowCap1.get(Id.createLinkId("7_3"))); log.info("Total delay: " + generalAnalyzerFlowCap1.getTotalDelay()); - - Assert.assertEquals("total signal green times should not differ", 1, + + Assert.assertEquals("total signal green times should not differ", 1, totalSignalGreenTimesFlowCap1.get(signalGroupId1)/totalSignalGreenTimesFlowCap2.get(signalGroupId1), 0.01); - Assert.assertEquals("total signal green times should not differ", 1, + Assert.assertEquals("total signal green times should not differ", 1, totalSignalGreenTimesFlowCap1.get(signalGroupId2)/totalSignalGreenTimesFlowCap2.get(signalGroupId2), 0.01); - Assert.assertEquals("avg signal green times per cycle should not differ", avgSignalGreenTimePerCycleFlowCap1.get(signalGroupId1), + Assert.assertEquals("avg signal green times per cycle should not differ", avgSignalGreenTimePerCycleFlowCap1.get(signalGroupId1), avgSignalGreenTimePerCycleFlowCap2.get(signalGroupId1), 0.1); - Assert.assertEquals("avg signal green times per cycle should not differ", avgSignalGreenTimePerCycleFlowCap1.get(signalGroupId2), + Assert.assertEquals("avg signal green times per cycle should not differ", avgSignalGreenTimePerCycleFlowCap1.get(signalGroupId2), avgSignalGreenTimePerCycleFlowCap2.get(signalGroupId2), 0.1); Assert.assertEquals("avg cycle time should not differ", avgCycleTimePerSystemFlowCap1.get(signalSystemId), avgCycleTimePerSystemFlowCap2.get(signalSystemId), 0.1); - Assert.assertEquals("avg delay per vehicle per link should not differ", + Assert.assertEquals("avg delay per vehicle per link should not differ", avgDelayPerLinkFlowCap1.get(Id.createLinkId("2_3")), avgDelayPerLinkFlowCap2.get(Id.createLinkId("2_3")), 0.1); - Assert.assertEquals("avg delay per vehicle per link should not differ", + Assert.assertEquals("avg delay per vehicle per link should not differ", avgDelayPerLinkFlowCap1.get(Id.createLinkId("7_3")), avgDelayPerLinkFlowCap2.get(Id.createLinkId("7_3")), 2); Assert.assertEquals("total delay for doubled demand should be doubled", 2, generalAnalyzerFlowCap2.getTotalDelay()/generalAnalyzerFlowCap1.getTotalDelay(), 0.1); } - + /** * Test Laemmer with multiple iterations (some variables have to be reset after iterations). */ @@ -444,7 +444,7 @@ public void testMultipleIterations() { Map, Double> avgDelayPerLink0It = generalAnalyzer0It.getAvgDelayPerLink(); Double avgDelayWE0It = avgDelayPerLink0It.get(Id.createLinkId("2_3")); Double avgDelayNS0It = avgDelayPerLink0It.get(Id.createLinkId("7_3")); - + log.info("total signal green times in iteration 0: " + totalSignalGreenTimes0It.get(signalGroupId1) + ", " + totalSignalGreenTimes0It.get(signalGroupId1l) + ", " + totalSignalGreenTimes0It.get(signalGroupId2)); log.info("avg signal green times per cycle in itertion 0: " + avgSignalGreenTimePerCycle0It.get(signalGroupId1) + ", " + avgSignalGreenTimePerCycle0It.get(signalGroupId1l) + ", " @@ -452,7 +452,7 @@ public void testMultipleIterations() { log.info("avg cycle time per system in itertion 0: " + avgCycleTimePerSystem0It.get(signalSystemId)); log.info("avg delay per link in itertion 0: " + avgDelayWE0It + ", " + avgDelayNS0It); - + Fixture fixture1It = new Fixture(500, 2000, 5.0, Regime.COMBINED); int lastIt = 1; fixture1It.setLastIteration(lastIt); @@ -466,7 +466,7 @@ public void testMultipleIterations() { Map, Double> avgDelayPerLink1It = generalAnalyzer1It.getAvgDelayPerLink(); Double avgDelayWE1It = avgDelayPerLink1It.get(Id.createLinkId("2_3")); Double avgDelayNS1It = avgDelayPerLink1It.get(Id.createLinkId("7_3")); - + log.info("total signal green times in itertion 1: " + totalSignalGreenTimes1It.get(signalGroupId1) + ", " + totalSignalGreenTimes1It.get(signalGroupId1l) + ", " + totalSignalGreenTimes1It.get(signalGroupId2)); log.info("avg signal green times per cycle in itertion 1: " + avgSignalGreenTimePerCycle1It.get(signalGroupId1) + ", " + avgSignalGreenTimePerCycle1It.get(signalGroupId1l) + ", " @@ -474,7 +474,7 @@ public void testMultipleIterations() { log.info("avg cycle time per system in itertion 1: " + avgCycleTimePerSystem1It.get(signalSystemId)); log.info("avg delay per link in itertion 1: " + avgDelayWE1It + ", " + avgDelayNS1It); - + Assert.assertEquals("total green time of signal group 1 should be the same as in the first iteration", totalSignalGreenTimes0It.get(signalGroupId1), totalSignalGreenTimes1It.get(signalGroupId1), MatsimTestUtils.EPSILON); Assert.assertEquals("total green time of signal group 1l should be the same as in the first iteration", totalSignalGreenTimes0It.get(signalGroupId1l), totalSignalGreenTimes1It.get(signalGroupId1l), MatsimTestUtils.EPSILON); Assert.assertEquals("total green time of signal group 2 should be the same as in the first iteration", totalSignalGreenTimes0It.get(signalGroupId2), totalSignalGreenTimes1It.get(signalGroupId2), MatsimTestUtils.EPSILON); @@ -489,29 +489,29 @@ public void testMultipleIterations() { long checksum_itLast = CRCChecksum.getCRCFromFile(testUtils.getOutputDirectory() + "ITERS/it."+lastIt+"/signalEvents2Via.csv"); Assert.assertEquals("Signal events are different", checksum_it0, checksum_itLast); } - + // TODO test stochasticity (laemmer better than fixed-time; different than for constant demand) // TODO test temporarily overcrowded situations (no exeption; signal is able to resolve congestion; like fixed-time schedule; cycle times get longer when overload continues) // TODO test liveArrivalRate (with/without time buckets) vs. exact data (the second results in more precise green times?!; liveArrivalRates are determined correctly) // TODO test grouping // TODO test lanes // ... - + private class Fixture { - + private Scenario scenario; private double flowNS; private double flowWE; - + Fixture(double flowNS, double flowWE, double minG, Regime regime) { this.flowWE = flowWE; this.flowNS = flowNS; - + // create Config Config config = ConfigUtils.loadConfig("./examples/tutorial/singleCrossingScenario/config.xml"); config.plans().setInputFile(null); config.controler().setOutputDirectory(testUtils.getOutputDirectory()); - + LaemmerConfigGroup laemmerConfigGroup = ConfigUtils.addOrGetModule(config, LaemmerConfigGroup.GROUP_NAME, LaemmerConfigGroup.class); laemmerConfigGroup.setMinGreenTime(minG); @@ -534,17 +534,17 @@ private class Fixture { lanesOfLink43.getLanes().get(Id.create("4_3.r", Lane.class)).setCapacityVehiclesPerHour(0); lanesOfLink43.getLanes().get(Id.create("4_3.s", Lane.class)).setCapacityVehiclesPerHour(3600); } - + void doublePopulation() { scenario.getConfig().qsim().setFlowCapFactor(2.0); createSimplePopulationWithoutLeftTurns(scenario.getPopulation(), flowNS, flowWE, "-2"); } - + void addLeftTurnTraffic() { String[] linksWEleft = {"1_2-6_7", "5_4-8_9"}; createPopulationForRelation(0.1 * flowWE, scenario.getPopulation(), linksWEleft, "-left"); } - + void setLastIteration(int lastIteration) { scenario.getConfig().controler().setLastIteration(lastIteration); // add replanning strategy @@ -553,14 +553,14 @@ void setLastIteration(int lastIteration) { strat.setWeight(1.); scenario.getConfig().strategy().addStrategySettings(strat); } - + DelayAnalysisTool run(SignalAnalysisTool signalAnalyzer) { Controler controler = new Controler( scenario ); - + // add the signals module // controler.addOverridingModule(new SignalsModule()); Signals.configure( controler ); - + // add signal analysis tool controler.addOverridingModule(new AbstractModule() { @Override @@ -577,13 +577,13 @@ public void install() { this.addEventHandlerBinding().toInstance(delayAnalysis); } }); - + // run the simulation controler.run(); - + return delayAnalysis; } - + private void createSimplePopulationWithoutLeftTurns(Population pop, double flowNS, double flowWE, String idPostFix) { String[] linksNS = {"6_7-8_9", "9_8-7_6"}; String[] linksWE = {"5_4-2_1", "1_2-4_5"}; @@ -591,7 +591,7 @@ private void createSimplePopulationWithoutLeftTurns(Population pop, double flowN createPopulationForRelation(flowNS, pop, linksNS, idPostFix); createPopulationForRelation(flowWE, pop, linksWE, idPostFix); } - + private void createPopulationForRelation(double flow, Population population, String[] links, String idPostFix) { if (flow == 0) { return; @@ -631,7 +631,7 @@ private void createPerson(Population population, String fromLinkId, String toLin Id.createLinkId(toLinkId)); plan.addActivity(drainAct); } - + } } diff --git a/contribs/signals/src/test/java/org/matsim/contrib/signals/controller/sylvia/SylviaIT.java b/contribs/signals/src/test/java/org/matsim/contrib/signals/controller/sylvia/SylviaIT.java index 4ec520760c8..4d4fca3fff7 100644 --- a/contribs/signals/src/test/java/org/matsim/contrib/signals/controller/sylvia/SylviaIT.java +++ b/contribs/signals/src/test/java/org/matsim/contrib/signals/controller/sylvia/SylviaIT.java @@ -60,8 +60,8 @@ import org.matsim.contrib.signals.utils.SignalUtils; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup.ActivityParams; -import org.matsim.core.config.groups.StrategyConfigGroup.StrategySettings; +import org.matsim.core.config.groups.ScoringConfigGroup.ActivityParams; +import org.matsim.core.config.groups.ReplanningConfigGroup.StrategySettings; import org.matsim.core.controler.AbstractModule; import org.matsim.core.controler.Controler; import org.matsim.core.controler.OutputDirectoryHierarchy.OverwriteFileSetting; @@ -74,10 +74,10 @@ /** * Test sylvia logic at an intersection with four incoming links and one signal each. * No lanes are used. - * + * * It is tested whether sylvia expands signal phases correctly when more vehicles want to pass * and whether cycle times are kept. - * + * * @author tthunig * */ @@ -94,7 +94,7 @@ public class SylviaIT { * used. The two approaches have equal demand but different priority in the * Sylvia signal algorithm. The priority is given by the order in the signal * plan. In this test, signal group 1 has priority over 2. - * + * * note: signal settings of the fixed time plan are unbalanced with 5 seconds * for signal group 1 vs. 45 seconds for signal group 2. but signal settings of * the sylvia plan are balanced, because each setting is shortend to 5 seconds @@ -123,16 +123,16 @@ public void testDemandABPrioA() { Assert.assertEquals("avg green time per cycle of signal group 1 is wrong", 30, avgSignalGreenTimePerCycle.get(signalGroupId1), 1); Assert.assertEquals("avg green time per cycle of signal group 2 is wrong", 20, avgSignalGreenTimePerCycle.get(signalGroupId2), 1); // can differ from the fixed cycle length because the analysis is quit after the last activity start event - Assert.assertEquals("avg cycle time of the system is wrong", 60, avgCycleTimePerSystem.get(signalSystemId), 1); + Assert.assertEquals("avg cycle time of the system is wrong", 60, avgCycleTimePerSystem.get(signalSystemId), 1); } - + /** * Test sylvia with two conflicting streams at a single intersection. A fixed * cycle time (of 60 seconds) and no maximal extension time per setting are * used. The two approaches have equal demand but different priority in the * Sylvia signal algorithm. The priority is given by the order in the signal * plan. In this test, signal group 2 has priority over 1. - * + * * note: signal settings of the fixed time plan are unbalanced with 5 seconds * for signal group 1 vs. 45 seconds for signal group 2. but signal settings of * the sylvia plan are balanced, because each setting is shortend to 5 seconds @@ -162,7 +162,7 @@ public void testDemandABPrioB() { Assert.assertEquals("avg green time per cycle of signal group 2 is wrong", 30, avgSignalGreenTimePerCycle.get(signalGroupId2), 1); Assert.assertEquals("avg green time per cycle of signal group 1 is wrong", 20, avgSignalGreenTimePerCycle.get(signalGroupId1), 1); // can differ from the fixed cycle length because the analysis is quit after the last activity start event - Assert.assertEquals("avg cycle time of the system is wrong", 60, avgCycleTimePerSystem.get(signalSystemId), 1); + Assert.assertEquals("avg cycle time of the system is wrong", 60, avgCycleTimePerSystem.get(signalSystemId), 1); } /** @@ -228,7 +228,7 @@ private void createScenarioElements(Scenario scenario, double[] noPersons, int o /** * creates a network like this: - * + * * 6 * ^ * | @@ -245,8 +245,8 @@ private void createScenarioElements(Scenario scenario, double[] noPersons, int o * ^ * | * v - * 9 - * + * 9 + * * @param net * the object where the network should be stored */ @@ -403,7 +403,7 @@ private Config defineConfig() { config.qsim().setEndTime(3 * 3600); config.qsim().setUsingFastCapacityUpdate(false); - + config.controler().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); config.vspExperimental().setWritingOutputEvents(false); diff --git a/contribs/signals/src/test/java/org/matsim/contrib/signals/oneagent/Fixture.java b/contribs/signals/src/test/java/org/matsim/contrib/signals/oneagent/Fixture.java index d01b6d7881b..3021d072edd 100644 --- a/contribs/signals/src/test/java/org/matsim/contrib/signals/oneagent/Fixture.java +++ b/contribs/signals/src/test/java/org/matsim/contrib/signals/oneagent/Fixture.java @@ -45,8 +45,8 @@ import org.matsim.contrib.signals.model.SignalSystem; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup.ActivityParams; -import org.matsim.core.config.groups.StrategyConfigGroup.StrategySettings; +import org.matsim.core.config.groups.ScoringConfigGroup.ActivityParams; +import org.matsim.core.config.groups.ReplanningConfigGroup.StrategySettings; import org.matsim.core.controler.OutputDirectoryHierarchy.OverwriteFileSetting; import org.matsim.core.scenario.ScenarioUtils; import org.matsim.lanes.Lane; @@ -65,18 +65,18 @@ public class Fixture { final Id signalPlanId2 = Id.create(2, SignalPlan.class); final Id signalSystemId2 = Id.create(2, SignalSystem.class); final Id signalGroupId100 = Id.create(100, SignalGroup.class); - + // only available if 'TwoSignals'-Method is used final Id signalGroupId200 = Id.create(200, SignalGroup.class); final Id linkId6 = Id.create(6, Link.class); final Id nodeId6 = Id.create(6, Node.class); - + public Scenario createAndLoadTestScenarioOneSignal(Boolean useIntergreens){ Config conf = createConfigOneSignal(useIntergreens); Scenario scenario = ScenarioUtils.loadScenario(conf); scenario.addScenarioElement(SignalsData.ELEMENT_NAME, new SignalsDataLoader(conf).loadSignalsData()); - + return scenario; } @@ -107,17 +107,17 @@ private Config createConfigOneSignal(Boolean useIntergreens) { conf.qsim().setUsingFastCapacityUpdate(false); SignalSystemsConfigGroup signalsConfig = ConfigUtils.addOrGetModule(conf, SignalSystemsConfigGroup.GROUP_NAME, SignalSystemsConfigGroup.class); signalsConfig.setUseSignalSystems(true); - + if (useIntergreens) { signalsConfig.setIntergreenTimesFile("testIntergreenTimes_v1.0.xml"); signalsConfig.setUseIntergreenTimes(true); signalsConfig.setActionOnIntergreenViolation(SignalSystemsConfigGroup.ActionOnSignalSpecsViolation.EXCEPTION); - } + } this.setSignalSystemConfigValues(signalsConfig, testUtils); return conf; } - + private void setSignalSystemConfigValues(SignalSystemsConfigGroup signalsConfig, MatsimTestUtils testUtils){ signalsConfig.setSignalSystemFile("testSignalSystems_v2.0.xml"); signalsConfig.setSignalGroupsFile("testSignalGroups_v2.0.xml"); @@ -130,10 +130,10 @@ public Scenario createAndLoadTestScenarioTwoSignals(boolean useConflictData) { SignalSystemsConfigGroup signalsConfig = ConfigUtils.addOrGetModule(config, SignalSystemsConfigGroup.GROUP_NAME, SignalSystemsConfigGroup.class); signalsConfig.setIntersectionLogic(IntersectionLogic.CONFLICTING_DIRECTIONS_NO_TURN_RESTRICTIONS); signalsConfig.setActionOnConflictingDirectionViolation(ActionOnSignalSpecsViolation.EXCEPTION); - + Scenario scenario = ScenarioUtils.loadScenario(config); scenario.addScenarioElement(SignalsData.ELEMENT_NAME, new SignalsDataLoader(config).loadSignalsData()); - + // modify scenario Network net = scenario.getNetwork(); net.addNode(net.getFactory().createNode(nodeId6, new Coord(0, 100))); @@ -168,9 +168,9 @@ public Scenario createAndLoadTestScenarioTwoSignals(boolean useConflictData) { conflictsNode2.addDirection(direction1); conflictsNode2.addDirection(direction2); signalsData.getConflictingDirectionsData().addConflictingDirectionsForIntersection(signalSystemId2, nodeId2, conflictsNode2); - + return scenario; } - + } diff --git a/contribs/socnetsim/src/main/java/org/matsim/contrib/socnetsim/jointactivities/scoring/FireMoneyEventsForUtilityOfBeingTogether.java b/contribs/socnetsim/src/main/java/org/matsim/contrib/socnetsim/jointactivities/scoring/FireMoneyEventsForUtilityOfBeingTogether.java index 50dfd2d5988..1df9b8341df 100644 --- a/contribs/socnetsim/src/main/java/org/matsim/contrib/socnetsim/jointactivities/scoring/FireMoneyEventsForUtilityOfBeingTogether.java +++ b/contribs/socnetsim/src/main/java/org/matsim/contrib/socnetsim/jointactivities/scoring/FireMoneyEventsForUtilityOfBeingTogether.java @@ -47,7 +47,7 @@ import org.matsim.contrib.socnetsim.run.ScoringFunctionConfigGroup; import org.matsim.core.api.experimental.events.EventsManager; import org.matsim.api.core.v01.events.HasPersonId; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup.ActivityParams; +import org.matsim.core.config.groups.ScoringConfigGroup.ActivityParams; import org.matsim.core.controler.events.AfterMobsimEvent; import org.matsim.core.controler.listener.AfterMobsimListener; import org.matsim.core.utils.collections.MapUtils; @@ -123,7 +123,7 @@ public BeingTogetherScoring.PersonOverlapScorer createScorer(final Id id) { return new BeingTogetherScoring.LinearOverlapScorer( 0 ); } final double typicalDuration = - getTypicalDuration( + getTypicalDuration( scenario, person, scoringFunctionConf.getActivityTypeForContactInDesires() ); @@ -152,13 +152,13 @@ public static double getTypicalDuration( if ( typicalDuration != null ) return typicalDuration; final ActivityParams params = scenario.getConfig().planCalcScore().getActivityParams( type ); - + if ( params == null ) { //throw new RuntimeException( "could not find typical duration for Person "+person.getId()+" for type "+type ); // not that nice, but needed for agents that might not have a preference. BeingTogetherScoring knows how to handle that return Double.NEGATIVE_INFINITY; } - + return params.getTypicalDuration().seconds(); } diff --git a/contribs/taxi/src/test/java/org/matsim/contrib/taxi/util/TaxiEventsReadersTest.java b/contribs/taxi/src/test/java/org/matsim/contrib/taxi/util/TaxiEventsReadersTest.java index 71db340ef1b..eba9e7a1c4b 100644 --- a/contribs/taxi/src/test/java/org/matsim/contrib/taxi/util/TaxiEventsReadersTest.java +++ b/contribs/taxi/src/test/java/org/matsim/contrib/taxi/util/TaxiEventsReadersTest.java @@ -46,7 +46,7 @@ import org.matsim.contrib.taxi.schedule.TaxiStayTask; import org.matsim.contrib.taxi.schedule.TaxiTaskType; import org.matsim.core.api.experimental.events.EventsManager; -import org.matsim.core.config.groups.ControlerConfigGroup; +import org.matsim.core.config.groups.ControllerConfigGroup; import org.matsim.core.events.EventsUtils; import org.matsim.core.events.algorithms.EventWriterXML; @@ -83,7 +83,7 @@ public void testReader() { eventsManager.initProcessing(); TaxiEventsReaders.createEventsReader(eventsManager) .readStream(new ByteArrayInputStream(outputStream.toByteArray()), - ControlerConfigGroup.EventsFileFormat.xml); + ControllerConfigGroup.EventsFileFormat.xml); eventsManager.finishProcessing(); assertThat(handler.handledEvents).usingRecursiveFieldByFieldElementComparator() diff --git a/contribs/vsp/src/main/java/org/matsim/contrib/vsp/scenario/SnzActivities.java b/contribs/vsp/src/main/java/org/matsim/contrib/vsp/scenario/SnzActivities.java index 8700bc0d86b..cbb8c519805 100644 --- a/contribs/vsp/src/main/java/org/matsim/contrib/vsp/scenario/SnzActivities.java +++ b/contribs/vsp/src/main/java/org/matsim/contrib/vsp/scenario/SnzActivities.java @@ -1,7 +1,7 @@ package org.matsim.contrib.vsp.scenario; import org.matsim.core.config.Config; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; /** * Defines available activities and open- and closing times in Snz scenarios at vsp. @@ -54,7 +54,7 @@ public enum SnzActivities { /** * Apply start and end time to params. */ - public PlanCalcScoreConfigGroup.ActivityParams apply(PlanCalcScoreConfigGroup.ActivityParams params) { + public ScoringConfigGroup.ActivityParams apply(ScoringConfigGroup.ActivityParams params) { if (start >= 0) params = params.setOpeningTime(start * 3600.); if (end >= 0) @@ -70,18 +70,18 @@ public static void addScoringParams(Config config) { for (SnzActivities value : SnzActivities.values()) { for (long ii = 600; ii <= 97200; ii += 600) { - config.planCalcScore().addActivityParams(value.apply(new PlanCalcScoreConfigGroup.ActivityParams(value.name() + "_" + ii).setTypicalDuration(ii))); + config.planCalcScore().addActivityParams(value.apply(new ScoringConfigGroup.ActivityParams(value.name() + "_" + ii).setTypicalDuration(ii))); } } - config.planCalcScore().addActivityParams(new PlanCalcScoreConfigGroup.ActivityParams("car interaction").setTypicalDuration(60)); - config.planCalcScore().addActivityParams(new PlanCalcScoreConfigGroup.ActivityParams("ride interaction").setTypicalDuration(60)); - config.planCalcScore().addActivityParams(new PlanCalcScoreConfigGroup.ActivityParams("bike interaction").setTypicalDuration(60)); + config.planCalcScore().addActivityParams(new ScoringConfigGroup.ActivityParams("car interaction").setTypicalDuration(60)); + config.planCalcScore().addActivityParams(new ScoringConfigGroup.ActivityParams("ride interaction").setTypicalDuration(60)); + config.planCalcScore().addActivityParams(new ScoringConfigGroup.ActivityParams("bike interaction").setTypicalDuration(60)); - config.planCalcScore().addActivityParams(new PlanCalcScoreConfigGroup.ActivityParams("other").setTypicalDuration(600 * 3)); + config.planCalcScore().addActivityParams(new ScoringConfigGroup.ActivityParams("other").setTypicalDuration(600 * 3)); - config.planCalcScore().addActivityParams(new PlanCalcScoreConfigGroup.ActivityParams("freight_start").setTypicalDuration(60 * 15)); - config.planCalcScore().addActivityParams(new PlanCalcScoreConfigGroup.ActivityParams("freight_end").setTypicalDuration(60 * 15)); + config.planCalcScore().addActivityParams(new ScoringConfigGroup.ActivityParams("freight_start").setTypicalDuration(60 * 15)); + config.planCalcScore().addActivityParams(new ScoringConfigGroup.ActivityParams("freight_end").setTypicalDuration(60 * 15)); } } diff --git a/contribs/vsp/src/main/java/org/matsim/core/scoring/functions/PersonScoringParametersFromPersonAttributes.java b/contribs/vsp/src/main/java/org/matsim/core/scoring/functions/PersonScoringParametersFromPersonAttributes.java index afa71b067aa..861a51c33c4 100644 --- a/contribs/vsp/src/main/java/org/matsim/core/scoring/functions/PersonScoringParametersFromPersonAttributes.java +++ b/contribs/vsp/src/main/java/org/matsim/core/scoring/functions/PersonScoringParametersFromPersonAttributes.java @@ -25,7 +25,7 @@ import org.matsim.api.core.v01.IdMap; import org.matsim.api.core.v01.population.Person; import org.matsim.api.core.v01.population.Population; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; import org.matsim.core.config.groups.ScenarioConfigGroup; import org.matsim.core.population.PersonUtils; import org.matsim.core.population.PopulationUtils; @@ -60,7 +60,7 @@ public class PersonScoringParametersFromPersonAttributes implements ScoringParametersForPerson { Logger log = LogManager.getLogger(PersonScoringParametersFromPersonAttributes.class); - private final PlanCalcScoreConfigGroup config; + private final ScoringConfigGroup config; private final ScenarioConfigGroup scConfig; private final TransitConfigGroup transitConfigGroup; private final Map, ScoringParameters> params = new IdMap<>(Person.class); @@ -68,8 +68,8 @@ public class PersonScoringParametersFromPersonAttributes implements ScoringParam private final Map> activityParamsPerSubpopulation = new ConcurrentHashMap<>(); @Inject - PersonScoringParametersFromPersonAttributes(Population population, PlanCalcScoreConfigGroup planCalcScoreConfigGroup, ScenarioConfigGroup scenarioConfigGroup, TransitConfigGroup transitConfigGroup) { - this.config = planCalcScoreConfigGroup; + PersonScoringParametersFromPersonAttributes(Population population, ScoringConfigGroup scoringConfigGroup, ScenarioConfigGroup scenarioConfigGroup, TransitConfigGroup transitConfigGroup) { + this.config = scoringConfigGroup; this.scConfig = scenarioConfigGroup; this.transitConfigGroup = transitConfigGroup; this.globalAvgIncome = computeAvgIncome(population); @@ -114,13 +114,13 @@ public ScoringParameters getScoringParameters(Person person) { * point of view than giving each ScoringFunction its own copy of the params. */ - PlanCalcScoreConfigGroup.ScoringParameterSet subpopulationScoringParams = this.config.getScoringParameters(subpopulation); + ScoringConfigGroup.ScoringParameterSet subpopulationScoringParams = this.config.getScoringParameters(subpopulation); // (we can set scoring params per subpopulation, so retrieve them as starting point. kai, apr'22) // save the activityParams of the subpopulation so we need to build them only once. this.activityParamsPerSubpopulation.computeIfAbsent(subpopulation, k -> { Map activityParams = new TreeMap<>(); - for (PlanCalcScoreConfigGroup.ActivityParams params : subpopulationScoringParams.getActivityParams()) { + for (ScoringConfigGroup.ActivityParams params : subpopulationScoringParams.getActivityParams()) { ActivityUtilityParameters.Builder factory = new ActivityUtilityParameters.Builder(params); activityParams.put(params.getActivityType(), factory.build()); } @@ -134,7 +134,7 @@ public ScoringParameters getScoringParameters(Person person) { if (transitConfigGroup.isUseTransit()) { // this is the PT stage activity: - PlanCalcScoreConfigGroup.ActivityParams transitActivityParams = new PlanCalcScoreConfigGroup.ActivityParams(PtConstants.TRANSIT_ACTIVITY_TYPE); + ScoringConfigGroup.ActivityParams transitActivityParams = new ScoringConfigGroup.ActivityParams(PtConstants.TRANSIT_ACTIVITY_TYPE); transitActivityParams.setTypicalDuration(120.0); transitActivityParams.setOpeningTime(0.); transitActivityParams.setClosingTime(0.); @@ -170,7 +170,7 @@ public ScoringParameters getScoringParameters(Person person) { } // copy other params from subpopulation config - PlanCalcScoreConfigGroup.ModeParams subpopulationModeParams = subpopulationScoringParams.getModes().get(entry.getKey()); + ScoringConfigGroup.ModeParams subpopulationModeParams = subpopulationScoringParams.getModes().get(entry.getKey()); modeUtilityParamsBuilder.setMarginalUtilityOfTraveling_s(subpopulationModeParams.getMarginalUtilityOfTraveling()); modeUtilityParamsBuilder.setMarginalUtilityOfDistance_m(subpopulationModeParams.getMarginalUtilityOfDistance()); modeUtilityParamsBuilder.setMonetaryDistanceRate(subpopulationModeParams.getMonetaryDistanceRate()); diff --git a/contribs/vsp/src/main/java/playground/vsp/airPollution/exposure/EmissionResponsibilityTravelDisutilityCalculatorFactory.java b/contribs/vsp/src/main/java/playground/vsp/airPollution/exposure/EmissionResponsibilityTravelDisutilityCalculatorFactory.java index 8ae1e6eabb7..e0c3d929689 100644 --- a/contribs/vsp/src/main/java/playground/vsp/airPollution/exposure/EmissionResponsibilityTravelDisutilityCalculatorFactory.java +++ b/contribs/vsp/src/main/java/playground/vsp/airPollution/exposure/EmissionResponsibilityTravelDisutilityCalculatorFactory.java @@ -24,7 +24,7 @@ import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; import org.matsim.contrib.emissions.EmissionModule; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; import org.matsim.core.router.costcalculators.RandomizingTimeDistanceTravelDisutilityFactory; import org.matsim.core.router.costcalculators.TravelDisutilityFactory; import org.matsim.core.router.util.TravelDisutility; @@ -41,7 +41,7 @@ public class EmissionResponsibilityTravelDisutilityCalculatorFactory implements private RandomizingTimeDistanceTravelDisutilityFactory randomizedTimeDistanceTravelDisutilityFactory; @Inject private EmissionModule emissionModule; @Inject private EmissionResponsibilityCostModule emissionCostModule; - @Inject private PlanCalcScoreConfigGroup cnScoringGroup; + @Inject private ScoringConfigGroup cnScoringGroup; private Set> hotspotLinks = null; @Inject private Vehicles vehicles; diff --git a/contribs/vsp/src/main/java/playground/vsp/airPollution/flatEmissions/EmissionTravelDisutilityCalculatorFactory.java b/contribs/vsp/src/main/java/playground/vsp/airPollution/flatEmissions/EmissionTravelDisutilityCalculatorFactory.java index 3158ac1e854..1b6814f1388 100644 --- a/contribs/vsp/src/main/java/playground/vsp/airPollution/flatEmissions/EmissionTravelDisutilityCalculatorFactory.java +++ b/contribs/vsp/src/main/java/playground/vsp/airPollution/flatEmissions/EmissionTravelDisutilityCalculatorFactory.java @@ -24,7 +24,7 @@ import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; import org.matsim.contrib.emissions.EmissionModule; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; import org.matsim.core.router.costcalculators.RandomizingTimeDistanceTravelDisutilityFactory; import org.matsim.core.router.costcalculators.TravelDisutilityFactory; import org.matsim.core.router.util.TravelDisutility; @@ -41,7 +41,7 @@ public class EmissionTravelDisutilityCalculatorFactory implements TravelDisutili private final RandomizingTimeDistanceTravelDisutilityFactory randomizedTimeDistanceTravelDisutilityFactory; @Inject private EmissionModule emissionModule; @Inject private EmissionCostModule emissionCostModule; - @Inject private PlanCalcScoreConfigGroup cnScoringGroup; + @Inject private ScoringConfigGroup cnScoringGroup; private Set> hotspotLinks = null; @Inject private Vehicles vehicles; diff --git a/contribs/vsp/src/main/java/playground/vsp/analysis/modules/userBenefits/UserBenefitsCalculator.java b/contribs/vsp/src/main/java/playground/vsp/analysis/modules/userBenefits/UserBenefitsCalculator.java index 57ade159f57..622939f0685 100644 --- a/contribs/vsp/src/main/java/playground/vsp/analysis/modules/userBenefits/UserBenefitsCalculator.java +++ b/contribs/vsp/src/main/java/playground/vsp/analysis/modules/userBenefits/UserBenefitsCalculator.java @@ -30,7 +30,7 @@ import org.matsim.api.core.v01.population.Plan; import org.matsim.api.core.v01.population.Population; import org.matsim.core.config.Config; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; import org.matsim.core.gbl.Gbl; /** @@ -54,26 +54,26 @@ public class UserBenefitsCalculator { private final Set> stuckingAgents; public UserBenefitsCalculator(Config config, WelfareMeasure wm, boolean considerAllPlans) { - PlanCalcScoreConfigGroup pcs = config.planCalcScore(); + ScoringConfigGroup pcs = config.planCalcScore(); this.betaLogit = pcs.getBrainExpBeta(); this.marginalUtlOfMoney = pcs.getMarginalUtilityOfMoney(); this.welfareMeasure = wm; this.considerAllPlans = considerAllPlans; - + logger.warn("There is no list of person IDs provided to be excluded from the user benefit calculation."); this.stuckingAgents = null; - + if (considerAllPlans) { logger.warn("All plans are considered for the calculation of user benefits. For an economic interpretation invalid plans (score <= 0.0 or score == null) should not be considered."); } else { logger.warn("Invalid plans that will not be considered for the calculation of user benefits are defined to have either a null score or a negative score."); } } - + public UserBenefitsCalculator(Config config, Set> stuckingAgents) { logger.info("Providing the IDs of agents that are stucking in the final iteration (selected plans)."); - PlanCalcScoreConfigGroup pcs = config.planCalcScore(); + ScoringConfigGroup pcs = config.planCalcScore(); this.betaLogit = pcs.getBrainExpBeta(); this.marginalUtlOfMoney = pcs.getMarginalUtilityOfMoney(); this.stuckingAgents = stuckingAgents; @@ -81,7 +81,7 @@ public UserBenefitsCalculator(Config config, Set> stuckingAgents) { logger.info("A list of person IDs of stucking agents is provided. These persons will be excluded from the user benefit calculation." + "All other plans will be considered."); this.considerAllPlans = false; - + logger.info("The welfare measure is set to " + WelfareMeasure.SELECTED.toString() + "."); this.welfareMeasure = WelfareMeasure.SELECTED; } @@ -105,7 +105,7 @@ public double calculateUtility_utils(Population pop){ logger.info("Finished user benefits calculation..."); return sumOfUtility_utils; } - + public double calculateUtility_money(Population pop) { double sumOfUtility_money = 0.0; logger.info("Starting user benefits calculation..."); @@ -126,7 +126,7 @@ public double calculateUtilityOfPerson_utils(Person person) { double utilityOfPerson_utils = 0.0; double sumOfExpScore = 0.0; double bestScore = Double.NEGATIVE_INFINITY; - + if(this.welfareMeasure.equals(WelfareMeasure.LOGSUM)){ for(Plan plan : person.getPlans()){ boolean shouldBeConsidered; @@ -141,7 +141,7 @@ public double calculateUtilityOfPerson_utils(Person person) { /* Kais version: */ bestScore = getBestScore(person); double expScoreOfPlan = Math.exp(betaLogit * (plan.getScore() - bestScore)); - + sumOfExpScore += expScoreOfPlan; } else { // plan is not considered @@ -188,7 +188,7 @@ private boolean testScore(Plan plan, Id personId) { if(plan.getScore() == null){ nullScore++; if(nullScore <= maxWarnCnt) { - logger.warn("Score for person " + personId + " is " + plan.getScore() + logger.warn("Score for person " + personId + " is " + plan.getScore() + ". A null score cannot be used for utility calculation."); if(nullScore == maxWarnCnt) logger.warn(Gbl.FUTURE_SUPPRESSED + "\n"); } @@ -196,7 +196,7 @@ private boolean testScore(Plan plan, Id personId) { } else if(plan.getScore() <= 0.0){ minusScore++; if(minusScore <= maxWarnCnt) { - logger.warn("Score for person " + personId + " is " + plan.getScore() + logger.warn("Score for person " + personId + " is " + plan.getScore() + ". A score <= 0.0 cannot be used for utility calculation."); if(minusScore == maxWarnCnt) logger.warn(Gbl.FUTURE_SUPPRESSED + "\n"); } @@ -204,7 +204,7 @@ private boolean testScore(Plan plan, Id personId) { } else return true; } else { if (plan.getScore() == null){ - throw new RuntimeException("Score for person " + personId + " is " + plan.getScore() + throw new RuntimeException("Score for person " + personId + " is " + plan.getScore() + ". A null score cannot be used for utility calculation. This person has to be excluded."); } else { if (this.stuckingAgents.contains(personId)) { @@ -243,7 +243,7 @@ public int getPersonsWithoutValidPlanCnt() { return personsWithoutValidPlanScore; } } - + public int getInvalidPlans() { if (this.considerAllPlans) { logger.warn("All plans are forced to be considered. Asking for the number of invalid plans doesn't make sense."); @@ -253,11 +253,11 @@ public int getInvalidPlans() { return invalidPlans; } } - + public Map, Double> getPersonId2Utility() { return personId2Utility; } - + public Map, Double> getPersonId2MonetizedUtility() { return personId2MonetizedUtility; } diff --git a/contribs/vsp/src/main/java/playground/vsp/buildingEnergy/BuildingEnergyAnalyzerMain.java b/contribs/vsp/src/main/java/playground/vsp/buildingEnergy/BuildingEnergyAnalyzerMain.java index d53a3a33238..1731b3f5d68 100644 --- a/contribs/vsp/src/main/java/playground/vsp/buildingEnergy/BuildingEnergyAnalyzerMain.java +++ b/contribs/vsp/src/main/java/playground/vsp/buildingEnergy/BuildingEnergyAnalyzerMain.java @@ -24,7 +24,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.matsim.core.config.groups.ControlerConfigGroup; +import org.matsim.core.config.groups.ControllerConfigGroup; import org.matsim.core.controler.OutputDirectoryHierarchy; import org.matsim.core.controler.OutputDirectoryLogging; import org.matsim.core.gbl.Gbl; @@ -36,12 +36,12 @@ /** * @author droeder - * + * */ class BuildingEnergyAnalyzerMain { private static final Logger log = LogManager.getLogger(BuildingEnergyAnalyzerMain.class); - + private static final String[] ARGS = new String[]{ "E:\\VSP\\svn\\shared-svn\\studies\\droeder\\buildingEnergy\\runs\\", "E:\\VSP\\svn\\shared-svn\\studies\\droeder\\buildingEnergy\\runs\\outputCaseStudies\\", @@ -64,8 +64,8 @@ private BuildingEnergyAnalyzerMain() { } /** - * - * + * + * * @param args */ public static void main(String[] args) { @@ -100,7 +100,7 @@ public static void main(String[] args) { OutputDirectoryLogging.initLogging( new OutputDirectoryHierarchy(outputPath, BuildingEnergyAnalyzer.class.getSimpleName(), OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles, - ControlerConfigGroup.CompressionType.none)); + ControllerConfigGroup.CompressionType.none)); OutputDirectoryLogging.catchLogEntries(); // dump input-parameters to log log.info("running class: " + System.getProperty("sun.java.command")); @@ -135,16 +135,16 @@ public static void main(String[] args) { Gbl.printElapsedTime(); log.info("finished."); } - + private static class OfficeEnergyConsumptionRuleImpl implements BuildingEnergyConsumptionRule{ - + private double additional; private double baseLoad; private double td; private double someCoefficient; /** - * + * * @param td, duration timeslice [s] * @param baseLoadPerPerson [kW] * @param additionalLoadPerPerson [kW] @@ -155,7 +155,7 @@ private static class OfficeEnergyConsumptionRuleImpl implements BuildingEnergyCo this.additional = additionalLoadPerPerson; this.someCoefficient = someCoefficient; } - + @Override public double getEnergyConsumption_kWh(double maxSize, double currentOccupancy) { if(currentOccupancy > maxSize) throw new RuntimeException("more persons on the link than expected"); @@ -164,17 +164,17 @@ public double getEnergyConsumption_kWh(double maxSize, double currentOccupancy) double additionalLoad = this.additional * maxSize; return (td / 3600. * (baseload + additionalLoad * (1 - Math.exp(-1.0 * currentOccupancy / maxSize * someCoefficient)))); } - + } - + private static class HomeEnergyConsumptionRuleImpl implements BuildingEnergyConsumptionRule{ - + private double td; private double baseLoad; private double additional; /** - * + * * @param td * @param baseLoadPerPerson * @param additionalLoadPerPerson @@ -189,7 +189,7 @@ private static class HomeEnergyConsumptionRuleImpl implements BuildingEnergyCons public double getEnergyConsumption_kWh(double maxSize, double currentOccupancy) { return (td/3600. * (maxSize * baseLoad + currentOccupancy * additional)); } - + } } diff --git a/contribs/vsp/src/main/java/playground/vsp/buildingEnergy/linkOccupancy/LinkActivityCalculationFromEventsMain.java b/contribs/vsp/src/main/java/playground/vsp/buildingEnergy/linkOccupancy/LinkActivityCalculationFromEventsMain.java index f6aa672471a..cb70d46affb 100644 --- a/contribs/vsp/src/main/java/playground/vsp/buildingEnergy/linkOccupancy/LinkActivityCalculationFromEventsMain.java +++ b/contribs/vsp/src/main/java/playground/vsp/buildingEnergy/linkOccupancy/LinkActivityCalculationFromEventsMain.java @@ -38,7 +38,7 @@ import org.matsim.api.core.v01.population.Population; import org.matsim.core.api.experimental.events.EventsManager; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.ControlerConfigGroup; +import org.matsim.core.config.groups.ControllerConfigGroup; import org.matsim.core.controler.OutputDirectoryHierarchy; import org.matsim.core.controler.OutputDirectoryLogging; import org.matsim.core.events.EventsUtils; @@ -54,7 +54,7 @@ /** - * Simple main-routine that parse an eventsfile, using {@link LinkActivityOccupancyCounter}. + * Simple main-routine that parse an eventsfile, using {@link LinkActivityOccupancyCounter}. * The generated data is written to csv-tables. * @author droeder * @@ -68,7 +68,7 @@ private LinkActivityCalculationFromEventsMain() { private static final String DIR = "E:\\VSP\\svn\\shared-svn\\studies\\droeder\\buildingEnergy\\runs\\"; private static final String RUN = "2kW.15"; - + private static String[] ARGS = new String[]{ DIR + RUN + "\\" + RUN + ".output_network.xml.gz", DIR + RUN + "\\ITERS\\it.1000\\" + RUN + ".1000.plans.xml.gz", @@ -78,15 +78,15 @@ private LinkActivityCalculationFromEventsMain() { "86400", RUN }; - + private static Counter he= new Counter("home events # "); private static Counter we = new Counter("work events # "); private static Counter hp= new Counter("home plans # "); private static Counter wp = new Counter("work plans # "); - + private static final String PREFIX = "activityCountOnLinks"; - - + + /** * @param args */ @@ -105,7 +105,7 @@ public static void main(String[] args) { //catch logEntries OutputDirectoryLogging.initLogging(new OutputDirectoryHierarchy(outputPath, runId + "." + PREFIX, OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles, - ControlerConfigGroup.CompressionType.none)); + ControllerConfigGroup.CompressionType.none)); OutputDirectoryLogging.catchLogEntries(); Gbl.enableThreadCpuTimeMeasurement(); // dump input-parameters @@ -139,10 +139,10 @@ public static void main(String[] args) { } /** - * @param eventsFile - * @param work - * @param home - * + * @param eventsFile + * @param work + * @param home + * */ private static void parseEvents(Map home, Map work, String eventsFile) { log.info("parsing events."); @@ -153,14 +153,14 @@ private static void parseEvents(Map home, for(LinkActivityOccupancyCounter v: work.values()){ manager.addHandler(v); } - + manager.addHandler(new ActivityStartEventHandler() { - + @Override public void reset(int iteration) { - + } - + @Override public void handleEvent(ActivityStartEvent event) { if(event.getActType().equals("home")) he.incCounter(); @@ -168,7 +168,7 @@ public void handleEvent(ActivityStartEvent event) { } }); new MatsimEventsReader(manager).readFile(eventsFile); - log.info("finished (parsing events)."); + log.info("finished (parsing events)."); } /** @@ -199,7 +199,7 @@ private static Scenario prepareScenario(String plansFile, String networkFile) { // final Population population = (Population) sc.getPopulation(); StreamingPopulationReader reader = new StreamingPopulationReader( sc ) ; reader.addAlgorithm(new PersonAlgorithm() { - + @Override public void run(Person person) { for(int i = 1; i < person.getSelectedPlan().getPlanElements().size(); i++){ diff --git a/contribs/vsp/src/main/java/playground/vsp/cadyts/multiModeCadyts/MultiModeCountsControlerListener.java b/contribs/vsp/src/main/java/playground/vsp/cadyts/multiModeCadyts/MultiModeCountsControlerListener.java index 4d7e7407fc9..3cb374b5048 100644 --- a/contribs/vsp/src/main/java/playground/vsp/cadyts/multiModeCadyts/MultiModeCountsControlerListener.java +++ b/contribs/vsp/src/main/java/playground/vsp/cadyts/multiModeCadyts/MultiModeCountsControlerListener.java @@ -30,12 +30,11 @@ import jakarta.inject.Inject; import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.matsim.analysis.IterationStopWatch; import org.matsim.analysis.VolumesAnalyzer; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; -import org.matsim.core.config.groups.ControlerConfigGroup; +import org.matsim.core.config.groups.ControllerConfigGroup; import org.matsim.core.config.groups.CountsConfigGroup; import org.matsim.core.config.groups.QSimConfigGroup; import org.matsim.core.controler.OutputDirectoryHierarchy; @@ -57,7 +56,7 @@ public class MultiModeCountsControlerListener implements StartupListener, Iterat */ public static final String OPERATION_COMPARECOUNTS = "compare with counts"; - private final ControlerConfigGroup controlerConfigGroup; + private final ControllerConfigGroup controllerConfigGroup; private final CountsConfigGroup config; // useful to get the link ids of counting stations and other infor for averaging private final Set analyzedModes; private final VolumesAnalyzer volumesAnalyzer; @@ -71,8 +70,8 @@ public class MultiModeCountsControlerListener implements StartupListener, Iterat private int iterationsUsed = 0; @Inject - private MultiModeCountsControlerListener(QSimConfigGroup qsimConfigGroup, ControlerConfigGroup controlerConfigGroup, CountsConfigGroup countsConfigGroup, VolumesAnalyzer volumesAnalyzer, IterationStopWatch iterationStopwatch, OutputDirectoryHierarchy controlerIO) { - this.controlerConfigGroup = controlerConfigGroup; + private MultiModeCountsControlerListener(QSimConfigGroup qsimConfigGroup, ControllerConfigGroup controllerConfigGroup, CountsConfigGroup countsConfigGroup, VolumesAnalyzer volumesAnalyzer, IterationStopWatch iterationStopwatch, OutputDirectoryHierarchy controlerIO) { + this.controllerConfigGroup = controllerConfigGroup; this.config = countsConfigGroup; this.volumesAnalyzer = volumesAnalyzer; this.analyzedModes = CollectionUtils.stringToSet(this.config.getAnalyzedModes()); @@ -105,13 +104,13 @@ public void notifyStartup(final StartupEvent controlerStartupEvent) { public void notifyIterationEnds(final IterationEndsEvent event) { if(counts==null) { } - else if ( event.getIteration() == controlerConfigGroup.getFirstIteration()){ + else if ( event.getIteration() == controllerConfigGroup.getFirstIteration()){ // write the data for first iteration too addVolumes(volumesAnalyzer); writeData(event, this.linkStats); reset(); } else if ( this.config.getWriteCountsInterval() > 0 ) { - if (useVolumesOfIteration(event.getIteration(), controlerConfigGroup.getFirstIteration())) { + if (useVolumesOfIteration(event.getIteration(), controllerConfigGroup.getFirstIteration())) { addVolumes(volumesAnalyzer); } diff --git a/contribs/vsp/src/main/java/playground/vsp/congestion/handlers/MarginalSumScoringFunction.java b/contribs/vsp/src/main/java/playground/vsp/congestion/handlers/MarginalSumScoringFunction.java index ec5d51bdb78..54c11433467 100644 --- a/contribs/vsp/src/main/java/playground/vsp/congestion/handlers/MarginalSumScoringFunction.java +++ b/contribs/vsp/src/main/java/playground/vsp/congestion/handlers/MarginalSumScoringFunction.java @@ -19,8 +19,8 @@ package playground.vsp.congestion.handlers; import org.matsim.api.core.v01.population.Activity; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup.TypicalDurationScoreComputation; +import org.matsim.core.config.groups.ScoringConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup.TypicalDurationScoreComputation; import org.matsim.core.population.PopulationUtils; import org.matsim.core.scoring.SumScoringFunction; import org.matsim.core.scoring.functions.ActivityUtilityParameters; @@ -33,29 +33,29 @@ */ public class MarginalSumScoringFunction { // private final static Logger log = LogManager.getLogger(MarginalSumScoringFunction.class); - + CharyparNagelActivityScoring activityScoringA; CharyparNagelActivityScoring activityScoringB; - + public MarginalSumScoringFunction(ScoringParameters params) { - - PlanCalcScoreConfigGroup.ActivityParams taxiActParams = new PlanCalcScoreConfigGroup.ActivityParams("TaxiPickup"); + + ScoringConfigGroup.ActivityParams taxiActParams = new ScoringConfigGroup.ActivityParams("TaxiPickup"); taxiActParams.setTypicalDurationScoreComputation(TypicalDurationScoreComputation.relative); taxiActParams.setScoringThisActivityAtAll(false); taxiActParams.setTypicalDuration(1.0); - + ActivityUtilityParameters actUtilityParams = new ActivityUtilityParameters.Builder(taxiActParams).build(); params.utilParams.put("TaxiPickup", actUtilityParams); - + activityScoringA = new CharyparNagelActivityScoring(params); activityScoringB = new CharyparNagelActivityScoring(params); } public final double getNormalActivityDelayDisutility(Activity activity, double delay) { - + SumScoringFunction sumScoringA = new SumScoringFunction() ; sumScoringA.addScoringFunction(activityScoringA); - + SumScoringFunction sumScoringB = new SumScoringFunction() ; sumScoringB.addScoringFunction(activityScoringB); @@ -70,31 +70,31 @@ public final double getNormalActivityDelayDisutility(Activity activity, double d Activity activityWithoutDelay = PopulationUtils.createActivity(activity); activityWithoutDelay.setStartTime(activity.getStartTime().seconds() - delay); - + // log.info("activity: " + activity.toString()); // log.info("activityWithoutDelay: " + activityWithoutDelay.toString()); - + sumScoringA.handleActivity(activity); sumScoringB.handleActivity(activityWithoutDelay); sumScoringA.finish(); sumScoringB.finish(); - + double scoreA1 = sumScoringA.getScore(); double scoreB1 = sumScoringB.getScore(); - + double scoreWithDelay = scoreA1 - scoreA0; double scoreWithoutDelay = scoreB1 - scoreB0; - + double activityDelayDisutility = scoreWithoutDelay - scoreWithDelay; - return activityDelayDisutility; + return activityDelayDisutility; } - + public final double getOvernightActivityDelayDisutility(Activity activityMorning, Activity activityEvening, double delay) { - + SumScoringFunction delegateA = new SumScoringFunction() ; delegateA.addScoringFunction(activityScoringA); - + SumScoringFunction delegateB = new SumScoringFunction() ; delegateB.addScoringFunction(activityScoringB); @@ -109,34 +109,34 @@ public final double getOvernightActivityDelayDisutility(Activity activityMorning } else { throw new RuntimeException("activityEvening is not the last activity. Or why does it have an end time? Aborting..."); } - + double scoreA0 = delegateA.getScore(); double scoreB0 = delegateB.getScore(); - + delegateA.handleActivity(activityMorning); delegateB.handleActivity(activityMorning); - + Activity activityEveningWithoutDelay = PopulationUtils.createActivity(activityEvening); activityEveningWithoutDelay.setStartTime(activityEvening.getStartTime().seconds() - delay); - + // log.info("activityMorning: " + activityMorning.toString()); // log.info("activityEvening: " + activityEvening.toString()); // log.info("activityEveningWithoutDelay: " + activityEveningWithoutDelay.toString()); delegateA.handleActivity(activityEvening); delegateB.handleActivity(activityEveningWithoutDelay); - + delegateA.finish(); delegateB.finish(); - + double scoreA1 = delegateA.getScore(); double scoreB1 = delegateB.getScore(); - + double scoreWithDelay = scoreA1 - scoreA0; double scoreWithoutDelay = scoreB1 - scoreB0; - + double activityDelayDisutility = scoreWithoutDelay - scoreWithDelay; return activityDelayDisutility; } - + } diff --git a/contribs/vsp/src/main/java/playground/vsp/congestion/routing/CongestionTollTimeDistanceTravelDisutilityFactory.java b/contribs/vsp/src/main/java/playground/vsp/congestion/routing/CongestionTollTimeDistanceTravelDisutilityFactory.java index 2e30bb434d2..9a2c2c7d0f2 100644 --- a/contribs/vsp/src/main/java/playground/vsp/congestion/routing/CongestionTollTimeDistanceTravelDisutilityFactory.java +++ b/contribs/vsp/src/main/java/playground/vsp/congestion/routing/CongestionTollTimeDistanceTravelDisutilityFactory.java @@ -19,7 +19,7 @@ * *********************************************************************** */ package playground.vsp.congestion.routing; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; import org.matsim.core.router.costcalculators.RandomizingTimeDistanceTravelDisutilityFactory; import org.matsim.core.router.costcalculators.TravelDisutilityFactory; import org.matsim.core.router.util.TravelDisutility; @@ -38,10 +38,10 @@ public final class CongestionTollTimeDistanceTravelDisutilityFactory implements private double blendFactor = 1.0; private RandomizingTimeDistanceTravelDisutilityFactory timeDistanceTravelDisutilityFactory; private final TollHandler tollHandler; - private final PlanCalcScoreConfigGroup cnScoringGroup; + private final ScoringConfigGroup cnScoringGroup; public CongestionTollTimeDistanceTravelDisutilityFactory(RandomizingTimeDistanceTravelDisutilityFactory timeDistanceTravelDisutilityFactory, - TollHandler tollHandler, PlanCalcScoreConfigGroup cnScoringGroup) { + TollHandler tollHandler, ScoringConfigGroup cnScoringGroup) { this.tollHandler = tollHandler; this.timeDistanceTravelDisutilityFactory = timeDistanceTravelDisutilityFactory; this.cnScoringGroup = cnScoringGroup; @@ -58,11 +58,11 @@ public final TravelDisutility createTravelDisutility(TravelTime timeCalculator) this.blendFactor ); } - + public void setSigma ( double val ) { this.sigma = val; } - + public void setBlendFactor ( double blendFactor ) { this.blendFactor = blendFactor; } diff --git a/contribs/vsp/src/main/java/playground/vsp/congestion/routing/TollDisutilityCalculatorFactory.java b/contribs/vsp/src/main/java/playground/vsp/congestion/routing/TollDisutilityCalculatorFactory.java index 2c7b8e8c03d..f3f4edafce3 100644 --- a/contribs/vsp/src/main/java/playground/vsp/congestion/routing/TollDisutilityCalculatorFactory.java +++ b/contribs/vsp/src/main/java/playground/vsp/congestion/routing/TollDisutilityCalculatorFactory.java @@ -18,13 +18,13 @@ * *********************************************************************** */ /** - * + * */ package playground.vsp.congestion.routing; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.population.Person; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; import org.matsim.core.router.costcalculators.TravelDisutilityFactory; import org.matsim.core.router.util.TravelDisutility; import org.matsim.core.router.util.TravelTime; @@ -39,10 +39,10 @@ public class TollDisutilityCalculatorFactory implements TravelDisutilityFactory { private TollHandler tollHandler; - private final PlanCalcScoreConfigGroup cnScoringGroup; + private final ScoringConfigGroup cnScoringGroup; @Deprecated - public TollDisutilityCalculatorFactory(TollHandler tollHandler, PlanCalcScoreConfigGroup cnScoringGroup) { + public TollDisutilityCalculatorFactory(TollHandler tollHandler, ScoringConfigGroup cnScoringGroup) { this.tollHandler = tollHandler; this.cnScoringGroup = cnScoringGroup; } @@ -58,7 +58,7 @@ public double getLinkTravelDisutility(final Link link, final double time, final double linkTravelDisutility = ttdc.getLinkTravelDisutility(link, time, person, vehicle); return linkTravelDisutility; } - + @Override public double getLinkMinimumTravelDisutility(Link link) { return ttdc.getLinkMinimumTravelDisutility(link); diff --git a/contribs/vsp/src/main/java/playground/vsp/congestion/routing/TollTravelDisutilityCalculator.java b/contribs/vsp/src/main/java/playground/vsp/congestion/routing/TollTravelDisutilityCalculator.java index 01e76368fcf..d94e382a396 100644 --- a/contribs/vsp/src/main/java/playground/vsp/congestion/routing/TollTravelDisutilityCalculator.java +++ b/contribs/vsp/src/main/java/playground/vsp/congestion/routing/TollTravelDisutilityCalculator.java @@ -18,7 +18,7 @@ * *********************************************************************** */ /** - * + * */ package playground.vsp.congestion.routing; @@ -27,7 +27,7 @@ import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.population.Person; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; import org.matsim.core.router.util.TravelDisutility; import org.matsim.core.router.util.TravelTime; import org.matsim.vehicles.Vehicle; @@ -48,28 +48,28 @@ public class TollTravelDisutilityCalculator implements TravelDisutility{ * the old value will be totally overwritten. */ private final double blendFactor = 0.1; - + private TravelTime timeCalculator; private double marginalUtlOfMoney; private double distanceCostRateCar; private double marginalUtlOfTravelTime; private TollHandler tollHandler; - + @Deprecated - public TollTravelDisutilityCalculator(TravelTime timeCalculator, PlanCalcScoreConfigGroup cnScoringGroup, TollHandler tollHandler) { + public TollTravelDisutilityCalculator(TravelTime timeCalculator, ScoringConfigGroup cnScoringGroup, TollHandler tollHandler) { this.timeCalculator = timeCalculator; this.marginalUtlOfMoney = cnScoringGroup.getMarginalUtilityOfMoney(); this.distanceCostRateCar = cnScoringGroup.getModes().get(TransportMode.car).getMonetaryDistanceRate(); // ignores cnScoringGroup.getModes().get(TransportMode.car).getMarginalUtilityOfDistance(); this.marginalUtlOfTravelTime = (-cnScoringGroup.getModes().get(TransportMode.car).getMarginalUtilityOfTraveling() / 3600.0) + (cnScoringGroup.getPerforming_utils_hr() / 3600.0); this.tollHandler = tollHandler; - + log.info("The 'blend factor' which is used for the calculation of the expected tolls in the next iteration is set to " + this.blendFactor); } @Override public double getLinkTravelDisutility(final Link link, final double time, final Person person, final Vehicle v) { - + double linkTravelTime = this.timeCalculator.getLinkTravelTime(link, time, person, v); double linkTravelTimeDisutility = this.marginalUtlOfTravelTime * linkTravelTime ; @@ -78,7 +78,7 @@ public double getLinkTravelDisutility(final Link link, final double time, final double linkDistanceDisutility = this.marginalUtlOfMoney * distanceCost; double linkExpectedTollDisutility = calculateExpectedTollDisutility(link, time, person); - + double linkTravelDisutility = linkTravelTimeDisutility + linkDistanceDisutility + linkExpectedTollDisutility; return linkTravelDisutility; @@ -88,21 +88,21 @@ private double calculateExpectedTollDisutility(Link link, double time, Person pe /* The following is an estimate of the tolls that an agent would have to pay if choosing that link in the next iteration i based on the tolls in iteration i-1 and i-2 */ - + double linkExpectedTollNewValue = this.tollHandler.getAvgToll(link.getId(), time); double linkExpectedTollOldValue = this.tollHandler.getAvgTollOldValue(link.getId(), time); double blendedOldValue = (1 - blendFactor) * linkExpectedTollOldValue; - double blendedNewValue = blendFactor * linkExpectedTollNewValue; - + double blendedNewValue = blendFactor * linkExpectedTollNewValue; + // if (linkExpectedTollNewValue != 0 || linkExpectedTollOldValue != 0) { // log.info("-----------> Person " + person.getId() + ": Expected toll (new value) on link " + link.getId() + " at " + Time.writeTime(time, Time.TIMEFORMAT_HHMMSS) + ": " + linkExpectedTollNewValue); // log.info("-----------> Person " + person.getId() + ": Expected toll (old value) on link " + link.getId() + " at " + Time.writeTime(time, Time.TIMEFORMAT_HHMMSS) + ": " + linkExpectedTollOldValue); -// +// // log.info("ExpectedToll: " + (blendedNewValue + blendedOldValue) ); // } - - double linkExpectedTollDisutility = -1 * this.marginalUtlOfMoney * (blendedOldValue + blendedNewValue); + + double linkExpectedTollDisutility = -1 * this.marginalUtlOfMoney * (blendedOldValue + blendedNewValue); return linkExpectedTollDisutility; } diff --git a/contribs/vsp/src/main/java/playground/vsp/demandde/pendlermatrix/PersonRouterFilter.java b/contribs/vsp/src/main/java/playground/vsp/demandde/pendlermatrix/PersonRouterFilter.java index 6b574ed8aa4..ab638409f4d 100644 --- a/contribs/vsp/src/main/java/playground/vsp/demandde/pendlermatrix/PersonRouterFilter.java +++ b/contribs/vsp/src/main/java/playground/vsp/demandde/pendlermatrix/PersonRouterFilter.java @@ -29,7 +29,7 @@ import org.matsim.api.core.v01.network.Node; import org.matsim.api.core.v01.population.Activity; import org.matsim.api.core.v01.population.Person; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; import org.matsim.core.network.NetworkUtils; import org.matsim.core.router.DijkstraFactory; import org.matsim.core.router.costcalculators.FreespeedTravelTimeAndDisutility; @@ -40,20 +40,20 @@ import playground.vsp.pipeline.PersonSinkSource; public class PersonRouterFilter implements PersonSinkSource { - + private Network network; - + private LeastCostPathCalculator dijkstra; - + private PersonSink sink; - + private Collection interestingNodeIds = new HashSet(); - + double travelTimeToEntry = 0.0; - + public PersonRouterFilter(Network network) { this.network = network; - FreespeedTravelTimeAndDisutility fttc = new FreespeedTravelTimeAndDisutility(new PlanCalcScoreConfigGroup()); + FreespeedTravelTimeAndDisutility fttc = new FreespeedTravelTimeAndDisutility(new ScoringConfigGroup()); dijkstra = new DijkstraFactory().createPathCalculator(network, fttc, fttc); } @@ -97,7 +97,7 @@ public void process(Person person) { public void setSink(PersonSink sink) { this.sink = sink; } - + private static double calculateFreespeedTravelTimeToNode(Network network, Path path, Node node) { double travelTime = 0.0; for (Link l : path.links) { diff --git a/contribs/vsp/src/main/java/playground/vsp/demandde/pendlermatrix/RouterFilter.java b/contribs/vsp/src/main/java/playground/vsp/demandde/pendlermatrix/RouterFilter.java index 6a7385c635c..f90921cf67c 100644 --- a/contribs/vsp/src/main/java/playground/vsp/demandde/pendlermatrix/RouterFilter.java +++ b/contribs/vsp/src/main/java/playground/vsp/demandde/pendlermatrix/RouterFilter.java @@ -29,7 +29,7 @@ import org.matsim.api.core.v01.network.Network; import org.matsim.api.core.v01.network.Node; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; import org.matsim.core.network.NetworkUtils; import org.matsim.core.router.DijkstraFactory; import org.matsim.core.router.costcalculators.FreespeedTravelTimeAndDisutility; @@ -50,16 +50,16 @@ public class RouterFilter implements TripFlowSink { private TripFlowSink sink; private Collection interestingNodeIds = new HashSet(); - + private double travelTimeToLink = 0.0; - + private Coord entryCoord; - + private final Scenario sc ; public RouterFilter(Network network) { this.network = network; - FreespeedTravelTimeAndDisutility fttc = new FreespeedTravelTimeAndDisutility(new PlanCalcScoreConfigGroup()); + FreespeedTravelTimeAndDisutility fttc = new FreespeedTravelTimeAndDisutility(new ScoringConfigGroup()); dijkstra = new DijkstraFactory().createPathCalculator(network, fttc, fttc); this.sc = ScenarioUtils.createScenario(ConfigUtils.createConfig()) ; } @@ -73,7 +73,7 @@ public void process(ActivityFacility quelle, ActivityFacility ziel, int quantity if (isInteresting(path)) { // Facility newQuelle = new Zone(quelle.getId(), quelle.workplaces, quelle.workingPopulation, entryCoord); ActivityFacility newQuelle = factory.createActivityFacility(quelle.getId(), quelle.getCoord() ) ; - for ( ActivityOption option : quelle.getActivityOptions().values() ) { + for ( ActivityOption option : quelle.getActivityOptions().values() ) { newQuelle.addActivityOption(option) ; } diff --git a/contribs/vsp/src/main/java/playground/vsp/demandde/pendlermatrix/TravelTimeToWorkCalculator.java b/contribs/vsp/src/main/java/playground/vsp/demandde/pendlermatrix/TravelTimeToWorkCalculator.java index 9792acd66b1..a2d26868067 100644 --- a/contribs/vsp/src/main/java/playground/vsp/demandde/pendlermatrix/TravelTimeToWorkCalculator.java +++ b/contribs/vsp/src/main/java/playground/vsp/demandde/pendlermatrix/TravelTimeToWorkCalculator.java @@ -3,7 +3,7 @@ import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; import org.matsim.api.core.v01.network.Node; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; import org.matsim.core.network.NetworkUtils; import org.matsim.core.router.DijkstraFactory; import org.matsim.core.router.costcalculators.FreespeedTravelTimeAndDisutility; @@ -21,7 +21,7 @@ public class TravelTimeToWorkCalculator implements TripFlowSink { public TravelTimeToWorkCalculator(Network network) { this.network = network; - FreespeedTravelTimeAndDisutility fttc = new FreespeedTravelTimeAndDisutility(new PlanCalcScoreConfigGroup()); + FreespeedTravelTimeAndDisutility fttc = new FreespeedTravelTimeAndDisutility(new ScoringConfigGroup()); dijkstra = new DijkstraFactory().createPathCalculator(network, fttc, fttc); } diff --git a/contribs/vsp/src/main/java/playground/vsp/ev/RunUrbanEVExample.java b/contribs/vsp/src/main/java/playground/vsp/ev/RunUrbanEVExample.java index 7a897d37cc4..06f63685f7e 100644 --- a/contribs/vsp/src/main/java/playground/vsp/ev/RunUrbanEVExample.java +++ b/contribs/vsp/src/main/java/playground/vsp/ev/RunUrbanEVExample.java @@ -43,7 +43,6 @@ import java.util.Arrays; import java.util.HashMap; -import java.util.List; import java.util.Map; import org.matsim.api.core.v01.Id; @@ -51,23 +50,19 @@ import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.population.Person; import org.matsim.contrib.ev.EvConfigGroup; -import org.matsim.contrib.ev.EvModule; import org.matsim.contrib.ev.fleet.ElectricVehicleSpecifications; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.PlansCalcRouteConfigGroup; +import org.matsim.core.config.groups.RoutingConfigGroup; import org.matsim.core.config.groups.QSimConfigGroup; import org.matsim.core.controler.Controler; -import org.matsim.core.mobsim.qsim.AbstractQSimModule; -import org.matsim.core.mobsim.qsim.components.QSimComponentsConfigGroup; -import org.matsim.core.modal.AbstractModalQSimModule; import org.matsim.core.scenario.ScenarioUtils; import org.matsim.vehicles.Vehicle; import org.matsim.vehicles.VehicleType; import org.matsim.vehicles.VehicleUtils; import org.matsim.vehicles.VehiclesFactory; -import static org.matsim.core.config.groups.PlanCalcScoreConfigGroup.*; +import static org.matsim.core.config.groups.ScoringConfigGroup.*; /** * this is an example of how to run MATSim with the UrbanEV module which inserts charging activities for all legs which use a EV. @@ -113,7 +108,7 @@ private static Config prepareConfig( String[] args ){ urbanEVConfig.setCriticalSOC(0.4); //TODO actually, should also work with all AccessEgressTypes but we have to check (write JUnit test) - config.plansCalcRoute().setAccessEgressType(PlansCalcRouteConfigGroup.AccessEgressType.none ); + config.plansCalcRoute().setAccessEgressType(RoutingConfigGroup.AccessEgressType.none ); //register charging interaction activities for car config.planCalcScore().addActivityParams( diff --git a/contribs/vsp/src/main/java/playground/vsp/ev/UrbanEVModule.java b/contribs/vsp/src/main/java/playground/vsp/ev/UrbanEVModule.java index 7f64ae48d74..84e59275d7b 100644 --- a/contribs/vsp/src/main/java/playground/vsp/ev/UrbanEVModule.java +++ b/contribs/vsp/src/main/java/playground/vsp/ev/UrbanEVModule.java @@ -20,11 +20,6 @@ package playground.vsp.ev; -import java.util.Collection; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - import org.matsim.contrib.ev.EvModule; import org.matsim.contrib.ev.charging.ChargingModule; import org.matsim.contrib.ev.discharging.DischargingModule; @@ -33,20 +28,19 @@ import org.matsim.contrib.ev.stats.EvStatsModule; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; import org.matsim.core.controler.AbstractModule; import org.matsim.core.mobsim.qsim.AbstractQSimModule; import com.google.inject.Inject; import com.google.inject.Singleton; import org.matsim.core.mobsim.qsim.components.QSimComponentsConfigGroup; -import org.matsim.core.modal.AbstractModalQSimModule; public class UrbanEVModule extends AbstractModule { static final String PLUGIN_IDENTIFIER = " plugin"; - public static final String PLUGIN_INTERACTION = PlanCalcScoreConfigGroup.createStageActivityType( PLUGIN_IDENTIFIER ); + public static final String PLUGIN_INTERACTION = ScoringConfigGroup.createStageActivityType( PLUGIN_IDENTIFIER ); static final String PLUGOUT_IDENTIFIER = " plugout"; - public static final String PLUGOUT_INTERACTION = PlanCalcScoreConfigGroup.createStageActivityType( PLUGOUT_IDENTIFIER ); + public static final String PLUGOUT_INTERACTION = ScoringConfigGroup.createStageActivityType( PLUGOUT_IDENTIFIER ); @Inject private Config config; @Override public void install() { diff --git a/contribs/vsp/src/main/java/playground/vsp/ev/UrbanEVTripsPlanner.java b/contribs/vsp/src/main/java/playground/vsp/ev/UrbanEVTripsPlanner.java index 388a93768dd..1091c7de552 100644 --- a/contribs/vsp/src/main/java/playground/vsp/ev/UrbanEVTripsPlanner.java +++ b/contribs/vsp/src/main/java/playground/vsp/ev/UrbanEVTripsPlanner.java @@ -61,7 +61,7 @@ import org.matsim.contrib.ev.infrastructure.ChargerSpecification; import org.matsim.contrib.ev.infrastructure.ChargingInfrastructureSpecification; import org.matsim.core.config.Config; -import org.matsim.core.config.groups.PlansCalcRouteConfigGroup; +import org.matsim.core.config.groups.RoutingConfigGroup; import org.matsim.core.controler.IterationCounter; import org.matsim.core.controler.OutputDirectoryHierarchy; import org.matsim.core.mobsim.framework.MobsimAgent; @@ -451,7 +451,7 @@ private boolean replanPrecedentAndCurrentEVLegs(MobsimAgent mobsimagent, Plan mo Activity plugoutTripDestination = findRealOrChargingActAfter(mobsimagent, modifiablePlan.getPlanElements().indexOf(plugoutLeg)); { //some consistency checks.. //TODO consider to put in a JUnit test.. - int offset = config.plansCalcRoute().getAccessEgressType().equals(PlansCalcRouteConfigGroup.AccessEgressType.none) ? 1 : 3; + int offset = config.plansCalcRoute().getAccessEgressType().equals(RoutingConfigGroup.AccessEgressType.none) ? 1 : 3; Preconditions.checkNotNull(pluginTripOrigin, "pluginTripOrigin is null. should never happen.."); Preconditions.checkState(!pluginTripOrigin.equals(actWhileCharging), diff --git a/contribs/vsp/src/main/java/playground/vsp/openberlinscenario/planmodification/SplitActivityTypesBasedOnDuration.java b/contribs/vsp/src/main/java/playground/vsp/openberlinscenario/planmodification/SplitActivityTypesBasedOnDuration.java index 43bb865b863..af7be05fd6a 100644 --- a/contribs/vsp/src/main/java/playground/vsp/openberlinscenario/planmodification/SplitActivityTypesBasedOnDuration.java +++ b/contribs/vsp/src/main/java/playground/vsp/openberlinscenario/planmodification/SplitActivityTypesBasedOnDuration.java @@ -28,8 +28,8 @@ import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; import org.matsim.core.config.ConfigWriter; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup.ActivityParams; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup.TypicalDurationScoreComputation; +import org.matsim.core.config.groups.ScoringConfigGroup.ActivityParams; +import org.matsim.core.config.groups.ScoringConfigGroup.TypicalDurationScoreComputation; import org.matsim.core.population.io.PopulationWriter; import org.matsim.core.scenario.ScenarioUtils; @@ -42,7 +42,7 @@ public class SplitActivityTypesBasedOnDuration { private final Logger log = LogManager.getLogger(SplitActivityTypesBasedOnDuration.class); private Scenario scenario; - + public SplitActivityTypesBasedOnDuration(String inputPopulationFile) { Config config = ConfigUtils.createConfig(); config.plans().setInputFile(inputPopulationFile); @@ -53,46 +53,46 @@ public static void main(String[] args) { final String inputPopulationFile = "../../shared-svn/studies/countries/de/open_berlin_scenario/be_5/population/plans_500_10-1_10pct_clc.xml.gz"; final String outputPopulationFile = "../../shared-svn/studies/countries/de/open_berlin_scenario/be_5/population/plans_500_10-1_10pct_clc_act-split.xml.gz"; final String outputConfigFile = "../../shared-svn/studies/countries/de/open_berlin_scenario/be_5/population/config_act-split.xml"; - + final double timeBinSize_s = 600.; - final String[] activityTypes = {ActivityTypes.HOME, ActivityTypes.WORK, ActivityTypes.EDUCATION, ActivityTypes.LEISURE, ActivityTypes.SHOPPING, ActivityTypes.OTHER}; - + final String[] activityTypes = {ActivityTypes.HOME, ActivityTypes.WORK, ActivityTypes.EDUCATION, ActivityTypes.LEISURE, ActivityTypes.SHOPPING, ActivityTypes.OTHER}; + SplitActivityTypesBasedOnDuration splitAct = new SplitActivityTypesBasedOnDuration(inputPopulationFile); splitAct.run(outputPopulationFile, outputConfigFile, timeBinSize_s, activityTypes, 0.0); } public void run(String outputPopulationFile, String outputConfigFile, double timeBinSize_s, String[] activities, double dayStartTime) { - + CemdapPopulationTools tools = new CemdapPopulationTools(); tools.setActivityTypesAccordingToDurationAndMergeOvernightActivities(scenario.getPopulation(), timeBinSize_s, dayStartTime); - + PopulationWriter writer = new PopulationWriter(scenario.getPopulation()); writer.write(outputPopulationFile); - + // Config List initialActivityParams = new ArrayList<>(); - + log.info("Initial activity parameters: "); for (String activity : activities) { ActivityParams params = new ActivityParams(activity); initialActivityParams.add(params); log.info(" -> " + params.getActivityType()); } - + log.info("Adding duration-specific activity types to config..."); - + List newActivityParams = new ArrayList<>(); - + for (ActivityParams actParams : initialActivityParams) { String activityType = actParams.getActivityType(); - + if (activityType.contains("interaction")) { log.info("Skipping activity " + activityType + "..."); } else { log.info("Splitting activity " + activityType + " in duration-specific activities."); double maximumDuration = tools.getMaxEndTime(); - + for (double n = timeBinSize_s; n <= maximumDuration ; n = n + timeBinSize_s) { ActivityParams params = new ActivityParams(activityType + "_" + n); params.setTypicalDuration(n); @@ -101,19 +101,19 @@ public void run(String outputPopulationFile, String outputConfigFile, double tim } } } - + for (ActivityParams actParams : newActivityParams) { scenario.getConfig().planCalcScore().addActivityParams(actParams); } - + log.info("New activity parameters: "); for (ActivityParams actParams : scenario.getConfig().planCalcScore().getActivityParams()) { initialActivityParams.add(actParams); log.info(" -> " + actParams.getActivityType()); } - + log.info("Adding duration-specific activity types to config... Done."); ConfigWriter configWriter = new ConfigWriter(scenario.getConfig()); configWriter.write(outputConfigFile); } -} \ No newline at end of file +} diff --git a/contribs/vsp/src/main/java/playground/vsp/parkAndRide/example/PRRunner.java b/contribs/vsp/src/main/java/playground/vsp/parkAndRide/example/PRRunner.java index 36a22a46b14..094cacd5883 100644 --- a/contribs/vsp/src/main/java/playground/vsp/parkAndRide/example/PRRunner.java +++ b/contribs/vsp/src/main/java/playground/vsp/parkAndRide/example/PRRunner.java @@ -19,7 +19,7 @@ * *********************************************************************** */ /** - * + * */ package playground.vsp.parkAndRide.example; @@ -30,7 +30,7 @@ import org.matsim.api.core.v01.Id; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup.ActivityParams; +import org.matsim.core.config.groups.ScoringConfigGroup.ActivityParams; import org.matsim.core.controler.AbstractModule; import org.matsim.core.controler.Controler; import org.matsim.core.controler.OutputDirectoryHierarchy; @@ -52,23 +52,23 @@ * */ public class PRRunner { - + static String configFile; - + public static void main(String[] args) throws IOException { - + configFile = "/path-to/config.xml"; - + PRRunner main = new PRRunner(); main.run(); } - + private void run() { - + Config config = new Config(); config.addModule(new PRConfigGroup()); ConfigUtils.loadConfig(config, configFile); - + final Controler controler = new Controler(config); controler.getConfig().controler().setOverwriteFileSetting( true ? @@ -82,7 +82,7 @@ private void run() { controler.getConfig().planCalcScore().addActivityParams(prActivityParams); controler.setScoringFunctionFactory(new PRScoringFunctionFactory(controler.getScenario(), prSettings.getIntermodalTransferPenalty())); - + PRFileReader prReader = new PRFileReader(prSettings.getInputFile()); Map, PRFacility> id2prFacility = prReader.getId2prFacility(); final PRAdaptiveCapacityControl adaptiveControl = new PRAdaptiveCapacityControl(id2prFacility); @@ -105,8 +105,8 @@ public Mobsim get() { }); controler.run(); - + } } - + diff --git a/contribs/vsp/src/main/java/playground/vsp/planselectors/InitialPlanKeeperPlanRemoval.java b/contribs/vsp/src/main/java/playground/vsp/planselectors/InitialPlanKeeperPlanRemoval.java index eb5c39bd9cd..e99af53d6cc 100644 --- a/contribs/vsp/src/main/java/playground/vsp/planselectors/InitialPlanKeeperPlanRemoval.java +++ b/contribs/vsp/src/main/java/playground/vsp/planselectors/InitialPlanKeeperPlanRemoval.java @@ -24,12 +24,11 @@ import java.util.Objects; import jakarta.inject.Inject; import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.population.HasPlansAndId; import org.matsim.api.core.v01.population.Person; import org.matsim.api.core.v01.population.Plan; import org.matsim.api.core.v01.population.Population; -import org.matsim.core.config.groups.StrategyConfigGroup; +import org.matsim.core.config.groups.ReplanningConfigGroup; import org.matsim.core.replanning.selectors.PlanSelector; import org.matsim.core.replanning.selectors.WorstPlanForRemovalSelector; @@ -48,13 +47,13 @@ public class InitialPlanKeeperPlanRemoval implements PlanSelector private final WorstPlanForRemovalSelector delegate; @Inject - public InitialPlanKeeperPlanRemoval(StrategyConfigGroup strategyConfigGroup, Population population){ + public InitialPlanKeeperPlanRemoval(ReplanningConfigGroup replanningConfigGroup, Population population){ this.delegate = new WorstPlanForRemovalSelector(); - if ( strategyConfigGroup.getMaxAgentPlanMemorySize() < 12) { + if ( replanningConfigGroup.getMaxAgentPlanMemorySize() < 12) { LogManager.getLogger(InitialPlanKeeperPlanRemoval.class).warn("A plans remover is used which keeps the initial plans or at least their copy \n " + - "and maximum number of plans in the choice set is limited to "+ strategyConfigGroup.getMaxAgentPlanMemorySize()+ + "and maximum number of plans in the choice set is limited to "+ replanningConfigGroup.getMaxAgentPlanMemorySize()+ ".\n Lower number of plans in choice set is likely to end up in infinite loop. Setting it to 15."); - strategyConfigGroup.setMaxAgentPlanMemorySize(15); + replanningConfigGroup.setMaxAgentPlanMemorySize(15); } for (Person person : population.getPersons().values()){ diff --git a/contribs/vsp/src/main/java/playground/vsp/scoring/IncomeDependentUtilityOfMoneyPersonScoringParameters.java b/contribs/vsp/src/main/java/playground/vsp/scoring/IncomeDependentUtilityOfMoneyPersonScoringParameters.java index 2c6398f2937..c25bed0527a 100644 --- a/contribs/vsp/src/main/java/playground/vsp/scoring/IncomeDependentUtilityOfMoneyPersonScoringParameters.java +++ b/contribs/vsp/src/main/java/playground/vsp/scoring/IncomeDependentUtilityOfMoneyPersonScoringParameters.java @@ -24,7 +24,7 @@ import org.matsim.api.core.v01.IdMap; import org.matsim.api.core.v01.population.Person; import org.matsim.api.core.v01.population.Population; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; import org.matsim.core.config.groups.ScenarioConfigGroup; import org.matsim.core.population.PersonUtils; import org.matsim.core.population.PopulationUtils; @@ -56,7 +56,7 @@ */ public class IncomeDependentUtilityOfMoneyPersonScoringParameters implements ScoringParametersForPerson { Logger log = LogManager.getLogger(IncomeDependentUtilityOfMoneyPersonScoringParameters.class); - private final PlanCalcScoreConfigGroup config; + private final ScoringConfigGroup config; private final ScenarioConfigGroup scConfig; private final TransitConfigGroup transitConfigGroup; private final Map, ScoringParameters> params = new IdMap<>(Person.class); @@ -64,8 +64,8 @@ public class IncomeDependentUtilityOfMoneyPersonScoringParameters implements Sco private final Map> activityParamsPerSubpopulation = new ConcurrentHashMap<>(); @Inject - IncomeDependentUtilityOfMoneyPersonScoringParameters(Population population, PlanCalcScoreConfigGroup planCalcScoreConfigGroup, ScenarioConfigGroup scenarioConfigGroup, TransitConfigGroup transitConfigGroup) { - this.config = planCalcScoreConfigGroup; + IncomeDependentUtilityOfMoneyPersonScoringParameters(Population population, ScoringConfigGroup scoringConfigGroup, ScenarioConfigGroup scenarioConfigGroup, TransitConfigGroup transitConfigGroup) { + this.config = scoringConfigGroup; this.scConfig = scenarioConfigGroup; this.transitConfigGroup = transitConfigGroup; this.globalAvgIncome = computeAvgIncome(population); @@ -110,13 +110,13 @@ public ScoringParameters getScoringParameters(Person person) { * point of view than giving each ScoringFunction its own copy of the params. */ - PlanCalcScoreConfigGroup.ScoringParameterSet subpopulationScoringParams = this.config.getScoringParameters(subpopulation); + ScoringConfigGroup.ScoringParameterSet subpopulationScoringParams = this.config.getScoringParameters(subpopulation); // (we can set scoring params per subpopulation, so retrieve them as starting point. kai, apr'22) // save the activityParams of the subpopulation so we need to build them only once. this.activityParamsPerSubpopulation.computeIfAbsent(subpopulation, k -> { Map activityParams = new TreeMap<>(); - for (PlanCalcScoreConfigGroup.ActivityParams params : subpopulationScoringParams.getActivityParams()) { + for (ScoringConfigGroup.ActivityParams params : subpopulationScoringParams.getActivityParams()) { ActivityUtilityParameters.Builder factory = new ActivityUtilityParameters.Builder(params); activityParams.put(params.getActivityType(), factory.build()); } @@ -130,7 +130,7 @@ public ScoringParameters getScoringParameters(Person person) { if (transitConfigGroup.isUseTransit()) { // this is the PT stage activity: - PlanCalcScoreConfigGroup.ActivityParams transitActivityParams = new PlanCalcScoreConfigGroup.ActivityParams(PtConstants.TRANSIT_ACTIVITY_TYPE); + ScoringConfigGroup.ActivityParams transitActivityParams = new ScoringConfigGroup.ActivityParams(PtConstants.TRANSIT_ACTIVITY_TYPE); transitActivityParams.setTypicalDuration(120.0); transitActivityParams.setOpeningTime(0.); transitActivityParams.setClosingTime(0.); diff --git a/contribs/vsp/src/test/java/org/matsim/core/scoring/functions/PersonScoringParametersFromPersonAttributesNoSubpopulationTest.java b/contribs/vsp/src/test/java/org/matsim/core/scoring/functions/PersonScoringParametersFromPersonAttributesNoSubpopulationTest.java index 4085cb20f81..bb9ca23ac4a 100644 --- a/contribs/vsp/src/test/java/org/matsim/core/scoring/functions/PersonScoringParametersFromPersonAttributesNoSubpopulationTest.java +++ b/contribs/vsp/src/test/java/org/matsim/core/scoring/functions/PersonScoringParametersFromPersonAttributesNoSubpopulationTest.java @@ -27,7 +27,7 @@ import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.population.*; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; import org.matsim.core.config.groups.ScenarioConfigGroup; import org.matsim.core.network.NetworkUtils; import org.matsim.core.population.PersonUtils; @@ -59,13 +59,13 @@ public class PersonScoringParametersFromPersonAttributesNoSubpopulationTest { public void setUp() { TransitConfigGroup transitConfigGroup = new TransitConfigGroup(); ScenarioConfigGroup scenarioConfigGroup = new ScenarioConfigGroup(); - PlanCalcScoreConfigGroup planCalcScoreConfigGroup = new PlanCalcScoreConfigGroup(); + ScoringConfigGroup scoringConfigGroup = new ScoringConfigGroup(); - PlanCalcScoreConfigGroup.ScoringParameterSet personParams = planCalcScoreConfigGroup.getOrCreateScoringParameters(null); + ScoringConfigGroup.ScoringParameterSet personParams = scoringConfigGroup.getOrCreateScoringParameters(null); personParams.setMarginalUtilityOfMoney(1); personParams.setMarginalUtlOfWaitingPt_utils_hr(0.5 * 3600); - PlanCalcScoreConfigGroup.ModeParams modeParamsCar = new PlanCalcScoreConfigGroup.ModeParams(TransportMode.car); + ScoringConfigGroup.ModeParams modeParamsCar = new ScoringConfigGroup.ModeParams(TransportMode.car); modeParamsCar.setConstant(-1.0); modeParamsCar.setMarginalUtilityOfTraveling(-0.001); modeParamsCar.setMarginalUtilityOfDistance(-0.002); @@ -74,7 +74,7 @@ public void setUp() { modeParamsCar.setDailyUtilityConstant(-0.3); personParams.addModeParams(modeParamsCar); - PlanCalcScoreConfigGroup.ModeParams modeParamsBike = new PlanCalcScoreConfigGroup.ModeParams(TransportMode.bike); + ScoringConfigGroup.ModeParams modeParamsBike = new ScoringConfigGroup.ModeParams(TransportMode.bike); modeParamsBike.setConstant(-0.55); modeParamsBike.setMarginalUtilityOfTraveling(-0.05); modeParamsBike.setMarginalUtilityOfDistance(-0.003); @@ -118,7 +118,7 @@ public void setUp() { } personScoringParams = new PersonScoringParametersFromPersonAttributes(population, - planCalcScoreConfigGroup, + scoringConfigGroup, scenarioConfigGroup, transitConfigGroup); } @@ -228,4 +228,4 @@ private void makeAssertMarginalUtilityOfMoneyAndPtWait(ScoringParameters params, } -} \ No newline at end of file +} diff --git a/contribs/vsp/src/test/java/org/matsim/core/scoring/functions/PersonScoringParametersFromPersonAttributesTest.java b/contribs/vsp/src/test/java/org/matsim/core/scoring/functions/PersonScoringParametersFromPersonAttributesTest.java index a11283749de..cb7da7c9069 100644 --- a/contribs/vsp/src/test/java/org/matsim/core/scoring/functions/PersonScoringParametersFromPersonAttributesTest.java +++ b/contribs/vsp/src/test/java/org/matsim/core/scoring/functions/PersonScoringParametersFromPersonAttributesTest.java @@ -27,7 +27,7 @@ import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.population.*; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; import org.matsim.core.config.groups.ScenarioConfigGroup; import org.matsim.core.network.NetworkUtils; import org.matsim.core.population.PersonUtils; @@ -59,13 +59,13 @@ public class PersonScoringParametersFromPersonAttributesTest { public void setUp() { TransitConfigGroup transitConfigGroup = new TransitConfigGroup(); ScenarioConfigGroup scenarioConfigGroup = new ScenarioConfigGroup(); - PlanCalcScoreConfigGroup planCalcScoreConfigGroup = new PlanCalcScoreConfigGroup(); + ScoringConfigGroup scoringConfigGroup = new ScoringConfigGroup(); - PlanCalcScoreConfigGroup.ScoringParameterSet personParams = planCalcScoreConfigGroup.getOrCreateScoringParameters("person"); + ScoringConfigGroup.ScoringParameterSet personParams = scoringConfigGroup.getOrCreateScoringParameters("person"); personParams.setMarginalUtilityOfMoney(1); personParams.setMarginalUtlOfWaitingPt_utils_hr(0.5 * 3600); - PlanCalcScoreConfigGroup.ModeParams modeParamsCar = new PlanCalcScoreConfigGroup.ModeParams(TransportMode.car); + ScoringConfigGroup.ModeParams modeParamsCar = new ScoringConfigGroup.ModeParams(TransportMode.car); modeParamsCar.setConstant(-1.0); modeParamsCar.setMarginalUtilityOfTraveling(-0.001); modeParamsCar.setMarginalUtilityOfDistance(-0.002); @@ -74,14 +74,14 @@ public void setUp() { modeParamsCar.setDailyUtilityConstant(-0.3); personParams.addModeParams(modeParamsCar); - PlanCalcScoreConfigGroup.ModeParams modeParamsBike = new PlanCalcScoreConfigGroup.ModeParams(TransportMode.bike); + ScoringConfigGroup.ModeParams modeParamsBike = new ScoringConfigGroup.ModeParams(TransportMode.bike); modeParamsBike.setConstant(-0.55); modeParamsBike.setMarginalUtilityOfTraveling(-0.05); modeParamsBike.setMarginalUtilityOfDistance(-0.003); modeParamsBike.setMonetaryDistanceRate(-0.002); personParams.addModeParams(modeParamsBike); - PlanCalcScoreConfigGroup.ScoringParameterSet freightParams = planCalcScoreConfigGroup.getOrCreateScoringParameters("freight"); + ScoringConfigGroup.ScoringParameterSet freightParams = scoringConfigGroup.getOrCreateScoringParameters("freight"); freightParams.setMarginalUtilityOfMoney(444); freightParams.setMarginalUtlOfWaitingPt_utils_hr(1d * 3600); @@ -140,7 +140,7 @@ public void setUp() { population.addPerson(freightWithIncome2); } personScoringParams = new PersonScoringParametersFromPersonAttributes(population, - planCalcScoreConfigGroup, + scoringConfigGroup, scenarioConfigGroup, transitConfigGroup); } @@ -268,4 +268,4 @@ private void makeAssertMarginalUtilityOfMoneyAndPtWait(ScoringParameters params, } -} \ No newline at end of file +} diff --git a/contribs/vsp/src/test/java/org/matsim/integration/drtAndPt/PtAlongALine2Test.java b/contribs/vsp/src/test/java/org/matsim/integration/drtAndPt/PtAlongALine2Test.java index e4e04cc74f7..9a97b6a9ce6 100644 --- a/contribs/vsp/src/test/java/org/matsim/integration/drtAndPt/PtAlongALine2Test.java +++ b/contribs/vsp/src/test/java/org/matsim/integration/drtAndPt/PtAlongALine2Test.java @@ -36,9 +36,9 @@ import org.matsim.contrib.otfvis.OTFVisLiveModule; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup.ModeParams; -import org.matsim.core.config.groups.PlansCalcRouteConfigGroup; -import org.matsim.core.config.groups.PlansCalcRouteConfigGroup.AccessEgressType; +import org.matsim.core.config.groups.ScoringConfigGroup.ModeParams; +import org.matsim.core.config.groups.RoutingConfigGroup; +import org.matsim.core.config.groups.RoutingConfigGroup.AccessEgressType; import org.matsim.core.config.groups.QSimConfigGroup; import org.matsim.core.config.groups.VspExperimentalConfigGroup; import org.matsim.core.controler.AbstractModule; @@ -119,16 +119,16 @@ public void testPtAlongALineWithRaptorAndDrtServiceArea() { if (drtMode == DrtMode.teleportBeeline) {// (configure teleportation router) config.plansCalcRoute() .addModeRoutingParams( - new PlansCalcRouteConfigGroup.TeleportedModeParams().setMode(TransportMode.drt ).setTeleportedModeSpeed(100. / 3.6 ) ); + new RoutingConfigGroup.TeleportedModeParams().setMode(TransportMode.drt ).setTeleportedModeSpeed(100. / 3.6 ) ); if (drt2) { config.plansCalcRoute() .addModeRoutingParams( - new PlansCalcRouteConfigGroup.TeleportedModeParams().setMode("drt2" ).setTeleportedModeSpeed(100. / 3.6 ) ); + new RoutingConfigGroup.TeleportedModeParams().setMode("drt2" ).setTeleportedModeSpeed(100. / 3.6 ) ); } if (drt3) { config.plansCalcRoute() .addModeRoutingParams( - new PlansCalcRouteConfigGroup.TeleportedModeParams().setMode("drt3" ).setTeleportedModeSpeed(100. / 3.6 ) ); + new RoutingConfigGroup.TeleportedModeParams().setMode("drt3" ).setTeleportedModeSpeed(100. / 3.6 ) ); } // teleportation router for walk or bike is automatically defined. } else if (drtMode == DrtMode.teleportBasedOnNetworkRoute) {// (route as network route) @@ -144,11 +144,11 @@ public void testPtAlongALineWithRaptorAndDrtServiceArea() { } config.plansCalcRoute() - .addModeRoutingParams(new PlansCalcRouteConfigGroup.TeleportedModeParams().setMode("walk" ).setTeleportedModeSpeed(5. / 3.6 ) ); + .addModeRoutingParams(new RoutingConfigGroup.TeleportedModeParams().setMode("walk" ).setTeleportedModeSpeed(5. / 3.6 ) ); // set up walk2 so we don't need walk in raptor: config.plansCalcRoute() - .addModeRoutingParams(new PlansCalcRouteConfigGroup.TeleportedModeParams().setMode("walk2" ).setTeleportedModeSpeed(5. / 3.6 ) ); + .addModeRoutingParams(new RoutingConfigGroup.TeleportedModeParams().setMode("walk2" ).setTeleportedModeSpeed(5. / 3.6 ) ); // === RAPTOR: === { @@ -597,7 +597,7 @@ public void intermodalAccessEgressPicksWrongVariant() { // === ROUTER: === - config.plansCalcRoute().setAccessEgressType(PlansCalcRouteConfigGroup.AccessEgressType.accessEgressModeToLink); + config.plansCalcRoute().setAccessEgressType(RoutingConfigGroup.AccessEgressType.accessEgressModeToLink); config.qsim().setVehiclesSource(QSimConfigGroup.VehiclesSource.modeVehicleTypesFromVehiclesData); // (as of today, will also influence router. kai, jun'19) @@ -605,10 +605,10 @@ public void intermodalAccessEgressPicksWrongVariant() { config.plansCalcRoute().setNetworkModes(new HashSet<>(Arrays.asList(TransportMode.drt, "drt2"))); // set up walk2 so we don't use faulty walk in raptor: - config.plansCalcRoute().addModeRoutingParams(new PlansCalcRouteConfigGroup.TeleportedModeParams("walk2").setTeleportedModeSpeed(5. / 3.6 ) ); + config.plansCalcRoute().addModeRoutingParams(new RoutingConfigGroup.TeleportedModeParams("walk2").setTeleportedModeSpeed(5. / 3.6 ) ); config.plansCalcRoute() - .addModeRoutingParams(new PlansCalcRouteConfigGroup.TeleportedModeParams(TransportMode.walk).setTeleportedModeSpeed(0. ) ); + .addModeRoutingParams(new RoutingConfigGroup.TeleportedModeParams(TransportMode.walk).setTeleportedModeSpeed(0. ) ); // (when specifying "walk2", all default routing params are cleared. However, swiss rail raptor needs "walk" to function. kai, feb'20) // === RAPTOR: === diff --git a/contribs/vsp/src/test/java/org/matsim/integration/drtAndPt/PtAlongALineTest.java b/contribs/vsp/src/test/java/org/matsim/integration/drtAndPt/PtAlongALineTest.java index bf402c506bc..c01005e567c 100644 --- a/contribs/vsp/src/test/java/org/matsim/integration/drtAndPt/PtAlongALineTest.java +++ b/contribs/vsp/src/test/java/org/matsim/integration/drtAndPt/PtAlongALineTest.java @@ -27,10 +27,10 @@ import org.matsim.contrib.dvrp.run.DvrpQSimComponents; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup.ModeParams; -import org.matsim.core.config.groups.PlansCalcRouteConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup.ModeParams; +import org.matsim.core.config.groups.RoutingConfigGroup; import org.matsim.core.config.groups.QSimConfigGroup; -import org.matsim.core.config.groups.StrategyConfigGroup; +import org.matsim.core.config.groups.ReplanningConfigGroup; import org.matsim.core.config.groups.VspExperimentalConfigGroup; import org.matsim.core.controler.Controler; import org.matsim.core.controler.OutputDirectoryHierarchy; @@ -128,7 +128,7 @@ public void testDrtAlongALine() { .setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists); { - StrategyConfigGroup.StrategySettings stratSets = new StrategyConfigGroup.StrategySettings(); + ReplanningConfigGroup.StrategySettings stratSets = new ReplanningConfigGroup.StrategySettings(); stratSets.setStrategyName(DefaultPlanStrategiesModule.DefaultStrategy.SubtourModeChoice); stratSets.setWeight(0.1); config.strategy().addStrategySettings(stratSets); @@ -136,7 +136,7 @@ public void testDrtAlongALine() { config.subtourModeChoice().setModes(new String[] { TransportMode.car, "drt_A" }); } { - StrategyConfigGroup.StrategySettings stratSets = new StrategyConfigGroup.StrategySettings(); + ReplanningConfigGroup.StrategySettings stratSets = new ReplanningConfigGroup.StrategySettings(); stratSets.setStrategyName(DefaultPlanStrategiesModule.DefaultSelector.ChangeExpBeta); stratSets.setWeight(1.); config.strategy().addStrategySettings(stratSets); @@ -210,7 +210,7 @@ public void testPtAlongALineWithRaptorAndDrtStopFilterAttribute() { config.qsim().setSimStarttimeInterpretation(QSimConfigGroup.StarttimeInterpretation.onlyUseStarttime); // yy why? kai, jun'19 - config.plansCalcRoute().setAccessEgressType(PlansCalcRouteConfigGroup.AccessEgressType.accessEgressModeToLink); + config.plansCalcRoute().setAccessEgressType(RoutingConfigGroup.AccessEgressType.accessEgressModeToLink); ModeParams accessWalk = new ModeParams(TransportMode.non_network_walk); accessWalk.setMarginalUtilityOfTraveling(0); config.planCalcScore().addModeParams(accessWalk); diff --git a/contribs/vsp/src/test/java/playground/vsp/cadyts/marginals/ModalDistanceAndCountsCadytsIT.java b/contribs/vsp/src/test/java/playground/vsp/cadyts/marginals/ModalDistanceAndCountsCadytsIT.java index ce790c4d024..2164553bb3b 100644 --- a/contribs/vsp/src/test/java/playground/vsp/cadyts/marginals/ModalDistanceAndCountsCadytsIT.java +++ b/contribs/vsp/src/test/java/playground/vsp/cadyts/marginals/ModalDistanceAndCountsCadytsIT.java @@ -89,13 +89,13 @@ private Config createConfig() { config.counts().setWriteCountsInterval(1); config.counts().setAverageCountsOverIterations(1); - PlanCalcScoreConfigGroup.ActivityParams home = new PlanCalcScoreConfigGroup.ActivityParams("home"); + ScoringConfigGroup.ActivityParams home = new ScoringConfigGroup.ActivityParams("home"); home.setMinimalDuration(3600); home.setTypicalDuration(3600); home.setEarliestEndTime(0); config.planCalcScore().addActivityParams(home); - PlanCalcScoreConfigGroup.ActivityParams work = new PlanCalcScoreConfigGroup.ActivityParams("work"); + ScoringConfigGroup.ActivityParams work = new ScoringConfigGroup.ActivityParams("work"); work.setMinimalDuration(3600); work.setTypicalDuration(3600); work.setEarliestEndTime(0); @@ -104,21 +104,21 @@ private Config createConfig() { config.planCalcScore().addActivityParams(work); // have random selection of plans to generate heterogenity in the beginning, so that cadyts can calibrate its correction - StrategyConfigGroup.StrategySettings selectRandom = new StrategyConfigGroup.StrategySettings(); + ReplanningConfigGroup.StrategySettings selectRandom = new ReplanningConfigGroup.StrategySettings(); selectRandom.setStrategyName(DefaultPlanStrategiesModule.DefaultSelector.SelectRandom); selectRandom.setDisableAfter(33); selectRandom.setWeight(0.5); config.strategy().addStrategySettings(selectRandom); // have change exp beta, so that mode distribution converges at the end of the simulation - StrategyConfigGroup.StrategySettings changeExpBeta = new StrategyConfigGroup.StrategySettings(); + ReplanningConfigGroup.StrategySettings changeExpBeta = new ReplanningConfigGroup.StrategySettings(); changeExpBeta.setStrategyName(DefaultPlanStrategiesModule.DefaultSelector.ChangeExpBeta); changeExpBeta.setDisableAfter(38); changeExpBeta.setWeight(0.5); config.strategy().addStrategySettings(changeExpBeta); // at the end of the scenario pick the plans with the best score - StrategyConfigGroup.StrategySettings bestScore = new StrategyConfigGroup.StrategySettings(); + ReplanningConfigGroup.StrategySettings bestScore = new ReplanningConfigGroup.StrategySettings(); bestScore.setStrategyName(DefaultPlanStrategiesModule.DefaultSelector.BestScore); bestScore.setWeight(0.1); config.strategy().addStrategySettings(bestScore); @@ -126,7 +126,7 @@ private Config createConfig() { // remove teleported bike config.plansCalcRoute().removeModeRoutingParams(TransportMode.bike); config.plansCalcRoute().setNetworkModes(Arrays.asList(modes)); - config.plansCalcRoute().setAccessEgressType(PlansCalcRouteConfigGroup.AccessEgressType.accessEgressModeToLink); + config.plansCalcRoute().setAccessEgressType(RoutingConfigGroup.AccessEgressType.accessEgressModeToLink); config.qsim().setMainModes(Arrays.asList(modes)); config.qsim().setLinkDynamics(QSimConfigGroup.LinkDynamics.PassingQ); diff --git a/contribs/vsp/src/test/java/playground/vsp/cadyts/marginals/ModalDistanceCadytsMultipleDistancesIT.java b/contribs/vsp/src/test/java/playground/vsp/cadyts/marginals/ModalDistanceCadytsMultipleDistancesIT.java index 8825758ec04..124c01956d1 100644 --- a/contribs/vsp/src/test/java/playground/vsp/cadyts/marginals/ModalDistanceCadytsMultipleDistancesIT.java +++ b/contribs/vsp/src/test/java/playground/vsp/cadyts/marginals/ModalDistanceCadytsMultipleDistancesIT.java @@ -16,10 +16,10 @@ import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; import org.matsim.core.config.groups.ChangeModeConfigGroup; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; -import org.matsim.core.config.groups.PlansCalcRouteConfigGroup.AccessEgressType; +import org.matsim.core.config.groups.ReplanningConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; +import org.matsim.core.config.groups.RoutingConfigGroup.AccessEgressType; import org.matsim.core.config.groups.QSimConfigGroup; -import org.matsim.core.config.groups.StrategyConfigGroup; import org.matsim.core.controler.AbstractModule; import org.matsim.core.controler.Controler; import org.matsim.core.controler.OutputDirectoryHierarchy; @@ -144,13 +144,13 @@ private Config createConfig() { config.counts().setWriteCountsInterval(1); config.counts().setAverageCountsOverIterations(1); - PlanCalcScoreConfigGroup.ActivityParams home = new PlanCalcScoreConfigGroup.ActivityParams("home"); + ScoringConfigGroup.ActivityParams home = new ScoringConfigGroup.ActivityParams("home"); home.setMinimalDuration(6 * 3600); home.setTypicalDuration(6 * 3600); home.setEarliestEndTime(6 * 3600); config.planCalcScore().addActivityParams(home); - PlanCalcScoreConfigGroup.ActivityParams work = new PlanCalcScoreConfigGroup.ActivityParams("work"); + ScoringConfigGroup.ActivityParams work = new ScoringConfigGroup.ActivityParams("work"); work.setMinimalDuration(8 * 3600); work.setTypicalDuration(8 * 3600); work.setEarliestEndTime(14 * 3600); @@ -159,14 +159,14 @@ private Config createConfig() { config.planCalcScore().addActivityParams(work); // have random selection of plans to generate heterogenity in the beginning, so that cadyts can calibrate its correction - StrategyConfigGroup.StrategySettings selectRandom = new StrategyConfigGroup.StrategySettings(); + ReplanningConfigGroup.StrategySettings selectRandom = new ReplanningConfigGroup.StrategySettings(); selectRandom.setStrategyName(DefaultPlanStrategiesModule.DefaultSelector.SelectRandom); selectRandom.setDisableAfter(17); selectRandom.setWeight(0.5); config.strategy().addStrategySettings(selectRandom); // have change exp beta, so that mode distribution converges at the end of the simulation - StrategyConfigGroup.StrategySettings changeExpBeta = new StrategyConfigGroup.StrategySettings(); + ReplanningConfigGroup.StrategySettings changeExpBeta = new ReplanningConfigGroup.StrategySettings(); changeExpBeta.setStrategyName(DefaultPlanStrategiesModule.DefaultSelector.ChangeExpBeta); changeExpBeta.setWeight(0.5); config.strategy().addStrategySettings(changeExpBeta); diff --git a/contribs/vsp/src/test/java/playground/vsp/cadyts/marginals/ModalDistanceCadytsSingleDistanceIT.java b/contribs/vsp/src/test/java/playground/vsp/cadyts/marginals/ModalDistanceCadytsSingleDistanceIT.java index bea4e17654b..3f60fa30150 100644 --- a/contribs/vsp/src/test/java/playground/vsp/cadyts/marginals/ModalDistanceCadytsSingleDistanceIT.java +++ b/contribs/vsp/src/test/java/playground/vsp/cadyts/marginals/ModalDistanceCadytsSingleDistanceIT.java @@ -148,13 +148,13 @@ private Config createConfig() { config.counts().setWriteCountsInterval(1); config.counts().setAverageCountsOverIterations(1); - PlanCalcScoreConfigGroup.ActivityParams home = new PlanCalcScoreConfigGroup.ActivityParams("home"); + ScoringConfigGroup.ActivityParams home = new ScoringConfigGroup.ActivityParams("home"); home.setMinimalDuration(6 * 3600); home.setTypicalDuration(6 * 3600); home.setEarliestEndTime(6 * 3600); config.planCalcScore().addActivityParams(home); - PlanCalcScoreConfigGroup.ActivityParams work = new PlanCalcScoreConfigGroup.ActivityParams("work"); + ScoringConfigGroup.ActivityParams work = new ScoringConfigGroup.ActivityParams("work"); work.setMinimalDuration(8 * 3600); work.setTypicalDuration(8 * 3600); work.setEarliestEndTime(14 * 3600); @@ -163,14 +163,14 @@ private Config createConfig() { config.planCalcScore().addActivityParams(work); // have random selection of plans to generate heterogenity in the beginning, so that cadyts can calibrate its correction - StrategyConfigGroup.StrategySettings selectRandom = new StrategyConfigGroup.StrategySettings(); + ReplanningConfigGroup.StrategySettings selectRandom = new ReplanningConfigGroup.StrategySettings(); selectRandom.setStrategyName(DefaultPlanStrategiesModule.DefaultSelector.SelectRandom); selectRandom.setDisableAfter(17); selectRandom.setWeight(0.5); config.strategy().addStrategySettings(selectRandom); // have change exp beta, so that mode distribution converges at the end of the simulation - StrategyConfigGroup.StrategySettings changeExpBeta = new StrategyConfigGroup.StrategySettings(); + ReplanningConfigGroup.StrategySettings changeExpBeta = new ReplanningConfigGroup.StrategySettings(); changeExpBeta.setStrategyName(DefaultPlanStrategiesModule.DefaultSelector.ChangeExpBeta); changeExpBeta.setWeight(0.5); config.strategy().addStrategySettings(changeExpBeta); @@ -178,7 +178,7 @@ private Config createConfig() { // remove teleported bike config.plansCalcRoute().removeModeRoutingParams(TransportMode.bike); config.plansCalcRoute().setNetworkModes(Arrays.asList(modes)); - config.plansCalcRoute().setAccessEgressType(PlansCalcRouteConfigGroup.AccessEgressType.accessEgressModeToLink); + config.plansCalcRoute().setAccessEgressType(RoutingConfigGroup.AccessEgressType.accessEgressModeToLink); config.qsim().setMainModes(Arrays.asList(modes)); config.qsim().setLinkDynamics(QSimConfigGroup.LinkDynamics.PassingQ); diff --git a/contribs/vsp/src/test/java/playground/vsp/cadyts/marginals/TripEventHandlerTest.java b/contribs/vsp/src/test/java/playground/vsp/cadyts/marginals/TripEventHandlerTest.java index d3f39021329..baeb3517fc9 100644 --- a/contribs/vsp/src/test/java/playground/vsp/cadyts/marginals/TripEventHandlerTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/cadyts/marginals/TripEventHandlerTest.java @@ -8,7 +8,7 @@ import org.matsim.api.core.v01.population.Person; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.PlansCalcRouteConfigGroup; +import org.matsim.core.config.groups.RoutingConfigGroup; import org.matsim.core.config.groups.PlansConfigGroup.HandlingOfPlansWithoutRoutingMode; import org.matsim.core.controler.AbstractModule; import org.matsim.core.controler.Controler; @@ -52,7 +52,7 @@ public void test() throws MalformedURLException { config.controler().setLastIteration(0); config.controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists); config.controler().setOutputDirectory(utils.getOutputDirectory()); - config.plansCalcRoute().setAccessEgressType(PlansCalcRouteConfigGroup.AccessEgressType.accessEgressModeToLink); + config.plansCalcRoute().setAccessEgressType(RoutingConfigGroup.AccessEgressType.accessEgressModeToLink); Scenario scenario = ScenarioUtils.loadScenario(config); @@ -107,4 +107,4 @@ public void install() { assertEquals(TransportMode.pt, tripsOfPerson102.get(2).getLegs().get(1).getMode()); assertEquals(TransportMode.walk, tripsOfPerson102.get(2).getLegs().get(2).getMode()); } -} \ No newline at end of file +} diff --git a/contribs/vsp/src/test/java/playground/vsp/congestion/AdvancedMarginalCongestionPricingIT.java b/contribs/vsp/src/test/java/playground/vsp/congestion/AdvancedMarginalCongestionPricingIT.java index 5403d398a2a..8c299d141e6 100644 --- a/contribs/vsp/src/test/java/playground/vsp/congestion/AdvancedMarginalCongestionPricingIT.java +++ b/contribs/vsp/src/test/java/playground/vsp/congestion/AdvancedMarginalCongestionPricingIT.java @@ -42,9 +42,9 @@ import org.matsim.core.api.experimental.events.EventsManager; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup.ActivityParams; -import org.matsim.core.config.groups.PlansCalcRouteConfigGroup.AccessEgressType; +import org.matsim.core.config.groups.ScoringConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup.ActivityParams; +import org.matsim.core.config.groups.RoutingConfigGroup.AccessEgressType; import org.matsim.core.config.groups.ScenarioConfigGroup; import org.matsim.core.controler.AbstractModule; import org.matsim.core.controler.Controler; @@ -78,7 +78,7 @@ public class AdvancedMarginalCongestionPricingIT { @Test public final void test0a(){ - PlanCalcScoreConfigGroup plansCalcScoreConfigGroup = new PlanCalcScoreConfigGroup(); + ScoringConfigGroup plansCalcScoreConfigGroup = new ScoringConfigGroup(); ActivityParams activityParams = new ActivityParams("work"); activityParams.setTypicalDuration(6 * 3600.); activityParams.setOpeningTime(7 * 3600.); @@ -143,7 +143,7 @@ public final void test0a(){ @Test public final void test0b(){ - PlanCalcScoreConfigGroup plansCalcScoreConfigGroup = new PlanCalcScoreConfigGroup(); + ScoringConfigGroup plansCalcScoreConfigGroup = new ScoringConfigGroup(); ActivityParams activityParams = new ActivityParams("overnightActivity"); activityParams.setTypicalDuration(12 * 3600.); @@ -191,7 +191,7 @@ public final void test0b(){ @Test public final void test0c(){ - PlanCalcScoreConfigGroup plansCalcScoreConfigGroup = new PlanCalcScoreConfigGroup(); + ScoringConfigGroup plansCalcScoreConfigGroup = new ScoringConfigGroup(); ActivityParams activityParams1 = new ActivityParams("firstActivityType"); activityParams1.setTypicalDuration(12 * 3600.); diff --git a/contribs/vsp/src/test/java/playground/vsp/congestion/MarginalCongestionHandlerFlowSpillbackQueueQsimTest.java b/contribs/vsp/src/test/java/playground/vsp/congestion/MarginalCongestionHandlerFlowSpillbackQueueQsimTest.java index 2198bb4d66a..a878b7ff8d0 100644 --- a/contribs/vsp/src/test/java/playground/vsp/congestion/MarginalCongestionHandlerFlowSpillbackQueueQsimTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/congestion/MarginalCongestionHandlerFlowSpillbackQueueQsimTest.java @@ -56,7 +56,7 @@ import org.matsim.core.api.experimental.events.EventsManager; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.PlansCalcRouteConfigGroup; +import org.matsim.core.config.groups.RoutingConfigGroup; import org.matsim.core.config.groups.QSimConfigGroup; import org.matsim.core.controler.AbstractModule; import org.matsim.core.controler.Controler; @@ -317,7 +317,7 @@ public final void testRouting(){ Config config = ConfigUtils.loadConfig( configFile ) ; - config.plansCalcRoute().setAccessEgressType(PlansCalcRouteConfigGroup.AccessEgressType.none); + config.plansCalcRoute().setAccessEgressType(RoutingConfigGroup.AccessEgressType.none); final Scenario scenario = ScenarioUtils.loadScenario( config ); Controler controler = new Controler( scenario ); diff --git a/contribs/vsp/src/test/java/playground/vsp/congestion/MarginalCongestionHandlerV3Test.java b/contribs/vsp/src/test/java/playground/vsp/congestion/MarginalCongestionHandlerV3Test.java index fb236dde784..8fb1bd44714 100644 --- a/contribs/vsp/src/test/java/playground/vsp/congestion/MarginalCongestionHandlerV3Test.java +++ b/contribs/vsp/src/test/java/playground/vsp/congestion/MarginalCongestionHandlerV3Test.java @@ -39,7 +39,7 @@ import org.matsim.core.api.experimental.events.EventsManager; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.PlansCalcRouteConfigGroup; +import org.matsim.core.config.groups.RoutingConfigGroup; import org.matsim.core.controler.AbstractModule; import org.matsim.core.controler.Controler; import org.matsim.core.controler.OutputDirectoryHierarchy; @@ -70,7 +70,7 @@ public final void testCongestionExample(){ final List congestionEvents = new ArrayList(); Config config = ConfigUtils.loadConfig( configFile ) ; - config.plansCalcRoute().setAccessEgressType(PlansCalcRouteConfigGroup.AccessEgressType.none); + config.plansCalcRoute().setAccessEgressType(RoutingConfigGroup.AccessEgressType.none); final Controler controler = new Controler(config); controler.addOverridingModule(new AbstractModule() { diff --git a/contribs/vsp/src/test/java/playground/vsp/ev/CreateUrbanEVTestScenario.java b/contribs/vsp/src/test/java/playground/vsp/ev/CreateUrbanEVTestScenario.java index 994dade91b8..3eba4b6c109 100644 --- a/contribs/vsp/src/test/java/playground/vsp/ev/CreateUrbanEVTestScenario.java +++ b/contribs/vsp/src/test/java/playground/vsp/ev/CreateUrbanEVTestScenario.java @@ -25,8 +25,8 @@ import org.matsim.contrib.ev.EvConfigGroup; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; -import org.matsim.core.config.groups.PlansCalcRouteConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; +import org.matsim.core.config.groups.RoutingConfigGroup; import org.matsim.core.config.groups.QSimConfigGroup; import org.matsim.core.controler.OutputDirectoryHierarchy; import org.matsim.core.scenario.ScenarioUtils; @@ -45,13 +45,13 @@ static Scenario createTestScenario(){ evReplanningCfg.setCriticalSOC(0.4); //TODO actually, should also work with all AccessEgressTypes but we have to check (write JUnit test) - config.plansCalcRoute().setAccessEgressType( PlansCalcRouteConfigGroup.AccessEgressType.none ); + config.plansCalcRoute().setAccessEgressType( RoutingConfigGroup.AccessEgressType.none ); //register charging interaction activities for car config.planCalcScore().addActivityParams( - new PlanCalcScoreConfigGroup.ActivityParams( TransportMode.car + UrbanEVModule.PLUGOUT_INTERACTION).setScoringThisActivityAtAll(false ) ); + new ScoringConfigGroup.ActivityParams( TransportMode.car + UrbanEVModule.PLUGOUT_INTERACTION).setScoringThisActivityAtAll(false ) ); config.planCalcScore().addActivityParams( - new PlanCalcScoreConfigGroup.ActivityParams( TransportMode.car + UrbanEVModule.PLUGIN_INTERACTION).setScoringThisActivityAtAll( false ) ); + new ScoringConfigGroup.ActivityParams( TransportMode.car + UrbanEVModule.PLUGIN_INTERACTION).setScoringThisActivityAtAll( false ) ); config.network().setInputFile("1pctNetwork.xml"); config.controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles); config.controler().setLastIteration(5); diff --git a/contribs/vsp/src/test/java/playground/vsp/pt/fare/PtTripFareEstimatorTest.java b/contribs/vsp/src/test/java/playground/vsp/pt/fare/PtTripFareEstimatorTest.java index fee58b21390..24d58706664 100644 --- a/contribs/vsp/src/test/java/playground/vsp/pt/fare/PtTripFareEstimatorTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/pt/fare/PtTripFareEstimatorTest.java @@ -15,7 +15,7 @@ import org.matsim.application.MATSimApplication; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; import org.matsim.core.controler.Controler; import org.matsim.core.scoring.functions.ScoringParametersForPerson; import org.matsim.modechoice.*; @@ -52,10 +52,10 @@ public void setUp() throws Exception { Config config = TestScenario.loadConfig(utils); - Map modes = config.planCalcScore().getScoringParameters("person").getModes(); + Map modes = config.planCalcScore().getScoringParameters("person").getModes(); - PlanCalcScoreConfigGroup.ModeParams pt = modes.get(TransportMode.pt); - PlanCalcScoreConfigGroup.ModeParams walk = modes.get(TransportMode.walk); + ScoringConfigGroup.ModeParams pt = modes.get(TransportMode.pt); + ScoringConfigGroup.ModeParams walk = modes.get(TransportMode.walk); group = ConfigUtils.addOrGetModule(config, InformedModeChoiceConfigGroup.class); diff --git a/contribs/vsp/src/test/java/playground/vsp/scoring/IncomeDependentUtilityOfMoneyPersonScoringParametersNoSubpopulationTest.java b/contribs/vsp/src/test/java/playground/vsp/scoring/IncomeDependentUtilityOfMoneyPersonScoringParametersNoSubpopulationTest.java index 7fb4fb7e312..f7a08b4ea4b 100644 --- a/contribs/vsp/src/test/java/playground/vsp/scoring/IncomeDependentUtilityOfMoneyPersonScoringParametersNoSubpopulationTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/scoring/IncomeDependentUtilityOfMoneyPersonScoringParametersNoSubpopulationTest.java @@ -9,7 +9,7 @@ import org.matsim.api.core.v01.population.Population; import org.matsim.api.core.v01.population.PopulationFactory; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; import org.matsim.core.config.groups.ScenarioConfigGroup; import org.matsim.core.population.PersonUtils; import org.matsim.core.population.PopulationUtils; @@ -37,9 +37,9 @@ public class IncomeDependentUtilityOfMoneyPersonScoringParametersNoSubpopulation public void setUp() { TransitConfigGroup transitConfigGroup = new TransitConfigGroup(); ScenarioConfigGroup scenarioConfigGroup = new ScenarioConfigGroup(); - PlanCalcScoreConfigGroup planCalcScoreConfigGroup = new PlanCalcScoreConfigGroup(); + ScoringConfigGroup scoringConfigGroup = new ScoringConfigGroup(); - PlanCalcScoreConfigGroup.ScoringParameterSet defaultParams = planCalcScoreConfigGroup.getOrCreateScoringParameters(null); + ScoringConfigGroup.ScoringParameterSet defaultParams = scoringConfigGroup.getOrCreateScoringParameters(null); defaultParams.setMarginalUtilityOfMoney(20); defaultParams.setMarginalUtlOfWaitingPt_utils_hr(0.5d * 3600); @@ -69,7 +69,7 @@ public void setUp() { } personScoringParams = new IncomeDependentUtilityOfMoneyPersonScoringParameters(population, - planCalcScoreConfigGroup, + scoringConfigGroup, scenarioConfigGroup, transitConfigGroup); } @@ -132,4 +132,4 @@ private void makeAssert(ScoringParameters params, double income, double marginal } -} \ No newline at end of file +} diff --git a/contribs/vsp/src/test/java/playground/vsp/scoring/IncomeDependentUtilityOfMoneyPersonScoringParametersTest.java b/contribs/vsp/src/test/java/playground/vsp/scoring/IncomeDependentUtilityOfMoneyPersonScoringParametersTest.java index 43b65dd4c82..daa410350d4 100644 --- a/contribs/vsp/src/test/java/playground/vsp/scoring/IncomeDependentUtilityOfMoneyPersonScoringParametersTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/scoring/IncomeDependentUtilityOfMoneyPersonScoringParametersTest.java @@ -6,7 +6,7 @@ import org.matsim.api.core.v01.population.Population; import org.matsim.api.core.v01.population.PopulationFactory; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; import org.matsim.core.config.groups.ScenarioConfigGroup; import org.matsim.core.population.PersonUtils; import org.matsim.core.population.PopulationUtils; @@ -34,13 +34,13 @@ public class IncomeDependentUtilityOfMoneyPersonScoringParametersTest { public void setUp() { TransitConfigGroup transitConfigGroup = new TransitConfigGroup(); ScenarioConfigGroup scenarioConfigGroup = new ScenarioConfigGroup(); - PlanCalcScoreConfigGroup planCalcScoreConfigGroup = new PlanCalcScoreConfigGroup(); + ScoringConfigGroup scoringConfigGroup = new ScoringConfigGroup(); - PlanCalcScoreConfigGroup.ScoringParameterSet personParams = planCalcScoreConfigGroup.getOrCreateScoringParameters("person"); + ScoringConfigGroup.ScoringParameterSet personParams = scoringConfigGroup.getOrCreateScoringParameters("person"); personParams.setMarginalUtilityOfMoney(1); personParams.setMarginalUtlOfWaitingPt_utils_hr(0.5 * 3600); - PlanCalcScoreConfigGroup.ScoringParameterSet freightParams = planCalcScoreConfigGroup.getOrCreateScoringParameters("freight"); + ScoringConfigGroup.ScoringParameterSet freightParams = scoringConfigGroup.getOrCreateScoringParameters("freight"); freightParams.setMarginalUtilityOfMoney(444); freightParams.setMarginalUtlOfWaitingPt_utils_hr(1d * 3600); @@ -88,7 +88,7 @@ public void setUp() { population.addPerson(freightWithIncome2); } personScoringParams = new IncomeDependentUtilityOfMoneyPersonScoringParameters(population, - planCalcScoreConfigGroup, + scoringConfigGroup, scenarioConfigGroup, transitConfigGroup); } @@ -169,4 +169,4 @@ private void makeAssert(ScoringParameters params, double income, double marginal } -} \ No newline at end of file +} diff --git a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/IndividualRaptorParametersForPerson.java b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/IndividualRaptorParametersForPerson.java index 26e95cb0a7b..9f276c3cf9f 100644 --- a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/IndividualRaptorParametersForPerson.java +++ b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/IndividualRaptorParametersForPerson.java @@ -4,7 +4,7 @@ import org.matsim.api.core.v01.population.Person; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; import org.matsim.core.scoring.functions.ModeUtilityParameters; import org.matsim.core.scoring.functions.ScoringParameters; import org.matsim.core.scoring.functions.ScoringParametersForPerson; @@ -41,9 +41,9 @@ public RaptorParameters getRaptorParameters(Person person) { raptorParameters.setMarginalUtilityOfWaitingPt_utl_s( scoringParameters.marginalUtilityOfWaitingPt_s - marginalUtilityOfPerforming); - PlanCalcScoreConfigGroup pcsConfig = config.planCalcScore(); + ScoringConfigGroup pcsConfig = config.planCalcScore(); - for (Map.Entry e : pcsConfig.getModes().entrySet()) { + for (Map.Entry e : pcsConfig.getModes().entrySet()) { String mode = e.getKey(); ModeUtilityParameters modeParams = scoringParameters.modeParams.get(mode); diff --git a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/OccupancyData.java b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/OccupancyData.java index 629f8476bfa..b963b6338ba 100644 --- a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/OccupancyData.java +++ b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/OccupancyData.java @@ -5,7 +5,6 @@ import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.IdMap; import org.matsim.api.core.v01.population.Person; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup.ModeParams; import org.matsim.core.scoring.functions.ModeUtilityParameters; import org.matsim.pt.transitSchedule.api.Departure; import org.matsim.pt.transitSchedule.api.TransitLine; diff --git a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/RaptorUtils.java b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/RaptorUtils.java index 5dbe0c60bd5..7a9e3b38034 100644 --- a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/RaptorUtils.java +++ b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/RaptorUtils.java @@ -17,8 +17,8 @@ import org.matsim.api.core.v01.population.Route; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; -import org.matsim.core.config.groups.PlansCalcRouteConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; +import org.matsim.core.config.groups.RoutingConfigGroup; import org.matsim.core.population.PopulationUtils; import org.matsim.core.population.routes.RouteUtils; import org.matsim.pt.router.TransitRouterConfig; @@ -36,13 +36,13 @@ private RaptorUtils() { } public static RaptorStaticConfig createStaticConfig(Config config) { - PlansCalcRouteConfigGroup pcrConfig = config.plansCalcRoute(); + RoutingConfigGroup pcrConfig = config.plansCalcRoute(); SwissRailRaptorConfigGroup srrConfig = ConfigUtils.addOrGetModule(config, SwissRailRaptorConfigGroup.class); RaptorStaticConfig staticConfig = new RaptorStaticConfig(); staticConfig.setBeelineWalkConnectionDistance(config.transitRouter().getMaxBeelineWalkConnectionDistance()); - PlansCalcRouteConfigGroup.TeleportedModeParams walk = pcrConfig.getModeRoutingParams().get(TransportMode.walk ); + RoutingConfigGroup.TeleportedModeParams walk = pcrConfig.getModeRoutingParams().get(TransportMode.walk ); staticConfig.setBeelineWalkSpeed(walk.getTeleportedModeSpeed() / walk.getBeelineDistanceFactor()); staticConfig.setBeelineWalkDistanceFactor(walk.getBeelineDistanceFactor()); staticConfig.setTransferWalkMargin(srrConfig.getTransferWalkMargin()); @@ -73,11 +73,11 @@ public static RaptorParameters createParameters(Config config) { raptorParams.setMarginalUtilityOfWaitingPt_utl_s(trConfig.getMarginalUtilityOfWaitingPt_utl_s()); - PlanCalcScoreConfigGroup pcsConfig = config.planCalcScore(); + ScoringConfigGroup pcsConfig = config.planCalcScore(); double marginalUtilityPerforming = pcsConfig.getPerforming_utils_hr() / 3600.0; - for (Map.Entry e : pcsConfig.getModes().entrySet()) { + for (Map.Entry e : pcsConfig.getModes().entrySet()) { String mode = e.getKey(); - PlanCalcScoreConfigGroup.ModeParams modeParams = e.getValue(); + ScoringConfigGroup.ModeParams modeParams = e.getValue(); double marginalUtility_utl_s = modeParams.getMarginalUtilityOfTraveling()/3600.0 - marginalUtilityPerforming; raptorParams.setMarginalUtilityOfTravelTime_utl_s(mode, marginalUtility_utl_s); } diff --git a/matsim/src/main/java/org/matsim/analysis/LegHistogramListener.java b/matsim/src/main/java/org/matsim/analysis/LegHistogramListener.java index 4ea53bb2da6..e5c1a9b8e2d 100644 --- a/matsim/src/main/java/org/matsim/analysis/LegHistogramListener.java +++ b/matsim/src/main/java/org/matsim/analysis/LegHistogramListener.java @@ -22,8 +22,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.matsim.core.config.Config; -import org.matsim.core.config.groups.ControlerConfigGroup; +import org.matsim.core.config.groups.ControllerConfigGroup; import org.matsim.core.controler.OutputDirectoryHierarchy; import org.matsim.core.controler.events.IterationEndsEvent; import org.matsim.core.controler.events.IterationStartsEvent; @@ -42,7 +41,7 @@ final class LegHistogramListener implements IterationEndsListener, IterationStartsListener { @Inject private LegHistogram histogram; - @Inject private ControlerConfigGroup controlerConfigGroup; + @Inject private ControllerConfigGroup controllerConfigGroup; @Inject private OutputDirectoryHierarchy controlerIO; static private final Logger log = LogManager.getLogger(LegHistogramListener.class); @@ -56,7 +55,7 @@ public void notifyIterationStarts(final IterationStartsEvent event) { public void notifyIterationEnds(final IterationEndsEvent event) { this.histogram.write(controlerIO.getIterationFilename(event.getIteration(), "legHistogram.txt")); this.printStats(); - if (controlerConfigGroup.isCreateGraphs()) { + if (controllerConfigGroup.isCreateGraphs()) { LegHistogramChart.writeGraphic(this.histogram, controlerIO.getIterationFilename(event.getIteration(), "legHistogram_all.png")); for (String legMode : this.histogram.getLegModes()) { LegHistogramChart.writeGraphic(this.histogram, controlerIO.getIterationFilename(event.getIteration(), "legHistogram_" + legMode + ".png"), legMode); diff --git a/matsim/src/main/java/org/matsim/analysis/LinkStatsControlerListener.java b/matsim/src/main/java/org/matsim/analysis/LinkStatsControlerListener.java index b968af1d8bf..5d28e0b9852 100644 --- a/matsim/src/main/java/org/matsim/analysis/LinkStatsControlerListener.java +++ b/matsim/src/main/java/org/matsim/analysis/LinkStatsControlerListener.java @@ -25,7 +25,7 @@ import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; -import org.matsim.core.config.groups.ControlerConfigGroup; +import org.matsim.core.config.groups.ControllerConfigGroup; import org.matsim.core.config.groups.LinkStatsConfigGroup; import org.matsim.core.controler.Controler; import org.matsim.core.controler.OutputDirectoryHierarchy; @@ -51,7 +51,7 @@ final class LinkStatsControlerListener implements IterationEndsListener, Iterati @Inject private LinkStatsConfigGroup linkStatsConfigGroup; @Inject - private ControlerConfigGroup controlerConfigGroup; + private ControllerConfigGroup controllerConfigGroup; @Inject private CalcLinkStats linkStats; @Inject @@ -71,7 +71,7 @@ final class LinkStatsControlerListener implements IterationEndsListener, Iterati public void notifyIterationEnds(IterationEndsEvent event) { int iteration = event.getIteration(); - if (useVolumesOfIteration(iteration, controlerConfigGroup.getFirstIteration())) { + if (useVolumesOfIteration(iteration, controllerConfigGroup.getFirstIteration())) { this.iterationsUsed++; linkStats.addData(volumes, travelTime.get(TransportMode.car)); } diff --git a/matsim/src/main/java/org/matsim/analysis/ModeChoiceCoverageControlerListener.java b/matsim/src/main/java/org/matsim/analysis/ModeChoiceCoverageControlerListener.java index 1e79eb68ae1..ce1bd875272 100644 --- a/matsim/src/main/java/org/matsim/analysis/ModeChoiceCoverageControlerListener.java +++ b/matsim/src/main/java/org/matsim/analysis/ModeChoiceCoverageControlerListener.java @@ -6,8 +6,8 @@ import org.matsim.api.core.v01.population.Person; import org.matsim.api.core.v01.population.Plan; import org.matsim.api.core.v01.population.Population; -import org.matsim.core.config.groups.ControlerConfigGroup; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; +import org.matsim.core.config.groups.ControllerConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; import org.matsim.core.controler.OutputDirectoryHierarchy; import org.matsim.core.controler.events.IterationEndsEvent; import org.matsim.core.controler.events.ShutdownEvent; @@ -45,7 +45,7 @@ public class ModeChoiceCoverageControlerListener implements StartupListener, Ite private final Population population; private final String modeFileName; private final boolean createPNG; - private final ControlerConfigGroup controlerConfigGroup; + private final ControllerConfigGroup controllerConfigGroup; private final MainModeIdentifier mainModeIdentifier; private int minIteration = 0; @@ -64,10 +64,10 @@ public class ModeChoiceCoverageControlerListener implements StartupListener, Ite @Inject - ModeChoiceCoverageControlerListener(ControlerConfigGroup controlerConfigGroup, Population population1, OutputDirectoryHierarchy controlerIO, - PlanCalcScoreConfigGroup scoreConfig, AnalysisMainModeIdentifier mainModeIdentifier) { + ModeChoiceCoverageControlerListener(ControllerConfigGroup controllerConfigGroup, Population population1, OutputDirectoryHierarchy controlerIO, + ScoringConfigGroup scoreConfig, AnalysisMainModeIdentifier mainModeIdentifier) { - this.controlerConfigGroup = controlerConfigGroup; + this.controllerConfigGroup = controllerConfigGroup; this.population = population1; this.modeFileName = controlerIO.getOutputFilename(FILENAME_MODESTATS); // this.createPNG = controlerConfigGroup.isCreateGraphs(); @@ -81,7 +81,7 @@ public class ModeChoiceCoverageControlerListener implements StartupListener, Ite @Override public void notifyStartup(final StartupEvent event) { - this.minIteration = controlerConfigGroup.getFirstIteration(); + this.minIteration = controllerConfigGroup.getFirstIteration(); } @Override diff --git a/matsim/src/main/java/org/matsim/analysis/ModeStatsControlerListener.java b/matsim/src/main/java/org/matsim/analysis/ModeStatsControlerListener.java index df37ea197fd..cc711abb7a5 100644 --- a/matsim/src/main/java/org/matsim/analysis/ModeStatsControlerListener.java +++ b/matsim/src/main/java/org/matsim/analysis/ModeStatsControlerListener.java @@ -32,26 +32,19 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.jfree.chart.ChartFactory; import org.jfree.chart.ChartUtils; import org.jfree.chart.JFreeChart; -import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.XYPlot; -import org.jfree.chart.renderer.xy.XYBarPainter; -import org.jfree.data.xy.DefaultTableXYDataset; import org.jfree.data.xy.XYDataset; -import org.jfree.data.xy.XYSeries; import org.matsim.api.core.v01.population.Person; import org.matsim.api.core.v01.population.Plan; import org.matsim.api.core.v01.population.Population; -import org.matsim.core.config.groups.ControlerConfigGroup; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; +import org.matsim.core.config.groups.ControllerConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; import org.matsim.core.controler.OutputDirectoryHierarchy; import org.matsim.core.controler.events.IterationEndsEvent; -import org.matsim.core.controler.events.ShutdownEvent; import org.matsim.core.controler.events.StartupEvent; import org.matsim.core.controler.listener.IterationEndsListener; -import org.matsim.core.controler.listener.ShutdownListener; import org.matsim.core.controler.listener.StartupListener; import org.matsim.core.router.AnalysisMainModeIdentifier; import org.matsim.core.router.MainModeIdentifier; @@ -80,7 +73,7 @@ public final class ModeStatsControlerListener implements StartupListener, Iterat final private String modeFileName ; private final boolean createPNG; - private final ControlerConfigGroup controlerConfigGroup; + private final ControllerConfigGroup controllerConfigGroup; Map> modeHistories = new HashMap<>() ; private int minIteration = 0; @@ -94,18 +87,18 @@ public final class ModeStatsControlerListener implements StartupListener, Iterat private final static Logger log = LogManager.getLogger(ModeStatsControlerListener.class); @Inject - ModeStatsControlerListener(ControlerConfigGroup controlerConfigGroup, Population population1, OutputDirectoryHierarchy controlerIO, - PlanCalcScoreConfigGroup scoreConfig, AnalysisMainModeIdentifier mainModeIdentifier) { - this.controlerConfigGroup = controlerConfigGroup; + ModeStatsControlerListener(ControllerConfigGroup controllerConfigGroup, Population population1, OutputDirectoryHierarchy controlerIO, + ScoringConfigGroup scoreConfig, AnalysisMainModeIdentifier mainModeIdentifier) { + this.controllerConfigGroup = controllerConfigGroup; this.population = population1; this.modeFileName = controlerIO.getOutputFilename( FILENAME_MODESTATS ) ; - this.createPNG = controlerConfigGroup.isCreateGraphs(); + this.createPNG = controllerConfigGroup.isCreateGraphs(); this.mainModeIdentifier = mainModeIdentifier; } @Override public void notifyStartup(final StartupEvent event) { - this.minIteration = controlerConfigGroup.getFirstIteration(); + this.minIteration = controllerConfigGroup.getFirstIteration(); } @Override diff --git a/matsim/src/main/java/org/matsim/analysis/PHbyModeCalculator.java b/matsim/src/main/java/org/matsim/analysis/PHbyModeCalculator.java index 6c9f11f0d8f..23973f7b645 100644 --- a/matsim/src/main/java/org/matsim/analysis/PHbyModeCalculator.java +++ b/matsim/src/main/java/org/matsim/analysis/PHbyModeCalculator.java @@ -32,14 +32,13 @@ import org.apache.commons.csv.CSVFormat; import org.apache.commons.csv.CSVPrinter; import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.jfree.chart.axis.CategoryLabelPositions; import org.matsim.api.core.v01.IdMap; import org.matsim.api.core.v01.population.Activity; import org.matsim.api.core.v01.population.Leg; import org.matsim.api.core.v01.population.Person; import org.matsim.api.core.v01.population.Plan; -import org.matsim.core.config.groups.ControlerConfigGroup; +import org.matsim.core.config.groups.ControllerConfigGroup; import org.matsim.core.controler.OutputDirectoryHierarchy; import org.matsim.core.router.StageActivityTypeIdentifier; import org.matsim.core.scoring.EventsToLegs; @@ -62,8 +61,8 @@ public class PHbyModeCalculator { private static final String STAGE_ACTIVITY = "stageActivity"; @Inject - PHbyModeCalculator(ControlerConfigGroup controlerConfigGroup, OutputDirectoryHierarchy controlerIO) { - writePng = controlerConfigGroup.isCreateGraphs(); + PHbyModeCalculator(ControllerConfigGroup controllerConfigGroup, OutputDirectoryHierarchy controlerIO) { + writePng = controllerConfigGroup.isCreateGraphs(); this.controlerIO = controlerIO; } diff --git a/matsim/src/main/java/org/matsim/analysis/PKMbyModeCalculator.java b/matsim/src/main/java/org/matsim/analysis/PKMbyModeCalculator.java index 831bf1a2c4e..47016857fdb 100644 --- a/matsim/src/main/java/org/matsim/analysis/PKMbyModeCalculator.java +++ b/matsim/src/main/java/org/matsim/analysis/PKMbyModeCalculator.java @@ -32,13 +32,12 @@ import org.apache.commons.csv.CSVFormat; import org.apache.commons.csv.CSVPrinter; import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.jfree.chart.axis.CategoryLabelPositions; import org.matsim.api.core.v01.IdMap; import org.matsim.api.core.v01.population.Leg; import org.matsim.api.core.v01.population.Person; import org.matsim.api.core.v01.population.Plan; -import org.matsim.core.config.groups.ControlerConfigGroup; +import org.matsim.core.config.groups.ControllerConfigGroup; import org.matsim.core.controler.OutputDirectoryHierarchy; import org.matsim.core.utils.charts.StackedBarChart; @@ -56,8 +55,8 @@ public class PKMbyModeCalculator { @Inject - PKMbyModeCalculator(ControlerConfigGroup controlerConfigGroup, OutputDirectoryHierarchy controlerIO) { - writePng = controlerConfigGroup.isCreateGraphs(); + PKMbyModeCalculator(ControllerConfigGroup controllerConfigGroup, OutputDirectoryHierarchy controlerIO) { + writePng = controllerConfigGroup.isCreateGraphs(); this.controlerIO = controlerIO; } diff --git a/matsim/src/main/java/org/matsim/analysis/ScoreStatsControlerListener.java b/matsim/src/main/java/org/matsim/analysis/ScoreStatsControlerListener.java index 50d09d51a63..5d20ff35c15 100644 --- a/matsim/src/main/java/org/matsim/analysis/ScoreStatsControlerListener.java +++ b/matsim/src/main/java/org/matsim/analysis/ScoreStatsControlerListener.java @@ -33,8 +33,8 @@ import org.matsim.api.core.v01.population.Person; import org.matsim.api.core.v01.population.Plan; import org.matsim.api.core.v01.population.Population; -import org.matsim.core.config.groups.ControlerConfigGroup; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; +import org.matsim.core.config.groups.ControllerConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; import org.matsim.core.controler.OutputDirectoryHierarchy; import org.matsim.core.controler.events.IterationEndsEvent; import org.matsim.core.controler.events.ShutdownEvent; @@ -74,7 +74,7 @@ public static enum ScoreItem { worst, best, average, executed } ; final private String fileName; private final boolean createPNG; - private final ControlerConfigGroup controlerConfigGroup; + private final ControllerConfigGroup controllerConfigGroup; private final Map> scoreHistory = new HashMap<>(); @@ -85,13 +85,13 @@ public static enum ScoreItem { worst, best, average, executed } ; private final static Logger log = LogManager.getLogger(ScoreStatsControlerListener.class); @Inject - ScoreStatsControlerListener(ControlerConfigGroup controlerConfigGroup, Population population, OutputDirectoryHierarchy controlerIO, - PlanCalcScoreConfigGroup scoreConfig, Provider tripRouterFactory ) { + ScoreStatsControlerListener(ControllerConfigGroup controllerConfigGroup, Population population, OutputDirectoryHierarchy controlerIO, + ScoringConfigGroup scoreConfig, Provider tripRouterFactory ) { - this.controlerConfigGroup = controlerConfigGroup; + this.controllerConfigGroup = controllerConfigGroup; this.population = population; this.fileName = controlerIO.getOutputFilename(FILENAME_SCORESTATS); - this.createPNG = controlerConfigGroup.isCreateGraphs(); + this.createPNG = controllerConfigGroup.isCreateGraphs(); this.out = IOUtils.getBufferedWriter(this.fileName + ".txt"); Set subpopulations = population.getPersons().values().stream() @@ -116,7 +116,7 @@ public static enum ScoreItem { worst, best, average, executed } ; @Override public void notifyStartup(final StartupEvent event) { - this.minIteration = controlerConfigGroup.getFirstIteration(); + this.minIteration = controllerConfigGroup.getFirstIteration(); // int maxIter = controlerConfigGroup.getLastIteration(); // int iterations = maxIter - this.minIteration; // if (iterations > 5000) iterations = 5000; // limit the history size diff --git a/matsim/src/main/java/org/matsim/analysis/TravelDistanceStats.java b/matsim/src/main/java/org/matsim/analysis/TravelDistanceStats.java index c0ea8aeccb1..060e5ae9e43 100644 --- a/matsim/src/main/java/org/matsim/analysis/TravelDistanceStats.java +++ b/matsim/src/main/java/org/matsim/analysis/TravelDistanceStats.java @@ -27,7 +27,7 @@ import org.matsim.api.core.v01.population.Person; import org.matsim.api.core.v01.population.Plan; import org.matsim.core.config.Config; -import org.matsim.core.config.groups.ControlerConfigGroup; +import org.matsim.core.config.groups.ControllerConfigGroup; import org.matsim.core.controler.OutputDirectoryHierarchy; import org.matsim.core.router.TripStructureUtils; import org.matsim.core.router.TripStructureUtils.Trip; @@ -58,7 +58,7 @@ public class TravelDistanceStats { - private final ControlerConfigGroup controlerConfigGroup; + private final ControllerConfigGroup controllerConfigGroup; final private BufferedWriter out; final private String legStatsPngName; final private String tripStatsPngName; @@ -69,10 +69,10 @@ public class TravelDistanceStats { private final static Logger log = LogManager.getLogger(TravelDistanceStats.class); @Inject - TravelDistanceStats(ControlerConfigGroup controlerConfigGroup, OutputDirectoryHierarchy controlerIO) { - this(controlerConfigGroup, controlerIO.getOutputFilename("traveldistancestats"), + TravelDistanceStats(ControllerConfigGroup controllerConfigGroup, OutputDirectoryHierarchy controlerIO) { + this(controllerConfigGroup, controlerIO.getOutputFilename("traveldistancestats"), controlerIO.getOutputFilename("traveldistancestats") + "legs", - controlerIO.getOutputFilename("traveldistancestats") + "trips", controlerConfigGroup.isCreateGraphs()); + controlerIO.getOutputFilename("traveldistancestats") + "trips", controllerConfigGroup.isCreateGraphs()); } /** @@ -84,13 +84,13 @@ public TravelDistanceStats(final Config config, final String filename, final boo this(config.controler(), filename, filename + "legs", filename + "trips", createPNG); } - private TravelDistanceStats(ControlerConfigGroup controlerConfigGroup, String travelDistanceStatsFileName, - String legStatsPngName, String tripStatsPngName, boolean createPNG) { - this.controlerConfigGroup = controlerConfigGroup; + private TravelDistanceStats(ControllerConfigGroup controllerConfigGroup, String travelDistanceStatsFileName, + String legStatsPngName, String tripStatsPngName, boolean createPNG) { + this.controllerConfigGroup = controllerConfigGroup; this.legStatsPngName = legStatsPngName; this.tripStatsPngName = tripStatsPngName; if (createPNG) { - int iterations = controlerConfigGroup.getLastIteration() - controlerConfigGroup.getFirstIteration(); + int iterations = controllerConfigGroup.getLastIteration() - controllerConfigGroup.getFirstIteration(); if (iterations > 5000) { iterations = 5000; // limit the history size } @@ -156,15 +156,15 @@ public void addIteration(int iteration, IdMap map) { } if (this.legStatsHistory != null) { - int index = iteration - controlerConfigGroup.getFirstIteration(); + int index = iteration - controllerConfigGroup.getFirstIteration(); this.legStatsHistory[index] = legStats.getAverage(); - if (iteration != controlerConfigGroup.getFirstIteration()) { + if (iteration != controllerConfigGroup.getFirstIteration()) { // create chart when data of more than one iteration is available. XYLineChart chart = new XYLineChart("Leg Travel Distance Statistics", "iteration", "average of the average leg distance per plan "); double[] iterations = new double[index + 1]; for (int i = 0; i <= index; i++) { - iterations[i] = i + controlerConfigGroup.getFirstIteration(); + iterations[i] = i + controllerConfigGroup.getFirstIteration(); } double[] values = new double[index + 1]; System.arraycopy(this.legStatsHistory, 0, values, 0, index + 1); @@ -179,15 +179,15 @@ public void addIteration(int iteration, IdMap map) { } if (this.tripStatsHistory != null) { - int index = iteration - controlerConfigGroup.getFirstIteration(); + int index = iteration - controllerConfigGroup.getFirstIteration(); this.tripStatsHistory[index] = tripStats.getAverage(); - if (iteration != controlerConfigGroup.getFirstIteration()) { + if (iteration != controllerConfigGroup.getFirstIteration()) { // create chart when data of more than one iteration is available. XYLineChart chart = new XYLineChart("Trip Travel Distance Statistics", "iteration", "average of the average trip distance per plan "); double[] iterations = new double[index + 1]; for (int i = 0; i <= index; i++) { - iterations[i] = i + controlerConfigGroup.getFirstIteration(); + iterations[i] = i + controllerConfigGroup.getFirstIteration(); } double[] values = new double[index + 1]; System.arraycopy(this.tripStatsHistory, 0, values, 0, index + 1); diff --git a/matsim/src/main/java/org/matsim/core/config/CommandLine.java b/matsim/src/main/java/org/matsim/core/config/CommandLine.java index a4c043e17d2..15f8213a860 100644 --- a/matsim/src/main/java/org/matsim/core/config/CommandLine.java +++ b/matsim/src/main/java/org/matsim/core/config/CommandLine.java @@ -35,7 +35,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup.ScoringParameterSet; +import org.matsim.core.config.groups.ScoringConfigGroup.ScoringParameterSet; /** *

@@ -44,63 +44,63 @@ * application in itself, it provides advanced functionality to directly modify * the MATSim {@link Config} object. *

- * + * *

General usage

- * + * *

* The command line interpreter is set up using the {@link CommandLine.Builder}: *

- * + * *
  * CommandLine cmd = new CommandLine.Builder(args) //
  * 		.allowOptions("optionA", "optionB") //
  * 		.requireOptions("outputPath") //
  * 		.allowPositionalArguments(false).build();
  * 
- * + * *

* The command line option can be accessed via safe getters, which return * {@link Optional}s, or strict getters, which raise exceptions: *

- * + * *
  * int numberOfThreads = cmd.getOption("threads").map(Integer::parseInt).orElse(4);
  * int numberOfThreads = Integer.parseInt(cmd.getOptionStrict("threads"));
  * 
- * + * *

* As can be seen, options are always returned as strings. It is the task of the * user to convert the arguments to the expected data types. They are given in * one of the following ways: *

- * + * *
    *
  • Value following the option name: --threads 20
  • *
  • With equals sign between: --threads=20
  • *
- * + * *

MATSim usage

- * + * *

* In order to configure MATSim with the command line, one needs to tell the * interpreter to apply the command line options to the MATSim {@link Config}: *

- * + * *
  * CommandLine cmd = new CommandLine.Builder(args) //
  * 		.allowPositionalArguments(false)//
  * 		.build();
- * 
+ *
  * Config config = ConfigUtils.createConfig();
  * cmd.applyConfiguration(config);
  * 
- * + * *

* This will interpret all command line options of the form * config:* as options that are supposed to be inserted into the * MATSim config. The rules are as follows: *

- * + * *
    *
  • --config:MODULE.PARAM VALUE sets a certain parameter with * name PARAM in the module MODULE to the value @@ -113,15 +113,15 @@ *
  • --config:MODULE.SET_TYPE[*=*].PARAM VALUE sets a value in * all parameter sets of SET_TYPE
  • *
- * + * * Some examples: - * + * *
    *
  • --config:global.numberOfThreads 48
  • *
  • --config:strategy.strategysettings[strategyName=ReRoute].weight 0.0
  • *
  • --config:planCalcScore.scoringParameters[subpopulation=null].modeParams[mode=car].constant -3.5
  • *
- * + * * @author Sebastian Hörl */ public class CommandLine { @@ -157,7 +157,7 @@ static public class Builder { /** * Creates a builder instance. - * + * * @param args The command line arguments passed to the Java application. */ public Builder(String[] args) { @@ -247,7 +247,7 @@ public Builder allowPrefixes(String... prefixes) { * Builds the command line interpreter with the given configuration. An * {@link ConfigurationException} may be thrown directly in one of the following * cases: - * + * *
    *
  • An unnamed (positional) command line argument is passed, although it is * forbidden (see {{@link #allowPositionalArguments(boolean)})
  • @@ -260,7 +260,7 @@ public Builder allowPrefixes(String... prefixes) { *
  • Some command line options have been defined as required (see * {@link #requireOptions(Collection)}), but are not present.
  • *
- * + * * @throws ConfigurationException */ public CommandLine build() throws ConfigurationException { @@ -348,7 +348,7 @@ public Optional getOption(String option) { /** * Returns a named command line option if it is present, raises a * {@link ConfigurationException} otherwise. - * + * * @throws ConfigurationException */ public String getOptionStrict(String option) throws ConfigurationException { @@ -364,7 +364,7 @@ public String getOptionStrict(String option) throws ConfigurationException { /** * Processes a list of raw command line arguments. - * + * * @throws ConfigurationException */ private void process(List args) throws ConfigurationException { @@ -401,13 +401,13 @@ private void process(List args) throws ConfigurationException { /** * Flattens a list of raw command line arguments: - * + * *
    *
  • Splits ["param=value"] into ["param", "value"], *
  • *
  • but makes sure that ["param[key=value]"] is preserved
  • *
- * + * * @param args * @return */ @@ -435,7 +435,7 @@ private List flattenArguments(List args) { /** * Adds a positional argument and checks if this is allowed by configuration. - * + * * @throws ConfigurationException */ private void addPositionalArgument(String value) throws ConfigurationException { @@ -448,7 +448,7 @@ private void addPositionalArgument(String value) throws ConfigurationException { /** * Adds a named option and checks whether it is allowed by configuration. - * + * * @throws ConfigurationException */ private void addOption(String option, String value) throws ConfigurationException { @@ -465,7 +465,7 @@ private void addOption(String option, String value) throws ConfigurationExceptio /** * Checks that are required options are present. - * + * * @throws ConfigurationException */ private void checkRequiredOptions() throws ConfigurationException { @@ -488,7 +488,7 @@ private void checkRequiredOptions() throws ConfigurationException { /** * Applies the command line configuration to a MATSim {@link Config} instance. * See {@link CommandLine} for more information on the syntax. - * + * * @throws ConfigurationException */ public void applyConfiguration(Config config) throws ConfigurationException { @@ -606,13 +606,13 @@ private void processParameter(String option, String path, ConfigGroup configGrou return; } } - + // allow for the case subpopulation = 'null' in the scoring parameters if (parameterSetType.equals(ScoringParameterSet.SET_TYPE) && selectionParameter.equals("subpopulation") && selectionValue.equals("null")) { processParameter(option, newPath, parameterSet, newRemainder); return; } - + } } diff --git a/matsim/src/main/java/org/matsim/core/config/Config.java b/matsim/src/main/java/org/matsim/core/config/Config.java index 45b2a8c74d6..b577ea51114 100644 --- a/matsim/src/main/java/org/matsim/core/config/Config.java +++ b/matsim/src/main/java/org/matsim/core/config/Config.java @@ -37,21 +37,21 @@ import org.matsim.core.config.consistency.VspConfigConsistencyCheckerImpl; import org.matsim.core.config.groups.ChangeLegModeConfigGroup; import org.matsim.core.config.groups.ChangeModeConfigGroup; -import org.matsim.core.config.groups.ControlerConfigGroup; +import org.matsim.core.config.groups.ControllerConfigGroup; import org.matsim.core.config.groups.CountsConfigGroup; +import org.matsim.core.config.groups.EventsManagerConfigGroup; import org.matsim.core.config.groups.FacilitiesConfigGroup; import org.matsim.core.config.groups.GlobalConfigGroup; import org.matsim.core.config.groups.HouseholdsConfigGroup; import org.matsim.core.config.groups.LinkStatsConfigGroup; import org.matsim.core.config.groups.NetworkConfigGroup; -import org.matsim.core.config.groups.ParallelEventHandlingConfigGroup; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; -import org.matsim.core.config.groups.PlansCalcRouteConfigGroup; +import org.matsim.core.config.groups.ReplanningConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; +import org.matsim.core.config.groups.RoutingConfigGroup; import org.matsim.core.config.groups.PlansConfigGroup; import org.matsim.core.config.groups.PtCountsConfigGroup; import org.matsim.core.config.groups.QSimConfigGroup; import org.matsim.core.config.groups.ScenarioConfigGroup; -import org.matsim.core.config.groups.StrategyConfigGroup; import org.matsim.core.config.groups.SubtourModeChoiceConfigGroup; import org.matsim.core.config.groups.TimeAllocationMutatorConfigGroup; import org.matsim.core.config.groups.TravelTimeCalculatorConfigGroup; @@ -67,7 +67,7 @@ /** * Stores all configuration settings specified in a configuration file and * provides access to the settings at runtime. - * + * * @see CreateFullConfig * * @author mrieser @@ -119,13 +119,13 @@ public Config() { public void addCoreModules() { this.modules.put(GlobalConfigGroup.GROUP_NAME, new GlobalConfigGroup()); - this.modules.put(ControlerConfigGroup.GROUP_NAME, new ControlerConfigGroup()); + this.modules.put(ControllerConfigGroup.GROUP_NAME, new ControllerConfigGroup()); this.modules.put(QSimConfigGroup.GROUP_NAME, new QSimConfigGroup()); this.modules.put(CountsConfigGroup.GROUP_NAME, new CountsConfigGroup()); - this.modules.put(PlanCalcScoreConfigGroup.GROUP_NAME, new PlanCalcScoreConfigGroup()); + this.modules.put(ScoringConfigGroup.GROUP_NAME, new ScoringConfigGroup()); this.modules.put(NetworkConfigGroup.GROUP_NAME, new NetworkConfigGroup()); @@ -133,22 +133,22 @@ public void addCoreModules() { this.modules.put(HouseholdsConfigGroup.GROUP_NAME, new HouseholdsConfigGroup()); - this.modules.put(ParallelEventHandlingConfigGroup.GROUP_NAME, new ParallelEventHandlingConfigGroup() ); + this.modules.put(EventsManagerConfigGroup.GROUP_NAME, new EventsManagerConfigGroup() ); this.modules.put(FacilitiesConfigGroup.GROUP_NAME, new FacilitiesConfigGroup()); - this.modules.put(StrategyConfigGroup.GROUP_NAME, new StrategyConfigGroup()); + this.modules.put(ReplanningConfigGroup.GROUP_NAME, new ReplanningConfigGroup()); this.modules.put(TravelTimeCalculatorConfigGroup.GROUPNAME, new TravelTimeCalculatorConfigGroup()); this.modules.put(ScenarioConfigGroup.GROUP_NAME, new ScenarioConfigGroup()); - this.modules.put(PlansCalcRouteConfigGroup.GROUP_NAME, new PlansCalcRouteConfigGroup()); + this.modules.put(RoutingConfigGroup.GROUP_NAME, new RoutingConfigGroup()); this.modules.put(TimeAllocationMutatorConfigGroup.GROUP_NAME, new TimeAllocationMutatorConfigGroup()); this.modules.put(VspExperimentalConfigGroup.GROUP_NAME, new VspExperimentalConfigGroup()); - + this.modules.put(PtCountsConfigGroup.GROUP_NAME, new PtCountsConfigGroup()); this.modules.put(TransitConfigGroup.GROUP_NAME, new TransitConfigGroup()); @@ -156,9 +156,9 @@ public void addCoreModules() { this.modules.put(LinkStatsConfigGroup.GROUP_NAME, new LinkStatsConfigGroup()); this.modules.put(TransitRouterConfigGroup.GROUP_NAME, new TransitRouterConfigGroup()); - + this.modules.put( SubtourModeChoiceConfigGroup.GROUP_NAME , new SubtourModeChoiceConfigGroup() ); - + this.modules.put( VehiclesConfigGroup.GROUP_NAME , new VehiclesConfigGroup() ) ; this.modules.put(ChangeModeConfigGroup.CONFIG_MODULE, new ChangeModeConfigGroup()); @@ -400,16 +400,16 @@ public final GlobalConfigGroup global() { return (GlobalConfigGroup) this.getModule(GlobalConfigGroup.GROUP_NAME); } - public final ControlerConfigGroup controler() { - return (ControlerConfigGroup) this.getModule(ControlerConfigGroup.GROUP_NAME); + public final ControllerConfigGroup controler() { + return (ControllerConfigGroup) this.getModule(ControllerConfigGroup.GROUP_NAME); } public final CountsConfigGroup counts() { return (CountsConfigGroup) this.getModule(CountsConfigGroup.GROUP_NAME); } - public final PlanCalcScoreConfigGroup planCalcScore() { - return (PlanCalcScoreConfigGroup) this.getModule(PlanCalcScoreConfigGroup.GROUP_NAME); + public final ScoringConfigGroup planCalcScore() { + return (ScoringConfigGroup) this.getModule(ScoringConfigGroup.GROUP_NAME); } public final NetworkConfigGroup network() { @@ -428,8 +428,8 @@ public final FacilitiesConfigGroup facilities() { return (FacilitiesConfigGroup) this.getModule(FacilitiesConfigGroup.GROUP_NAME); } - public final StrategyConfigGroup strategy() { - return (StrategyConfigGroup) this.getModule(StrategyConfigGroup.GROUP_NAME); + public final ReplanningConfigGroup strategy() { + return (ReplanningConfigGroup) this.getModule(ReplanningConfigGroup.GROUP_NAME); } public TravelTimeCalculatorConfigGroup travelTimeCalculator() { @@ -440,8 +440,8 @@ public ScenarioConfigGroup scenario() { return (ScenarioConfigGroup) this.getModule(ScenarioConfigGroup.GROUP_NAME); } - public PlansCalcRouteConfigGroup plansCalcRoute() { - return (PlansCalcRouteConfigGroup) this.getModule(PlansCalcRouteConfigGroup.GROUP_NAME); + public RoutingConfigGroup plansCalcRoute() { + return (RoutingConfigGroup) this.getModule(RoutingConfigGroup.GROUP_NAME); } public VspExperimentalConfigGroup vspExperimental() { @@ -472,8 +472,8 @@ public TimeAllocationMutatorConfigGroup timeAllocationMutator() { return (TimeAllocationMutatorConfigGroup) this.getModule(TimeAllocationMutatorConfigGroup.GROUP_NAME); } - public ParallelEventHandlingConfigGroup parallelEventHandling() { - return (ParallelEventHandlingConfigGroup) this.getModule(ParallelEventHandlingConfigGroup.GROUP_NAME); + public EventsManagerConfigGroup parallelEventHandling() { + return (EventsManagerConfigGroup) this.getModule(EventsManagerConfigGroup.GROUP_NAME); } public SubtourModeChoiceConfigGroup subtourModeChoice() { @@ -545,7 +545,7 @@ private void checkIfLocked() { public final VehiclesConfigGroup vehicles() { return (VehiclesConfigGroup) this.getModule(VehiclesConfigGroup.GROUP_NAME); } - + public void setContext(URL context) { if ( this.context==null || !(context.toString().equals( this.context.toString() ) ) ) { log.info("setting context to [" + context + "]"); diff --git a/matsim/src/main/java/org/matsim/core/config/ConfigReaderMatsimV2.java b/matsim/src/main/java/org/matsim/core/config/ConfigReaderMatsimV2.java index 755fb36341e..246bc1a9609 100644 --- a/matsim/src/main/java/org/matsim/core/config/ConfigReaderMatsimV2.java +++ b/matsim/src/main/java/org/matsim/core/config/ConfigReaderMatsimV2.java @@ -61,9 +61,15 @@ class ConfigReaderMatsimV2 extends MatsimXmlParser { public void addDefaultAliases() { // when renaming config modules and parameter names, add them here as aliases: -// this.addAlias("controler", "controller"); -// this.addAlias("planCalcScore", "scoring"); -// this.addAlias("planscalcroute", "routing"); + + this.addAlias("ReplanningAnnealer", "replanningAnnealer"); + this.addAlias("TimeAllocationMutator", "timeAllocationMutator"); + this.addAlias("JDEQSim", "jdeqsim"); + this.addAlias("controler", "controller"); + this.addAlias("planCalcScore", "scoring"); + this.addAlias("planscalcroute", "routing"); + this.addAlias("strategy", "replanning"); + this.addAlias("parallelEventHandling", "eventsManager"); } public void addAlias(String oldName, String newName, String... path) { diff --git a/matsim/src/main/java/org/matsim/core/config/ConfigUtils.java b/matsim/src/main/java/org/matsim/core/config/ConfigUtils.java index 3022bc62bc4..ba671deeb5c 100644 --- a/matsim/src/main/java/org/matsim/core/config/ConfigUtils.java +++ b/matsim/src/main/java/org/matsim/core/config/ConfigUtils.java @@ -23,7 +23,7 @@ import org.matsim.core.api.internal.MatsimExtensionPoint; import org.matsim.core.config.ConfigWriter.Verbosity; import org.matsim.core.config.groups.PlansConfigGroup; -import org.matsim.core.config.groups.StrategyConfigGroup.StrategySettings; +import org.matsim.core.config.groups.ReplanningConfigGroup.StrategySettings; import org.matsim.core.config.groups.VspExperimentalConfigGroup.VspDefaultsCheckingLevel; import org.matsim.core.gbl.Gbl; import org.matsim.core.utils.io.IOUtils; @@ -32,7 +32,6 @@ import java.io.File; import java.net.URL; import java.util.Arrays; -import java.util.Iterator; /** * @author mrieser diff --git a/matsim/src/main/java/org/matsim/core/config/ConfigWriterHandlerImplV2.java b/matsim/src/main/java/org/matsim/core/config/ConfigWriterHandlerImplV2.java index 91f98383c62..c7aaa094de9 100644 --- a/matsim/src/main/java/org/matsim/core/config/ConfigWriterHandlerImplV2.java +++ b/matsim/src/main/java/org/matsim/core/config/ConfigWriterHandlerImplV2.java @@ -22,12 +22,12 @@ import org.apache.logging.log4j.LogManager; import org.matsim.core.config.ConfigWriter.Verbosity; import org.matsim.core.config.groups.ChangeLegModeConfigGroup; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup.ActivityParams; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup.ModeParams; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup.ScoringParameterSet; -import org.matsim.core.config.groups.PlansCalcRouteConfigGroup; -import org.matsim.core.config.groups.StrategyConfigGroup.StrategySettings; +import org.matsim.core.config.groups.ScoringConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup.ActivityParams; +import org.matsim.core.config.groups.ScoringConfigGroup.ModeParams; +import org.matsim.core.config.groups.ScoringConfigGroup.ScoringParameterSet; +import org.matsim.core.config.groups.RoutingConfigGroup; +import org.matsim.core.config.groups.ReplanningConfigGroup.StrategySettings; import org.matsim.core.utils.io.UncheckedIOException; import java.io.BufferedWriter; @@ -55,16 +55,16 @@ class ConfigWriterHandlerImplV2 extends ConfigWriterHandler { // paths. If someone feels like doing that, please go ahead. kai, jun'18 private String newline = "\n"; - + /** * So we can write only what deviates from the default. * Implementation of this functionality unfortunately became quite messy. * kai, may'18 */ private final Verbosity verbosity; - + private final Set commentsAlreadyWritten = new HashSet<>() ; - + ConfigWriterHandlerImplV2( Verbosity verbosity ) { this.verbosity = verbosity ; } @@ -81,10 +81,10 @@ private void writeModule( Map comments = module.getComments(); try { - + // first write the regular config entries (key,value pairs) boolean headerHasBeenWritten = writeRegularEntries(writer, indent, moduleTag, moduleNameAtt, moduleName, comparisonModule, params, comments); - + // can't say what this is for: if ( moduleName.equals("thisAintNoFlat") ) { LogManager.getLogger(this.getClass()).warn("here") ; @@ -92,7 +92,7 @@ private void writeModule( // then process the parameter sets (which will recursively call the current method again): headerHasBeenWritten = processParameterSets(writer, indent, moduleTag, moduleNameAtt, moduleName, module, comparisonModule, headerHasBeenWritten); - + if ( headerHasBeenWritten ) { writer.write(indent); writer.write("\t"); @@ -103,7 +103,7 @@ private void writeModule( throw new UncheckedIOException(e); } } - + private Boolean processParameterSets(BufferedWriter writer, String indent, String moduleTag, String moduleNameAtt, String moduleName, ConfigGroup module, ConfigGroup comparisonModule, Boolean headerHasBeenWritten) throws IOException { for ( Entry> entry : module.getParameterSets().entrySet() ) { @@ -125,13 +125,13 @@ private Boolean processParameterSets(BufferedWriter writer, String indent, Strin // } if ( verbosity== Verbosity.minimal && comparisonPSet==null ) { if ( pSet instanceof ScoringParameterSet) { - comparisonPSet = ((PlanCalcScoreConfigGroup) comparisonModule).getOrCreateScoringParameters(((ScoringParameterSet) pSet).getSubpopulation()); + comparisonPSet = ((ScoringConfigGroup) comparisonModule).getOrCreateScoringParameters(((ScoringParameterSet) pSet).getSubpopulation()); } else if ( pSet instanceof ModeParams ) { comparisonPSet = ((ScoringParameterSet) comparisonModule).getOrCreateModeParams(((ModeParams) pSet).getMode()); } else if ( pSet instanceof ActivityParams ) { comparisonPSet = ((ScoringParameterSet) comparisonModule).getOrCreateActivityParams(((ActivityParams) pSet).getActivityType()); - } else if ( pSet instanceof PlansCalcRouteConfigGroup.TeleportedModeParams ) { - comparisonPSet = ((PlansCalcRouteConfigGroup) comparisonModule).getOrCreateModeRoutingParams(((PlansCalcRouteConfigGroup.TeleportedModeParams) pSet).getMode() ) ; + } else if ( pSet instanceof RoutingConfigGroup.TeleportedModeParams ) { + comparisonPSet = ((RoutingConfigGroup) comparisonModule).getOrCreateModeRoutingParams(((RoutingConfigGroup.TeleportedModeParams) pSet).getMode() ) ; } else { try { comparisonPSet = pSet.getClass().newInstance(); @@ -155,13 +155,13 @@ private Boolean processParameterSets(BufferedWriter writer, String indent, Strin } return headerHasBeenWritten; } - + private Boolean writeRegularEntries(BufferedWriter writer, String indent, String moduleTag, String moduleNameAtt, String moduleName, ConfigGroup comparisonModule, Map params, Map comments) throws IOException { boolean headerHasBeenWritten = false ; for (Entry entry : params.entrySet()) { - + final String actual = entry.getValue(); if ( verbosity== Verbosity.minimal ) { if ( comparisonModule!=null ) { @@ -188,7 +188,7 @@ private Boolean writeRegularEntries(BufferedWriter writer, String indent, String // } } } - + if ( !headerHasBeenWritten ) { headerHasBeenWritten = true ; writeHeader(writer, indent, moduleTag, moduleNameAtt, moduleName, newline); @@ -215,7 +215,7 @@ private Boolean writeRegularEntries(BufferedWriter writer, String indent, String } return headerHasBeenWritten; } - + private static void writeHeader(BufferedWriter writer, String indent, String moduleTag, String moduleNameAtt, String moduleName, String newline) throws IOException { // writer.write( this.newline ); writer.write( indent ); @@ -223,14 +223,14 @@ private static void writeHeader(BufferedWriter writer, String indent, String mod writer.write(" "+moduleNameAtt+"=\"" + moduleName + "\" >"); writer.write( newline ); } - + private static boolean sameType(ConfigGroup pSet, ConfigGroup cg) { if ( ! ( pSet.getName().equals( cg.getName() ) ) ) { return false; } - if ( pSet instanceof PlansCalcRouteConfigGroup.TeleportedModeParams ) { + if ( pSet instanceof RoutingConfigGroup.TeleportedModeParams ) { // (these are the "teleportedRouteParameters" in config.xml) - if ( ((PlansCalcRouteConfigGroup.TeleportedModeParams)pSet).getMode().equals( ((PlansCalcRouteConfigGroup.TeleportedModeParams)cg).getMode() ) ) { + if ( ((RoutingConfigGroup.TeleportedModeParams)pSet).getMode().equals( ((RoutingConfigGroup.TeleportedModeParams)cg).getMode() ) ) { return true ; } } @@ -253,7 +253,7 @@ private static boolean sameType(ConfigGroup pSet, ConfigGroup cg) { } return false ; } - + @Override void startConfig( final Config config, @@ -264,7 +264,7 @@ void startConfig( } catch (IOException e) { throw new UncheckedIOException(e); } - + } @Override @@ -276,7 +276,7 @@ void endConfig( out.write( this.newline ); } catch (IOException e) { throw new UncheckedIOException(e); - } + } } @Override @@ -285,14 +285,14 @@ void writeModule( final BufferedWriter out) { if ( ! (module instanceof ChangeLegModeConfigGroup) ) { // yyyy special case to provide error message; may be removed eventually. kai, may'16 - - + + ConfigGroup comparisonConfig = null ; if ( verbosity==Verbosity.minimal) { comparisonConfig = ConfigUtils.createConfig().getModules().get(module.getName()); // preference to generate this here multiple times to avoid having it as a field. kai, may'18 } - + writeModule( out, "", diff --git a/matsim/src/main/java/org/matsim/core/config/consistency/ConfigConsistencyCheckerImpl.java b/matsim/src/main/java/org/matsim/core/config/consistency/ConfigConsistencyCheckerImpl.java index ace3b44225b..30040a7ee6e 100644 --- a/matsim/src/main/java/org/matsim/core/config/consistency/ConfigConsistencyCheckerImpl.java +++ b/matsim/src/main/java/org/matsim/core/config/consistency/ConfigConsistencyCheckerImpl.java @@ -23,11 +23,11 @@ import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.TransportMode; import org.matsim.core.config.Config; -import org.matsim.core.config.groups.ControlerConfigGroup.EventsFileFormat; -import org.matsim.core.config.groups.ControlerConfigGroup.RoutingAlgorithmType; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup.ActivityParams; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup.ModeParams; +import org.matsim.core.config.groups.ControllerConfigGroup.EventsFileFormat; +import org.matsim.core.config.groups.ControllerConfigGroup.RoutingAlgorithmType; +import org.matsim.core.config.groups.ScoringConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup.ActivityParams; +import org.matsim.core.config.groups.ScoringConfigGroup.ModeParams; import org.matsim.pt.PtConstants; /** @@ -70,26 +70,26 @@ static boolean checkConsistencyBetweenRouterAndTravelTimeCalculator( final Confi /*package because of test */ static void checkPlanCalcScore(final Config c) { ModeParams ptModeParams = c.planCalcScore().getModes().get(TransportMode.pt); if (ptModeParams!=null && ptModeParams.getMarginalUtilityOfTraveling() > 0) { - log.warn(PlanCalcScoreConfigGroup.GROUP_NAME + ".travelingPt is > 0. This values specifies a utility. " + + log.warn(ScoringConfigGroup.GROUP_NAME + ".travelingPt is > 0. This values specifies a utility. " + "Typically, this should be a disutility, i.e. have a negative value."); } ModeParams carModeParams = c.planCalcScore().getModes().get(TransportMode.car); if (carModeParams!=null && carModeParams.getMarginalUtilityOfTraveling() > 0) { - log.warn(PlanCalcScoreConfigGroup.GROUP_NAME + ".traveling is > 0. This values specifies a utility. " + + log.warn(ScoringConfigGroup.GROUP_NAME + ".traveling is > 0. This values specifies a utility. " + "Typically, this should be a disutility, i.e. have a negative value."); } ModeParams bikeModeParams = c.planCalcScore().getModes().get(TransportMode.bike); if (bikeModeParams!=null && bikeModeParams.getMarginalUtilityOfTraveling() > 0) { - log.warn(PlanCalcScoreConfigGroup.GROUP_NAME + ".travelingBike is > 0. This values specifies a utility. " + + log.warn(ScoringConfigGroup.GROUP_NAME + ".travelingBike is > 0. This values specifies a utility. " + "Typically, this should be a disutility, i.e. have a negative value."); } ModeParams walkModeParams = c.planCalcScore().getModes().get(TransportMode.walk); if (walkModeParams!=null && walkModeParams.getMarginalUtilityOfTraveling() > 0) { - log.warn(PlanCalcScoreConfigGroup.GROUP_NAME + ".travelingWalk is > 0. This values specifies a utility. " + + log.warn(ScoringConfigGroup.GROUP_NAME + ".travelingWalk is > 0. This values specifies a utility. " + "Typically, this should be a disutility, i.e. have a negative value."); } - - + + ActivityParams ptAct = c.planCalcScore().getActivityParams(PtConstants.TRANSIT_ACTIVITY_TYPE) ; if ( ptAct != null ) { // if ( ptAct.getClosingTime()!=0. && ptAct.getClosingTime()!=Time.getUndefinedTime() ) { @@ -105,7 +105,7 @@ static boolean checkConsistencyBetweenRouterAndTravelTimeCalculator( final Confi } } } - + } private static void checkEventsFormatLanesSignals(final Config c) { @@ -157,7 +157,7 @@ private static void checkTravelTimeCalculationRoutingConfiguration(final Config config.controler().getRoutingAlgorithmType() != RoutingAlgorithmType.Dijkstra ) { log.warn("We don't know if non-Dijkstra routing works together with LinkToLink routing."); } - + } diff --git a/matsim/src/main/java/org/matsim/core/config/consistency/VspConfigConsistencyCheckerImpl.java b/matsim/src/main/java/org/matsim/core/config/consistency/VspConfigConsistencyCheckerImpl.java index 336426e9a51..162a2d3b744 100644 --- a/matsim/src/main/java/org/matsim/core/config/consistency/VspConfigConsistencyCheckerImpl.java +++ b/matsim/src/main/java/org/matsim/core/config/consistency/VspConfigConsistencyCheckerImpl.java @@ -26,13 +26,12 @@ import org.matsim.api.core.v01.TransportMode; import org.matsim.core.config.Config; import org.matsim.core.config.groups.*; -import org.matsim.core.config.groups.ControlerConfigGroup.EventsFileFormat; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup.ActivityParams; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup.ModeParams; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup.TypicalDurationScoreComputation; +import org.matsim.core.config.groups.ControllerConfigGroup.EventsFileFormat; +import org.matsim.core.config.groups.ScoringConfigGroup.ActivityParams; +import org.matsim.core.config.groups.ScoringConfigGroup.ModeParams; import org.matsim.core.config.groups.QSimConfigGroup.TrafficDynamics; import org.matsim.core.config.groups.QSimConfigGroup.VehiclesSource; -import org.matsim.core.config.groups.StrategyConfigGroup.StrategySettings; +import org.matsim.core.config.groups.ReplanningConfigGroup.StrategySettings; import org.matsim.core.config.groups.VspExperimentalConfigGroup.CheckingOfMarginalUtilityOfTravellng; import org.matsim.core.config.groups.VspExperimentalConfigGroup.VspDefaultsCheckingLevel; import org.matsim.core.replanning.strategies.DefaultPlanStrategiesModule.DefaultStrategy; @@ -402,7 +401,7 @@ private static boolean checkPlanCalcScoreConfigGroup( Config config, Level lvl, } // added feb'16 - if ( config.plansCalcRoute().getAccessEgressType().equals(PlansCalcRouteConfigGroup.AccessEgressType.none ) ) { + if ( config.plansCalcRoute().getAccessEgressType().equals(RoutingConfigGroup.AccessEgressType.none ) ) { log.log( lvl, "found `PlansCalcRouteConfigGroup.AccessEgressType.none'; vsp should use `accessEgressModeToLink' or " + "some other value or talk to Kai." ) ; } @@ -418,7 +417,7 @@ private static boolean checkPlanCalcScoreConfigGroup( Config config, Level lvl, } // added apr'21: - for( Map.Entry entry : config.planCalcScore().getScoringParametersPerSubpopulation().entrySet() ){ + for( Map.Entry entry : config.planCalcScore().getScoringParametersPerSubpopulation().entrySet() ){ for( ActivityParams activityParam : entry.getValue().getActivityParams() ){ if( activityParam.getMinimalDuration().isDefined() ){ log.log( lvl, "Vsp default is to not define minimal duration. Activity type=" + activityParam.getActivityType() + "; subpopulation=" + entry.getKey() ); diff --git a/matsim/src/main/java/org/matsim/core/config/groups/ControlerConfigGroup.java b/matsim/src/main/java/org/matsim/core/config/groups/ControllerConfigGroup.java similarity index 98% rename from matsim/src/main/java/org/matsim/core/config/groups/ControlerConfigGroup.java rename to matsim/src/main/java/org/matsim/core/config/groups/ControllerConfigGroup.java index 7496f79c6ab..f9488228a42 100644 --- a/matsim/src/main/java/org/matsim/core/config/groups/ControlerConfigGroup.java +++ b/matsim/src/main/java/org/matsim/core/config/groups/ControllerConfigGroup.java @@ -31,8 +31,8 @@ import java.util.*; -public final class ControlerConfigGroup extends ReflectiveConfigGroup { - private static final Logger log = LogManager.getLogger( ControlerConfigGroup.class ); +public final class ControllerConfigGroup extends ReflectiveConfigGroup { + private static final Logger log = LogManager.getLogger( ControllerConfigGroup.class ); public enum RoutingAlgorithmType {Dijkstra, AStarLandmarks, SpeedyALT} @@ -58,7 +58,7 @@ public enum CleanIterations { delete, } - public static final String GROUP_NAME = "controler"; + public static final String GROUP_NAME = "controller"; private static final String OUTPUT_DIRECTORY = "outputDirectory"; private static final String FIRST_ITERATION = "firstIteration"; @@ -109,7 +109,7 @@ public enum MobsimType {qsim, JDEQSim, hermes} private CleanIterations cleanItersAtEnd = CleanIterations.keep; - public ControlerConfigGroup() { + public ControllerConfigGroup() { super(GROUP_NAME); } diff --git a/matsim/src/main/java/org/matsim/core/config/groups/ParallelEventHandlingConfigGroup.java b/matsim/src/main/java/org/matsim/core/config/groups/EventsManagerConfigGroup.java similarity index 95% rename from matsim/src/main/java/org/matsim/core/config/groups/ParallelEventHandlingConfigGroup.java rename to matsim/src/main/java/org/matsim/core/config/groups/EventsManagerConfigGroup.java index 3d38075a498..07a5f6c8469 100644 --- a/matsim/src/main/java/org/matsim/core/config/groups/ParallelEventHandlingConfigGroup.java +++ b/matsim/src/main/java/org/matsim/core/config/groups/EventsManagerConfigGroup.java @@ -28,9 +28,9 @@ * @author nagel * */ -public final class ParallelEventHandlingConfigGroup extends ReflectiveConfigGroup { +public final class EventsManagerConfigGroup extends ReflectiveConfigGroup { - public static final String GROUP_NAME = "parallelEventHandling"; + public static final String GROUP_NAME = "eventsManager"; private final static String NUMBER_OF_THREADS = "numberOfThreads"; private Integer numberOfThreads = null; @@ -39,10 +39,10 @@ public final class ParallelEventHandlingConfigGroup extends ReflectiveConfigGrou private final static String ESTIMATED_NUMBER_OF_EVENTS = "estimatedNumberOfEvents"; private Long estimatedNumberOfEvents = null; - private final static String SYNCHRONIZE_ON_SIMSTEPS = "synchronizeOnSimSteps"; + private final static String SYNCHRONIZE_ON_SIMSTEPS = "synchronizeOnSimSteps"; private Boolean synchronizeOnSimSteps = true; - - private final static String ONE_THREAD_PER_HANDLER = "oneThreadPerHandler"; + + private final static String ONE_THREAD_PER_HANDLER = "oneThreadPerHandler"; private Boolean oneThreadPerHandler = false; private final static String EVENTS_QUEUE_SIZE = "eventsQueueSize"; @@ -53,7 +53,7 @@ public final class ParallelEventHandlingConfigGroup extends ReflectiveConfigGrou private boolean locked = false; - public ParallelEventHandlingConfigGroup() { + public EventsManagerConfigGroup() { super(GROUP_NAME); } @@ -80,7 +80,7 @@ public Integer getNumberOfThreads() { /** * {@value #NUMBER_OF_THREADS_COMMENT} - * + * * @param numberOfThreads */ @StringSetter( NUMBER_OF_THREADS ) @@ -143,8 +143,8 @@ public void setOneThreadPerHandler(Boolean oneThreadPerHandler) { throw new RuntimeException("it is too late in the control flow to modify this parameter"); } } - + public void makeLocked() { this.locked = true; } -} \ No newline at end of file +} diff --git a/matsim/src/main/java/org/matsim/core/config/groups/StrategyConfigGroup.java b/matsim/src/main/java/org/matsim/core/config/groups/ReplanningConfigGroup.java similarity index 98% rename from matsim/src/main/java/org/matsim/core/config/groups/StrategyConfigGroup.java rename to matsim/src/main/java/org/matsim/core/config/groups/ReplanningConfigGroup.java index 8f2d2f8c8fb..4a9b0de4f20 100644 --- a/matsim/src/main/java/org/matsim/core/config/groups/StrategyConfigGroup.java +++ b/matsim/src/main/java/org/matsim/core/config/groups/ReplanningConfigGroup.java @@ -41,10 +41,10 @@ * * @author mrieser */ -public final class StrategyConfigGroup extends ConfigGroup { +public final class ReplanningConfigGroup extends ConfigGroup { + + public static final String GROUP_NAME = "replanning"; - public static final String GROUP_NAME = "strategy"; - // in the following, it is still named "module", for the following reason: // the "right" side is the outside interface, used in the config files, which is left with the old keys for backwards compatibility. // kai/mz, dec'14 @@ -58,7 +58,7 @@ public final class StrategyConfigGroup extends ConfigGroup { // yy could you please describe why this indirect design was done? Was ist just because it made refactoring easier, or does it provide // an advantage or is even necessary? Thanks ... kai, oct'14 // To maintain backwards compatibility (underscored parameters), one needs to override the "getValue" and "add_param" methods, - // which are final in ReflectiveModule. However, using reflective module for the + // which are final in ReflectiveModule. However, using reflective module for the // rest of the parameters still made refactoring much easier. So let's call // this "necessary". td, apr'15 @@ -82,14 +82,14 @@ public StrategySettings(final Id id) { // this.strategyName = id.toString() ; // safety net, can be overridden by (also deprecated) setStrategyName(...). kai/mz, nov'15 // putting the above into the code fails at least one test. We would vote for removing that test ... } - + @Override public final Map getComments() { Map map = super.getComments(); // put comments only for the first strategy to improve readability // I think that the above comment is a todo, not a description of the code status. kai, feb'15 - + StringBuilder sels = new StringBuilder() ; sels.append( DefaultSelector.SelectRandom ) ; sels.append( ' ' ); @@ -102,7 +102,7 @@ public final Map getComments() { sels.append( DefaultSelector.SelectExpBeta ) ; sels.append( ' ' ); sels.append( DefaultSelector.SelectPathSizeLogit ) ; - + StringBuilder strats = new StringBuilder() ; strats.append( DefaultStrategy.ReRoute ) ; sels.append( ' ' ); @@ -115,7 +115,7 @@ public final Map getComments() { strats.append( DefaultStrategy.ChangeTripMode ) ; sels.append( ' ' ); strats.append( DefaultStrategy.SubtourModeChoice ) ; - + map.put( "strategyName", "strategyName of strategy. Possible default names: " + sels + " (selectors), " + strats + " (innovative strategies)." ); map.put( "weight", @@ -139,7 +139,7 @@ protected void checkConsistency(Config config) { throw new RuntimeException("Strategy strategyName is not set"); } if ( getWeight() < 0.0 ) { - throw new RuntimeException("Weight for strategy " + getStrategyName() + " must be >= 0.0" ); + throw new RuntimeException("Weight for strategy " + getStrategyName() + " must be >= 0.0" ); } } @@ -204,7 +204,7 @@ public String getSubpopulation() { } } - public StrategyConfigGroup() { + public ReplanningConfigGroup() { super(GROUP_NAME); } @@ -286,7 +286,7 @@ public final Map getComments() { + "Possible defaults: " + strb.toString() + ". The current default, WorstPlanSelector is not a good " + "choice from a discrete choice theoretical perspective. Alternatives, however, have not been systematically " + "tested. kai, feb'12") ; - + map.put(ReflectiveDelegate.EXTERNAL_EXE_CONFIG_TEMPLATE,"the external executable will be called with a config file as argument. This is the pathname to a possible " + "skeleton config, to which additional information will be added. Can be null."); map.put(ReflectiveDelegate.EXTERNAL_EXE_TMP_FILE_ROOT_DIR, "root directory for temporary files generated by the external executable. Provided as a service; " @@ -328,7 +328,7 @@ public ConfigGroup createParameterSet(final String type) { public void addStrategySettings(final StrategySettings stratSets) { addParameterSet( stratSets ); } - + public final void clearStrategySettings() { this.clearParameterSetsForType( StrategySettings.SET_NAME ) ; } @@ -391,7 +391,7 @@ public void setPlanSelectorForRemoval(String planSelectorForRemoval) { throw new RuntimeException("'ChangeExpBeta' was replaced by 'ChangeExpBetaForRemoval' in the plans removal setting" ) ; case "PathSizeLogitSelector" : throw new RuntimeException("'PathSizeLogitSelector' was replaced by 'PathSizeLogitSelectorForRemoval' in the plans removal setting" ) ; - default: + default: delegate.setPlanSelectorForRemoval(planSelectorForRemoval) ; } } @@ -423,13 +423,13 @@ private static class ReflectiveDelegate extends ReflectiveConfigGroup { private long externalExeTimeOut = 3600; private String planSelectorForRemoval = "WorstPlanSelector"; - + //--- private double fraction = Double.POSITIVE_INFINITY ; //--- public ReflectiveDelegate() { - super( StrategyConfigGroup.GROUP_NAME ); + super( ReplanningConfigGroup.GROUP_NAME ); } diff --git a/matsim/src/main/java/org/matsim/core/config/groups/PlansCalcRouteConfigGroup.java b/matsim/src/main/java/org/matsim/core/config/groups/RoutingConfigGroup.java similarity index 98% rename from matsim/src/main/java/org/matsim/core/config/groups/PlansCalcRouteConfigGroup.java rename to matsim/src/main/java/org/matsim/core/config/groups/RoutingConfigGroup.java index 638c1883455..a693d0c0297 100644 --- a/matsim/src/main/java/org/matsim/core/config/groups/PlansCalcRouteConfigGroup.java +++ b/matsim/src/main/java/org/matsim/core/config/groups/RoutingConfigGroup.java @@ -40,12 +40,12 @@ * @author dgrether * @author mrieser */ -public final class PlansCalcRouteConfigGroup extends ConfigGroup { +public final class RoutingConfigGroup extends ConfigGroup { // yy There is a certain degree of messiness in this class because of retrofitting, e.g. making beelineDistance mode-specific while // being backwards compatible. This could eventually be cleaned up, maybe about a year after introducing it. kai, jun'15 - - public static final String GROUP_NAME = "planscalcroute"; - + + public static final String GROUP_NAME = "routing"; + private static final String BEELINE_DISTANCE_FACTOR = "beelineDistanceFactor"; private static final String NETWORK_MODES = "networkModes"; private static final String TELEPORTED_MODE_SPEEDS = "teleportedModeSpeed_"; @@ -53,7 +53,7 @@ public final class PlansCalcRouteConfigGroup extends ConfigGroup { public static final String UNDEFINED = "undefined"; - + // For config file backward compatibility. // These are just hardcoded versions of the options above. private static final String PT_SPEED_FACTOR = "ptSpeedFactor"; @@ -61,13 +61,13 @@ public final class PlansCalcRouteConfigGroup extends ConfigGroup { private static final String WALK_SPEED = "walkSpeed"; private static final String BIKE_SPEED = "bikeSpeed"; private static final String UNDEFINED_MODE_SPEED = "undefinedModeSpeed"; - - private static final Logger log = LogManager.getLogger(PlansCalcRouteConfigGroup.class) ; - + + private static final Logger log = LogManager.getLogger(RoutingConfigGroup.class) ; + private Collection networkModes = Collections.singletonList( TransportMode.car ); private boolean acceptModeParamsWithoutClearing; - + private Double beelineDistanceFactor = 1.3 ; public enum AccessEgressType { @@ -138,13 +138,13 @@ public static class TeleportedModeParams extends ReflectiveConfigGroup implement public static final String SET_TYPE = "teleportedModeParameters"; public static final String MODE = "mode"; public static final String TELEPORTED_MODE_FREESPEED_FACTOR = "teleportedModeFreespeedFactor"; - + private String mode = null; // beeline teleportation: private Double teleportedModeSpeed = null; private Double beelineDistanceFactorForMode = null ; - + // route computed on network: private Double teleportedModeFreespeedFactor = null; private Double teleportedModeFreespeedLimit = Double.POSITIVE_INFINITY ; @@ -153,7 +153,7 @@ public static class TeleportedModeParams extends ReflectiveConfigGroup implement "Travel time = teleportedModeFreespeedFactor * . Insert a line like this for every such mode. " + "Please do not set teleportedModeFreespeedFactor as well as teleportedModeSpeed for the same mode, but if you do, +" + "teleportedModeFreespeedFactor wins over teleportedModeSpeed."; - + private static final String TELEPORTED_MODE_FREESPEED_LIMIT_CMT = "When using freespeed factor, a speed limit on the free speed. " + "Link travel time will be $= factor * [ min( link_freespeed, freespeed_limit) ]" ; @@ -194,7 +194,7 @@ public Map getComments() { /** * Currently not in xml interface. - * + * * @return teleportedModeFreespeedLimit -- {@value #TELEPORTED_MODE_FREESPEED_LIMIT_CMT} */ public final Double getTeleportedModeFreespeedLimit() { @@ -203,7 +203,7 @@ public final Double getTeleportedModeFreespeedLimit() { /** * Currently not in xml interface. - * + * * @param teleportedModeFreespeedLimit -- {@value #TELEPORTED_MODE_FREESPEED_LIMIT_CMT} */ public TeleportedModeParams setTeleportedModeFreespeedLimit( Double teleportedModeFreespeedLimit ) { @@ -237,7 +237,7 @@ public TeleportedModeParams setTeleportedModeSpeed( Double teleportedModeSpeed ) this.teleportedModeSpeed = teleportedModeSpeed; return this; } - + /** * @return {@value #TELEPORTED_MODE_FREESPEED_FACTOR_CMT} */ @@ -245,7 +245,7 @@ public TeleportedModeParams setTeleportedModeSpeed( Double teleportedModeSpeed ) public Double getTeleportedModeFreespeedFactor() { return teleportedModeFreespeedFactor; } - + /** * @param teleportedModeFreespeedFactor -- {@value #TELEPORTED_MODE_FREESPEED_FACTOR_CMT} */ @@ -259,7 +259,7 @@ public TeleportedModeParams setTeleportedModeFreespeedFactor( this.teleportedModeFreespeedFactor = teleportedModeFreespeedFactor; return this; } - + @StringSetter("beelineDistanceFactor") public TeleportedModeParams setBeelineDistanceFactor( Double val ) { testForLocked() ; @@ -270,10 +270,10 @@ public TeleportedModeParams setBeelineDistanceFactor( Double val ) { public Double getBeelineDistanceFactor() { return this.beelineDistanceFactorForMode ; } - + } - - public PlansCalcRouteConfigGroup() { + + public RoutingConfigGroup() { super(GROUP_NAME); acceptModeParamsWithoutClearing = true; @@ -288,7 +288,7 @@ public PlansCalcRouteConfigGroup() { walk.setTeleportedModeSpeed( 3.0 / 3.6 ); // 3.0 km/h --> m/s addParameterSet( walk ); } - + // the following two are deliberately different from "walk" since "walk" may become a network routing mode, but these two // will not. kai, dec'15 { @@ -333,7 +333,7 @@ public PlansCalcRouteConfigGroup() { // addParameterSet( transit_walk ); // } // one might add the above but it was not added in the original design. Not sure about the reason. kai, feb'15 - + this.acceptModeParamsWithoutClearing = false; } @@ -461,7 +461,7 @@ public Map getModeRoutingParams() { for ( ConfigGroup pars : getParameterSets( TeleportedModeParams.SET_TYPE ) ) { if ( this.isLocked() ) { - pars.setLocked(); + pars.setLocked(); } final String mode = ((TeleportedModeParams) pars).getMode(); final TeleportedModeParams old = map.put( mode , (TeleportedModeParams) pars ); @@ -480,7 +480,7 @@ public TeleportedModeParams getOrCreateModeRoutingParams( final String mode ) { addParameterSet( pars ); } if ( this.isLocked() ) { - pars.setLocked(); + pars.setLocked(); } return pars; @@ -562,7 +562,7 @@ public Map getTeleportedModeSpeeds() { final Map map = new LinkedHashMap< >(); for ( TeleportedModeParams pars : getModeRoutingParams().values() ) { if ( this.isLocked() ) { - pars.setLocked(); + pars.setLocked(); } final Double speed = pars.getTeleportedModeSpeed(); @@ -575,7 +575,7 @@ public Map getTeleportedModeFreespeedFactors() { final Map map = new LinkedHashMap< >(); for ( TeleportedModeParams pars : getModeRoutingParams().values() ) { if ( this.isLocked() ) { - pars.setLocked(); + pars.setLocked(); } final Double speed = pars.getTeleportedModeFreespeedFactor(); @@ -583,12 +583,12 @@ public Map getTeleportedModeFreespeedFactors() { } return map; } - + public Map getBeelineDistanceFactors() { final Map map = new LinkedHashMap<>() ; for ( TeleportedModeParams pars : getModeRoutingParams().values() ) { if ( this.isLocked() ) { - pars.setLocked(); + pars.setLocked(); } final Double val = pars.getBeelineDistanceFactor() ; @@ -614,16 +614,16 @@ public void setTeleportedModeSpeed(String mode, double speed) { pars.setTeleportedModeSpeed( speed ); addParameterSet( pars ); } - + @Deprecated // use mode-specific beeline distance factors! kai, apr'15 public void setBeelineDistanceFactor(double val) { testForLocked() ; // yyyy thinking about this: this should in design maybe not be different from the other teleportation factors (reset everything // if one is set; or possibly disallow setting it at all). kai, feb'15 - + // memorize the global factor for ModeRoutingParams that are added later: this.beelineDistanceFactor = val ; - + // push the global factor to the local ones for all ModeRoutingParams that are already there: for ( TeleportedModeParams params : this.getModeRoutingParams().values() ) { params.setBeelineDistanceFactor( val ); diff --git a/matsim/src/main/java/org/matsim/core/config/groups/PlanCalcScoreConfigGroup.java b/matsim/src/main/java/org/matsim/core/config/groups/ScoringConfigGroup.java similarity index 99% rename from matsim/src/main/java/org/matsim/core/config/groups/PlanCalcScoreConfigGroup.java rename to matsim/src/main/java/org/matsim/core/config/groups/ScoringConfigGroup.java index 973bb8890bc..effe07e8059 100644 --- a/matsim/src/main/java/org/matsim/core/config/groups/PlanCalcScoreConfigGroup.java +++ b/matsim/src/main/java/org/matsim/core/config/groups/ScoringConfigGroup.java @@ -52,15 +52,15 @@ *
  • The parameter names in the config file are not changed in this way * since this would mean a public api change. kai, dec'10 * - * + * * @author nagel * */ -public final class PlanCalcScoreConfigGroup extends ConfigGroup { +public final class ScoringConfigGroup extends ConfigGroup { - private static final Logger log = LogManager.getLogger(PlanCalcScoreConfigGroup.class); + private static final Logger log = LogManager.getLogger(ScoringConfigGroup.class); - public static final String GROUP_NAME = "planCalcScore"; + public static final String GROUP_NAME = "scoring"; private static final String LEARNING_RATE = "learningRate"; private static final String BRAIN_EXP_BETA = "BrainExpBeta"; @@ -79,10 +79,10 @@ public final class PlanCalcScoreConfigGroup extends ConfigGroup { private static final String UTL_OF_LINE_SWITCH = "utilityOfLineSwitch"; private final ReflectiveDelegate delegate = new ReflectiveDelegate(); - + private boolean usesDeprecatedSyntax = false ; - public PlanCalcScoreConfigGroup() { + public ScoringConfigGroup() { super(GROUP_NAME); this.addScoringParameters(new ScoringParameterSet()); @@ -177,13 +177,13 @@ public static String createStageActivityType( String mode ){ public String getValue(final String key) { throw new IllegalArgumentException(key + ": getValue access disabled; use direct getter"); } - + private static final String msg = " is deprecated config syntax; please use the more " + "modern hierarchical format; your output_config.xml " + "will be in the correct version; the old version will fail eventually, since we want to reduce the " + "workload on this backwards compatibility (look into " + "PlanCalcScoreConfigGroup or PlanCalcRouteConfigGroup if you want to know what we mean)."; - + @Override public void addParam(final String key, final String value) { testForLocked(); @@ -198,7 +198,7 @@ public void addParam(final String key, final String value) { else if (key.startsWith("activityType_")) { log.warn( key + msg ); usesDeprecatedSyntax = true ; - + ActivityParams actParams = getActivityTypeByNumber(key.substring("activityType_".length())); actParams.setActivityType(value); @@ -348,7 +348,7 @@ else if (Arrays // log.warn( key + msg ); // usesDeprecatedSyntax = true ; // this is the stuff with the default subpopulation - + getScoringParameters(null).addParam(key, value); } @@ -420,7 +420,7 @@ public final Map getComments() { return map; } - + /* * * @returns a list of all Activities over all Subpopulations (if existent) @@ -442,15 +442,15 @@ public Collection getActivityTypes() { public Collection getAllModes() { if (getScoringParameters(null) != null) { return getScoringParameters(null).getModes().keySet(); - + } else { Set modes = new HashSet<>(); getScoringParametersPerSubpopulation().values().forEach(item -> modes.addAll(item.getModes().keySet())); return modes; } - + } - + public Collection getActivityParams() { if (getScoringParameters(null) != null) return getScoringParameters(null).getActivityParams(); @@ -469,8 +469,8 @@ else if (getScoringParameters(DEFAULT_SUBPOPULATION) != null) throw new RuntimeException("Default subpopulation is not defined"); } - - + + public Map getScoringParametersPerSubpopulation() { @SuppressWarnings("unchecked") final Collection parameters = (Collection) getParameterSets( @@ -609,14 +609,14 @@ protected void checkParameterSet(final ConfigGroup module) { @Override protected final void checkConsistency(final Config config) { super.checkConsistency(config); - + if ( usesDeprecatedSyntax && !config.global().isInsistingOnDeprecatedConfigVersion() ) { throw new RuntimeException( msg ) ; } - + if (getScoringParametersPerSubpopulation().size()>1){ - if (!getScoringParametersPerSubpopulation().containsKey(PlanCalcScoreConfigGroup.DEFAULT_SUBPOPULATION)){ - throw new RuntimeException("Using several subpopulations in "+PlanCalcScoreConfigGroup.GROUP_NAME+" requires defining a \""+PlanCalcScoreConfigGroup.DEFAULT_SUBPOPULATION+" \" subpopulation." + if (!getScoringParametersPerSubpopulation().containsKey(ScoringConfigGroup.DEFAULT_SUBPOPULATION)){ + throw new RuntimeException("Using several subpopulations in "+ ScoringConfigGroup.GROUP_NAME+" requires defining a \""+ ScoringConfigGroup.DEFAULT_SUBPOPULATION+" \" subpopulation." + " Otherwise, crashes can be expected."); } } @@ -819,7 +819,7 @@ public static class ActivityParams extends ReflectiveConfigGroup implements Mats // ActivityParams. I will try to pass the locked setting through the getters. kai, jun'15 public final static String SET_TYPE = "activityParams"; - + // --- private static final String TYPICAL_DURATION_SCORE_COMPUTATION = "typicalDurationScoreComputation"; @@ -1070,7 +1070,7 @@ public ActivityParams setClosingTime(final double closingTime) { } // --- - + static final String SCORING_THIS_ACTIVITY_AT_ALL = "scoringThisActivityAtAll"; private boolean scoringThisActivityAtAll = true; @@ -1091,7 +1091,7 @@ public ActivityParams setScoringThisActivityAtAll(boolean scoringThisActivityAtA public static class ModeParams extends ReflectiveConfigGroup implements MatsimParameters { final static String SET_TYPE = "modeParams"; - + private static final String MONETARY_DISTANCE_RATE = "monetaryDistanceRate"; private static final String MONETARY_DISTANCE_RATE_CMT = "[unit_of_money/m] conversion of distance into money. Normally negative."; @@ -1101,12 +1101,12 @@ public static class ModeParams extends ReflectiveConfigGroup implements MatsimPa private static final String CONSTANT_CMT = "[utils] alternative-specific constant. Normally per trip, but that is probably buggy for multi-leg trips."; public static final String MODE = "mode"; - + private static final String DAILY_MONETARY_CONSTANT = "dailyMonetaryConstant"; private static final String DAILY_MONETARY_CONSTANT_CMT = "[unit_of_money/day] Fixed cost of mode, per day."; private static final String DAILY_UTILITY_CONSTANT = "dailyUtilityConstant"; - + private String mode = null; private double traveling = -6.0; private double distance = 0.0; @@ -1524,12 +1524,12 @@ public void addActivityParams(final ActivityParams params) { @Override public void checkConsistency(Config config) { super.checkConsistency(config); - - + + boolean hasOpeningAndClosingTime = false; boolean hasOpeningTimeAndLatePenalty = false; - + // This cannot be done in ActivityParams (where it would make more // sense), // because some global properties are also checked @@ -1572,7 +1572,7 @@ public void checkConsistency(Config config) { private static class ReflectiveDelegate extends ReflectiveConfigGroup { private ReflectiveDelegate() { - super(PlanCalcScoreConfigGroup.GROUP_NAME); + super(ScoringConfigGroup.GROUP_NAME); } private double learningRate = 1.0; diff --git a/matsim/src/main/java/org/matsim/core/config/groups/TimeAllocationMutatorConfigGroup.java b/matsim/src/main/java/org/matsim/core/config/groups/TimeAllocationMutatorConfigGroup.java index 822763c7683..f9e7d9b2718 100644 --- a/matsim/src/main/java/org/matsim/core/config/groups/TimeAllocationMutatorConfigGroup.java +++ b/matsim/src/main/java/org/matsim/core/config/groups/TimeAllocationMutatorConfigGroup.java @@ -28,8 +28,8 @@ public final class TimeAllocationMutatorConfigGroup extends ReflectiveConfigGroup { - public static final String GROUP_NAME = "TimeAllocationMutator"; - + public static final String GROUP_NAME = "timeAllocationMutator"; + public TimeAllocationMutatorConfigGroup() { super(GROUP_NAME); } @@ -43,7 +43,7 @@ public Map getComments() { + "If enabled but no settings are found, regular settings are uses as fallback."); return comments; } - + // --- private static final String MUTATION_RANGE = "mutationRange"; @@ -56,9 +56,9 @@ public double getMutationRange() { public void setMutationRange(final double val) { this.mutationRange = val; } - + // --- - + private static final String MUTATION_AFFECTS_DURATION = "mutationAffectsDuration"; private boolean affectingDuration = true; @StringGetter(MUTATION_AFFECTS_DURATION) @@ -69,9 +69,9 @@ public boolean isAffectingDuration() { public void setAffectingDuration(boolean affectingDuration) { this.affectingDuration = affectingDuration; } - + // --- - + private static final String USE_INDIVIDUAL_SETTINGS_FOR_SUBPOPULATIONS = "useIndividualSettingsForSubpopulations"; private boolean useIndividualSettingsForSubpopulations = false; // @StringGetter(USE_INDIVIDUAL_SETTINGS_FOR_SUBPOPULATIONS) // I am disabling the xml usage for the time being, see comment below. kai, may'19 @@ -86,13 +86,13 @@ public void setUseIndividualSettingsForSubpopulations(boolean useIndividualSetti // yyyy see comment under isUseIndividualSettingsForSubpopulations. kai, may'10 this.useIndividualSettingsForSubpopulations = useIndividualSettingsForSubpopulations; } - + // --- - + public TimeAllocationMutatorSubpopulationSettings getTimeAllocationMutatorSubpopulationSettings(String subpopulation) { - + if (subpopulation == null) return null; - + Collection configGroups = this.getParameterSets(TimeAllocationMutatorSubpopulationSettings.SET_NAME); for (ConfigGroup group : configGroups) { if (group instanceof TimeAllocationMutatorSubpopulationSettings) { @@ -100,10 +100,10 @@ public TimeAllocationMutatorSubpopulationSettings getTimeAllocationMutatorSubpop if (subpopulation.equals(subpopulationSettings.subpopulation)) return subpopulationSettings; } } - + return null; } - + @Override public ConfigGroup createParameterSet(final String type) { switch (type) { @@ -113,7 +113,7 @@ public ConfigGroup createParameterSet(final String type) { throw new IllegalArgumentException("unknown set type '" + type + "'"); } } - + @Override public void addParameterSet(final ConfigGroup set) { switch (set.getName()) { @@ -124,22 +124,22 @@ public void addParameterSet(final ConfigGroup set) { throw new IllegalArgumentException( set.getName() ); } } - + public static class TimeAllocationMutatorSubpopulationSettings extends ReflectiveConfigGroup { - + public static final String SET_NAME = "subpopulationSettings"; private static final String MUTATION_RANGE = "mutationRange"; private static final String MUTATION_AFFECTS_DURATION = "mutationAffectsDuration"; private static final String SUBPOPULATION = "subpopulation"; - + private double mutationRange = 1800.0; private boolean affectingDuration = true; private String subpopulation = null; - + public TimeAllocationMutatorSubpopulationSettings() { super(SET_NAME); } - + @Override public final Map getComments() { Map comments = super.getComments(); @@ -153,17 +153,17 @@ public final Map getComments() { public double getMutationRange() { return this.mutationRange; } - + @StringSetter(MUTATION_RANGE) public void setMutationRange(final double val) { this.mutationRange = val; } - + @StringGetter(MUTATION_AFFECTS_DURATION) public boolean isAffectingDuration() { return affectingDuration; } - + @StringSetter(MUTATION_AFFECTS_DURATION) public void setAffectingDuration(boolean affectingDuration) { this.affectingDuration = affectingDuration; diff --git a/matsim/src/main/java/org/matsim/core/controler/NewControler.java b/matsim/src/main/java/org/matsim/core/controler/NewControler.java index c36813f7be2..13047b030fd 100755 --- a/matsim/src/main/java/org/matsim/core/controler/NewControler.java +++ b/matsim/src/main/java/org/matsim/core/controler/NewControler.java @@ -24,7 +24,7 @@ import org.matsim.analysis.IterationStopWatch; import org.matsim.core.config.Config; import org.matsim.core.config.consistency.ConfigConsistencyCheckerImpl; -import org.matsim.core.config.groups.ControlerConfigGroup; +import org.matsim.core.config.groups.ControllerConfigGroup; import org.matsim.core.controler.corelisteners.*; import org.matsim.core.controler.listener.ControlerListener; import org.matsim.core.mobsim.framework.Mobsim; @@ -48,7 +48,7 @@ class NewControler extends AbstractController implements ControlerI { private final TerminationCriterion terminationCriterion; private final DumpDataAtEnd dumpDataAtEnd; private final Set controlerListenersDeclaredByModules; - private final ControlerConfigGroup controlerConfigGroup; + private final ControllerConfigGroup controllerConfigGroup; private final OutputDirectoryHierarchy outputDirectoryHierarchy; @Inject @@ -56,7 +56,7 @@ class NewControler extends AbstractController implements ControlerI { IterationStopWatch stopWatch, PrepareForSim prepareForSim, EventsHandling eventsHandling, PlansDumping plansDumping, PlansReplanning plansReplanning, Provider mobsimProvider, PlansScoring plansScoring, TerminationCriterion terminationCriterion, DumpDataAtEnd dumpDataAtEnd, - Set controlerListenersDeclaredByModules, ControlerConfigGroup controlerConfigGroup, + Set controlerListenersDeclaredByModules, ControllerConfigGroup controllerConfigGroup, OutputDirectoryHierarchy outputDirectoryHierarchy , PrepareForMobsim prepareForMobsim ) { @@ -73,7 +73,7 @@ class NewControler extends AbstractController implements ControlerI { this.terminationCriterion = terminationCriterion; this.dumpDataAtEnd = dumpDataAtEnd; this.controlerListenersDeclaredByModules = controlerListenersDeclaredByModules; - this.controlerConfigGroup = controlerConfigGroup; + this.controllerConfigGroup = controllerConfigGroup; this.outputDirectoryHierarchy = outputDirectoryHierarchy; } @@ -94,7 +94,7 @@ protected final void loadCoreListeners() { * IMPORTANT: The execution order is reverse to the order the listeners * are added to the list. */ - if (controlerConfigGroup.getDumpDataAtEnd()) { + if (controllerConfigGroup.getDumpDataAtEnd()) { this.addCoreControlerListener(this.dumpDataAtEnd); } diff --git a/matsim/src/main/java/org/matsim/core/controler/OutputDirectoryHierarchy.java b/matsim/src/main/java/org/matsim/core/controler/OutputDirectoryHierarchy.java index 39e389ab155..fa69f8d803c 100644 --- a/matsim/src/main/java/org/matsim/core/controler/OutputDirectoryHierarchy.java +++ b/matsim/src/main/java/org/matsim/core/controler/OutputDirectoryHierarchy.java @@ -29,7 +29,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.matsim.core.config.Config; -import org.matsim.core.config.groups.ControlerConfigGroup; +import org.matsim.core.config.groups.ControllerConfigGroup; import org.matsim.core.utils.io.IOUtils; import jakarta.inject.Inject; @@ -53,12 +53,12 @@ public enum OverwriteFileSetting {failIfDirectoryExists, overwriteExistingFiles, private final String outputPath; - private final ControlerConfigGroup.CompressionType defaultCompressionType; + private final ControllerConfigGroup.CompressionType defaultCompressionType; private OverwriteFileSetting overwriteFiles = OverwriteFileSetting.failIfDirectoryExists; @Inject - OutputDirectoryHierarchy(ControlerConfigGroup config) { + OutputDirectoryHierarchy(ControllerConfigGroup config) { this(config.getOutputDirectory(), config.getRunId(), @@ -75,11 +75,11 @@ public OutputDirectoryHierarchy( Config config ) { this( config.controler().getOutputDirectory(), config.controler().getRunId(), config.controler().getOverwriteFileSetting(), config.controler().getCompressionType() ); } - public OutputDirectoryHierarchy(String outputPath, OverwriteFileSetting overwriteFiles, ControlerConfigGroup.CompressionType defaultCompressionType) { + public OutputDirectoryHierarchy(String outputPath, OverwriteFileSetting overwriteFiles, ControllerConfigGroup.CompressionType defaultCompressionType) { this(outputPath, null, overwriteFiles, true, defaultCompressionType); } - public OutputDirectoryHierarchy(String outputPath, String runId, OverwriteFileSetting overwriteFiles, ControlerConfigGroup.CompressionType defaultCompressionType) { + public OutputDirectoryHierarchy(String outputPath, String runId, OverwriteFileSetting overwriteFiles, ControllerConfigGroup.CompressionType defaultCompressionType) { this(outputPath, runId, overwriteFiles, true, defaultCompressionType); } /** @@ -89,7 +89,7 @@ public OutputDirectoryHierarchy(String outputPath, String runId, OverwriteFileSe * @param outputPath the path to the output directory * @param createDirectories create the directories or abort if they exist */ - public OutputDirectoryHierarchy(String outputPath, String runId, OverwriteFileSetting overwriteFiles, boolean createDirectories, ControlerConfigGroup.CompressionType compressionType){ + public OutputDirectoryHierarchy(String outputPath, String runId, OverwriteFileSetting overwriteFiles, boolean createDirectories, ControllerConfigGroup.CompressionType compressionType){ this.overwriteFiles = overwriteFiles; if (outputPath.endsWith("/")) { outputPath = outputPath.substring(0, outputPath.length() - 1); @@ -144,7 +144,7 @@ public final String getIterationFilename(final int iteration, final String filen return s.toString(); } - public String getIterationFilename(int iteration, String filename, ControlerConfigGroup.CompressionType compression) { + public String getIterationFilename(int iteration, String filename, ControllerConfigGroup.CompressionType compression) { if (compression == null) { return getIterationFilename(iteration, filename); } @@ -155,7 +155,7 @@ public final String getIterationFilename(int iteration, Controler.DefaultFiles f return getIterationFilename(iteration, file, this.defaultCompressionType); } - public final String getIterationFilename(int iteration, Controler.DefaultFiles file, ControlerConfigGroup.CompressionType compression) { + public final String getIterationFilename(int iteration, Controler.DefaultFiles file, ControllerConfigGroup.CompressionType compression) { if (compression == null) { return getIterationFilename(iteration, file.filename); } @@ -180,7 +180,7 @@ public final String getOutputFilename(final String filename) { return s.toString(); } - public String getOutputFilename(String filename, ControlerConfigGroup.CompressionType compression) { + public String getOutputFilename(String filename, ControllerConfigGroup.CompressionType compression) { if (compression == null) { return getOutputFilename(filename); } @@ -195,7 +195,7 @@ public final String getOutputFilename(Controler.DefaultFiles file) { return getOutputFilename(file, this.defaultCompressionType); } - public final String getOutputFilename(Controler.DefaultFiles file, ControlerConfigGroup.CompressionType compression) { + public final String getOutputFilename(Controler.DefaultFiles file, ControllerConfigGroup.CompressionType compression) { if (compression == null) { return getOutputFilename(Controler.OUTPUT_PREFIX + file.filename); } diff --git a/matsim/src/main/java/org/matsim/core/controler/TerminateAtFixedIterationNumber.java b/matsim/src/main/java/org/matsim/core/controler/TerminateAtFixedIterationNumber.java index 6ce863d4164..d5b3a7a95dc 100644 --- a/matsim/src/main/java/org/matsim/core/controler/TerminateAtFixedIterationNumber.java +++ b/matsim/src/main/java/org/matsim/core/controler/TerminateAtFixedIterationNumber.java @@ -23,14 +23,14 @@ import jakarta.inject.Inject; -import org.matsim.core.config.groups.ControlerConfigGroup; +import org.matsim.core.config.groups.ControllerConfigGroup; class TerminateAtFixedIterationNumber implements TerminationCriterion { private final int lastIteration; @Inject - TerminateAtFixedIterationNumber(ControlerConfigGroup controlerConfigGroup) { - this.lastIteration = controlerConfigGroup.getLastIteration(); + TerminateAtFixedIterationNumber(ControllerConfigGroup controllerConfigGroup) { + this.lastIteration = controllerConfigGroup.getLastIteration(); } @Override diff --git a/matsim/src/main/java/org/matsim/core/controler/corelisteners/DumpDataAtEndImpl.java b/matsim/src/main/java/org/matsim/core/controler/corelisteners/DumpDataAtEndImpl.java index 25fd325c37a..21388d19e1e 100644 --- a/matsim/src/main/java/org/matsim/core/controler/corelisteners/DumpDataAtEndImpl.java +++ b/matsim/src/main/java/org/matsim/core/controler/corelisteners/DumpDataAtEndImpl.java @@ -30,7 +30,7 @@ import org.matsim.api.core.v01.population.PopulationWriter; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigWriter; -import org.matsim.core.config.groups.ControlerConfigGroup; +import org.matsim.core.config.groups.ControllerConfigGroup; import org.matsim.core.config.groups.VspExperimentalConfigGroup; import org.matsim.core.controler.Controler; import org.matsim.core.controler.OutputDirectoryHierarchy; @@ -69,7 +69,7 @@ final class DumpDataAtEndImpl implements DumpDataAtEnd, ShutdownListener { private Config config; @Inject - private ControlerConfigGroup controlerConfigGroup; + private ControllerConfigGroup controllerConfigGroup; @Inject private VspExperimentalConfigGroup vspConfig; @@ -129,7 +129,7 @@ public void notifyShutdown(ShutdownEvent event) { dumpLanes(); dumpCounts(); - if (!event.isUnexpected() && this.vspConfig.isWritingOutputEvents() && (this.controlerConfigGroup.getWriteEventsInterval()!=0)) { + if (!event.isUnexpected() && this.vspConfig.isWritingOutputEvents() && (this.controllerConfigGroup.getWriteEventsInterval()!=0)) { dumpOutputEvents(event.getIteration()); } dumpOutputTrips(event.getIteration()); @@ -137,13 +137,13 @@ public void notifyShutdown(ShutdownEvent event) { dumpOutputActivities(event.getIteration()); dumpExperiencedPlans(event.getIteration()); - if (controlerConfigGroup.getCleanItersAtEnd() == ControlerConfigGroup.CleanIterations.delete) { + if (controllerConfigGroup.getCleanItersAtEnd() == ControllerConfigGroup.CleanIterations.delete) { this.controlerIO.deleteIterationDirectory(); } } private void dumpOutputEvents(int iteration) { - for (ControlerConfigGroup.EventsFileFormat format : this.controlerConfigGroup.getEventsFileFormats()) { + for (ControllerConfigGroup.EventsFileFormat format : this.controllerConfigGroup.getEventsFileFormats()) { try{ Controler.DefaultFiles file; switch (format) { @@ -306,8 +306,8 @@ private void dumpFacilities() { private void dumpConfig() { // dump config - new ConfigWriter(this.config).write(this.controlerIO.getOutputFilename(Controler.DefaultFiles.config, ControlerConfigGroup.CompressionType.none)); - new ConfigWriter(this.config, ConfigWriter.Verbosity.minimal).write(this.controlerIO.getOutputFilename(Controler.DefaultFiles.configReduced, ControlerConfigGroup.CompressionType.none)); + new ConfigWriter(this.config).write(this.controlerIO.getOutputFilename(Controler.DefaultFiles.config, ControllerConfigGroup.CompressionType.none)); + new ConfigWriter(this.config, ConfigWriter.Verbosity.minimal).write(this.controlerIO.getOutputFilename(Controler.DefaultFiles.configReduced, ControllerConfigGroup.CompressionType.none)); } private void dumpNetwork() { diff --git a/matsim/src/main/java/org/matsim/core/controler/corelisteners/EventsHandlingImpl.java b/matsim/src/main/java/org/matsim/core/controler/corelisteners/EventsHandlingImpl.java index e4d87291d8b..722bbe2c0d9 100644 --- a/matsim/src/main/java/org/matsim/core/controler/corelisteners/EventsHandlingImpl.java +++ b/matsim/src/main/java/org/matsim/core/controler/corelisteners/EventsHandlingImpl.java @@ -32,8 +32,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.matsim.core.api.experimental.events.EventsManager; -import org.matsim.core.config.groups.ControlerConfigGroup; -import org.matsim.core.config.groups.ControlerConfigGroup.EventsFileFormat; +import org.matsim.core.config.groups.ControllerConfigGroup; +import org.matsim.core.config.groups.ControllerConfigGroup.EventsFileFormat; import org.matsim.core.controler.Controler; import org.matsim.core.controler.OutputDirectoryHierarchy; import org.matsim.core.controler.events.BeforeMobsimEvent; @@ -54,14 +54,14 @@ final class EventsHandlingImpl implements EventsHandling, BeforeMobsimListener, IterationEndsListener, ShutdownListener { final static private Logger log = LogManager.getLogger(EventsHandlingImpl.class); - + private final EventsManager eventsManager; private List eventWriters = new LinkedList<>(); private int writeEventsInterval; - + private Set eventsFileFormats ; - + private OutputDirectoryHierarchy controlerIO ; private int writeMoreUntilIteration; @@ -69,7 +69,7 @@ final class EventsHandlingImpl implements EventsHandling, BeforeMobsimListener, @Inject EventsHandlingImpl( final EventsManager eventsManager, - final ControlerConfigGroup config, + final ControllerConfigGroup config, final OutputDirectoryHierarchy controlerIO) { this.eventsManager = eventsManager; this.writeEventsInterval = config.getWriteEventsInterval(); @@ -118,11 +118,11 @@ public void notifyBeforeMobsim(BeforeMobsimEvent event) { } } } - + @Override public void notifyIterationEnds(IterationEndsEvent event) { /* - * Events that are produced after the Mobsim has ended, e.g. by the RoadProcing + * Events that are produced after the Mobsim has ended, e.g. by the RoadProcing * module, should also be written to the events file. */ for (EventWriter writer : this.eventWriters) { @@ -138,5 +138,5 @@ public void notifyShutdown(ShutdownEvent event) { writer.closeFile(); } } - + } diff --git a/matsim/src/main/java/org/matsim/core/controler/corelisteners/PlansDumpingImpl.java b/matsim/src/main/java/org/matsim/core/controler/corelisteners/PlansDumpingImpl.java index 5857544e818..66a57005853 100644 --- a/matsim/src/main/java/org/matsim/core/controler/corelisteners/PlansDumpingImpl.java +++ b/matsim/src/main/java/org/matsim/core/controler/corelisteners/PlansDumpingImpl.java @@ -27,7 +27,7 @@ import org.matsim.api.core.v01.population.Population; import org.matsim.api.core.v01.population.PopulationWriter; import org.matsim.core.config.Config; -import org.matsim.core.config.groups.ControlerConfigGroup; +import org.matsim.core.config.groups.ControllerConfigGroup; import org.matsim.core.controler.Controler; import org.matsim.core.controler.OutputDirectoryHierarchy; import org.matsim.core.controler.events.BeforeMobsimEvent; @@ -41,7 +41,7 @@ /** * {@link org.matsim.core.controler.listener.ControlerListener} that dumps the * complete plans regularly at the start of an iteration - * ({@link ControlerConfigGroup#getWritePlansInterval()} as well as in the first + * ({@link ControllerConfigGroup#getWritePlansInterval()} as well as in the first * iteration, just in case someone might check that the replanning worked * correctly in the first iteration. * @@ -62,7 +62,7 @@ final class PlansDumpingImpl implements PlansDumping, BeforeMobsimListener { private int writeMoreUntilIteration; @Inject - PlansDumpingImpl(ControlerConfigGroup config) { + PlansDumpingImpl(ControllerConfigGroup config) { this.writePlansInterval = config.getWritePlansInterval(); this.writeMoreUntilIteration = config.getWritePlansUntilIteration() ; } diff --git a/matsim/src/main/java/org/matsim/core/events/MatsimEventsReader.java b/matsim/src/main/java/org/matsim/core/events/MatsimEventsReader.java index 24663d4ba92..25bbe72a79e 100644 --- a/matsim/src/main/java/org/matsim/core/events/MatsimEventsReader.java +++ b/matsim/src/main/java/org/matsim/core/events/MatsimEventsReader.java @@ -33,7 +33,7 @@ import org.matsim.api.core.v01.events.GenericEvent; import org.matsim.core.api.experimental.events.EventsManager; import org.matsim.core.api.internal.MatsimReader; -import org.matsim.core.config.groups.ControlerConfigGroup; +import org.matsim.core.config.groups.ControllerConfigGroup; import org.matsim.core.utils.io.MatsimXmlParser; import org.xml.sax.Attributes; import org.xml.sax.SAXException; @@ -94,7 +94,7 @@ public void readStream(final InputStream stream) { new XmlEventsReader(this.events, this.customEventMappers).parse(stream ); } - public void readStream(final InputStream stream, final ControlerConfigGroup.EventsFileFormat format) { + public void readStream(final InputStream stream, final ControllerConfigGroup.EventsFileFormat format) { switch (format) { case xml: new XmlEventsReader(this.events, this.customEventMappers).parse(stream); diff --git a/matsim/src/main/java/org/matsim/core/events/SimStepParallelEventsManagerImpl.java b/matsim/src/main/java/org/matsim/core/events/SimStepParallelEventsManagerImpl.java index c7a282c5a4d..726c62b96e8 100644 --- a/matsim/src/main/java/org/matsim/core/events/SimStepParallelEventsManagerImpl.java +++ b/matsim/src/main/java/org/matsim/core/events/SimStepParallelEventsManagerImpl.java @@ -36,7 +36,7 @@ import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.events.Event; import org.matsim.core.api.experimental.events.EventsManager; -import org.matsim.core.config.groups.ParallelEventHandlingConfigGroup; +import org.matsim.core.config.groups.EventsManagerConfigGroup; import org.matsim.core.events.handler.EventHandler; import org.matsim.core.gbl.Gbl; @@ -67,7 +67,7 @@ class SimStepParallelEventsManagerImpl implements EventsManager { private AtomicReference hadException = new AtomicReference<>(); @Inject - SimStepParallelEventsManagerImpl(ParallelEventHandlingConfigGroup config) { + SimStepParallelEventsManagerImpl(EventsManagerConfigGroup config) { this(config.getNumberOfThreads() != null ? config.getNumberOfThreads() : 1); } diff --git a/matsim/src/main/java/org/matsim/core/mobsim/DefaultMobsimModule.java b/matsim/src/main/java/org/matsim/core/mobsim/DefaultMobsimModule.java index 24649b3e059..95bf5b8f13f 100644 --- a/matsim/src/main/java/org/matsim/core/mobsim/DefaultMobsimModule.java +++ b/matsim/src/main/java/org/matsim/core/mobsim/DefaultMobsimModule.java @@ -22,7 +22,7 @@ package org.matsim.core.mobsim; -import org.matsim.core.config.groups.ControlerConfigGroup; +import org.matsim.core.config.groups.ControllerConfigGroup; import org.matsim.core.config.groups.ExternalMobimConfigGroup; import org.matsim.core.controler.AbstractModule; import org.matsim.core.events.MobsimScopeEventHandlingModule; @@ -34,13 +34,13 @@ public class DefaultMobsimModule extends AbstractModule { @Override public void install() { - if (getConfig().controler().getMobsim().equals(ControlerConfigGroup.MobsimType.qsim.toString())) { + if (getConfig().controler().getMobsim().equals(ControllerConfigGroup.MobsimType.qsim.toString())) { install(new QSimModule()); // bind( RelativePositionOfEntryExitOnLink.class ).toInstance( () -> 1. ); - } else if (getConfig().controler().getMobsim().equals(ControlerConfigGroup.MobsimType.JDEQSim.toString())) { + } else if (getConfig().controler().getMobsim().equals(ControllerConfigGroup.MobsimType.JDEQSim.toString())) { bindMobsim().to(JDEQSimulation.class); // bind( RelativePositionOfEntryExitOnLink.class ).toInstance( () -> 0. ); - } else if (getConfig().controler().getMobsim().equals(ControlerConfigGroup.MobsimType.hermes.toString())) { + } else if (getConfig().controler().getMobsim().equals(ControllerConfigGroup.MobsimType.hermes.toString())) { bindMobsim().toProvider(HermesProvider.class); } else if (getConfig().getModule(ExternalMobimConfigGroup.GROUP_NAME) != null && ((ExternalMobimConfigGroup)getConfig().getModule( diff --git a/matsim/src/main/java/org/matsim/core/mobsim/jdeqsim/JDEQSimConfigGroup.java b/matsim/src/main/java/org/matsim/core/mobsim/jdeqsim/JDEQSimConfigGroup.java index f2abdfbbfb2..a7766a68582 100644 --- a/matsim/src/main/java/org/matsim/core/mobsim/jdeqsim/JDEQSimConfigGroup.java +++ b/matsim/src/main/java/org/matsim/core/mobsim/jdeqsim/JDEQSimConfigGroup.java @@ -30,7 +30,7 @@ */ public class JDEQSimConfigGroup extends ReflectiveConfigGroup { - public final static String NAME = "JDEQSim"; + public final static String NAME = "jdeqsim"; // CONSTANTS public static final String START_LEG = "start leg"; diff --git a/matsim/src/main/java/org/matsim/core/mobsim/qsim/PreplanningEngine.java b/matsim/src/main/java/org/matsim/core/mobsim/qsim/PreplanningEngine.java index f6be7dc4ca9..cb85462403e 100644 --- a/matsim/src/main/java/org/matsim/core/mobsim/qsim/PreplanningEngine.java +++ b/matsim/src/main/java/org/matsim/core/mobsim/qsim/PreplanningEngine.java @@ -22,7 +22,7 @@ package org.matsim.core.mobsim.qsim; import static java.util.Comparator.comparing; -import static org.matsim.core.config.groups.PlanCalcScoreConfigGroup.createStageActivityType; +import static org.matsim.core.config.groups.ScoringConfigGroup.createStageActivityType; import java.util.ArrayList; import java.util.Collections; diff --git a/matsim/src/main/java/org/matsim/core/population/PopulationUtils.java b/matsim/src/main/java/org/matsim/core/population/PopulationUtils.java index cc26dd7608c..7f187b285a4 100644 --- a/matsim/src/main/java/org/matsim/core/population/PopulationUtils.java +++ b/matsim/src/main/java/org/matsim/core/population/PopulationUtils.java @@ -52,7 +52,7 @@ import org.matsim.api.core.v01.population.Route; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; import org.matsim.core.config.groups.PlansConfigGroup; import org.matsim.core.gbl.Gbl; import org.matsim.core.gbl.MatsimRandom; @@ -182,7 +182,7 @@ public String getRoutingMode() { public void setRoutingMode(String routingMode) { throw new UnsupportedOperationException() ; } - + @Override public Route getRoute() { // route should be unmodifiable. kai @@ -526,10 +526,10 @@ public static double calculateSimilarity(List legs1, List legs2, Netwo double sameModeReward, double sameRouteReward ) { // yyyy should be made configurable somehow (i.e. possibly not a static method any more). kai, apr'15 - // yy kwa points to: + // yy kwa points to: // Schüssler, N. and K.W. Axhausen (2009b) Accounting for similarities in destination choice modelling: A concept, paper presented at the 9th Swiss Transport Research Conference, Ascona, October 2009. - // und - // Joh, Chang-Hyeon, Theo A. Arentze and Harry J. P. Timmermans (2001). + // und + // Joh, Chang-Hyeon, Theo A. Arentze and Harry J. P. Timmermans (2001). // A Position-Sensitive Sequence Alignment Method Illustrated for Space-Time Activity-Diary Data¹, Environment and Planning A 33(2): 313­338. // Mahdieh Allahviranloo has some work on activity pattern similarity (iatbr'15) @@ -581,10 +581,10 @@ public static double calculateSimilarity(List activities1, List facilityId) { return getFactory().createInteractionActivityFromActivityFacilityId(type, facilityId); } - + public static Activity createActivityFromCoord(String type, Coord coord) { return getFactory().createActivityFromCoord(type, coord) ; } @@ -775,7 +775,7 @@ public static Activity createActivityFromCoord(String type, Coord coord) { public static Activity createInteractionActivityFromCoord(String type, Coord coord) { return getFactory().createInteractionActivityFromCoord(type, coord) ; } - + public static Activity createActivityFromCoordAndLinkId(String type, Coord coord, Id linkId) { Activity act = getFactory().createActivityFromCoord(type, coord) ; act.setLinkId(linkId); @@ -832,7 +832,7 @@ public static Activity createAndAddActivity(Plan plan, String type) { } public static Activity createStageActivityFromCoordLinkIdAndModePrefix(final Coord interactionCoord, final Id interactionLink, String modePrefix ) { - Activity act = createInteractionActivityFromCoordAndLinkId(PlanCalcScoreConfigGroup.createStageActivityType(modePrefix), interactionCoord, interactionLink); + Activity act = createInteractionActivityFromCoordAndLinkId(ScoringConfigGroup.createStageActivityType(modePrefix), interactionCoord, interactionLink); // act.setMaximumDuration(0.0); // obsolete since this is hard-coded in InteractionActivity return act; } @@ -849,7 +849,7 @@ public static void copyFromTo(final Plan in, final Plan out) { /* * By default 'false' to be backwards compatible. As a result, InteractionActivities will be converted to ActivityImpl. */ - copyFromTo(in, out, false); + copyFromTo(in, out, false); } public static void copyFromTo(final Plan in, final Plan out, final boolean withInteractionActivities) { diff --git a/matsim/src/main/java/org/matsim/core/replanning/StrategyManager.java b/matsim/src/main/java/org/matsim/core/replanning/StrategyManager.java index d00190b72e4..1b8b31473d8 100644 --- a/matsim/src/main/java/org/matsim/core/replanning/StrategyManager.java +++ b/matsim/src/main/java/org/matsim/core/replanning/StrategyManager.java @@ -26,8 +26,8 @@ import org.matsim.api.core.v01.population.Plan; import org.matsim.api.core.v01.population.Population; import org.matsim.core.api.internal.MatsimManager; -import org.matsim.core.config.groups.ControlerConfigGroup; -import org.matsim.core.config.groups.StrategyConfigGroup; +import org.matsim.core.config.groups.ControllerConfigGroup; +import org.matsim.core.config.groups.ReplanningConfigGroup; import org.matsim.core.replanning.choosers.StrategyChooser; import org.matsim.core.replanning.selectors.PlanSelector; import org.matsim.core.replanning.selectors.WorstPlanForRemovalSelector; @@ -65,20 +65,20 @@ public class StrategyManager implements MatsimManager { private final GenericStrategyManagerImpl delegate; @Inject - StrategyManager( StrategyConfigGroup strategyConfigGroup, - ControlerConfigGroup controlerConfigGroup, StrategyChooser strategyChooser, - Map planStrategies ) { + StrategyManager(ReplanningConfigGroup replanningConfigGroup, + ControllerConfigGroup controllerConfigGroup, StrategyChooser strategyChooser, + Map planStrategies ) { this(strategyChooser); - setMaxPlansPerAgent(strategyConfigGroup.getMaxAgentPlanMemorySize()); + setMaxPlansPerAgent(replanningConfigGroup.getMaxAgentPlanMemorySize()); - int globalInnovationDisableAfter = (int) ((controlerConfigGroup.getLastIteration() - controlerConfigGroup.getFirstIteration()) - * strategyConfigGroup.getFractionOfIterationsToDisableInnovation() + controlerConfigGroup.getFirstIteration()); + int globalInnovationDisableAfter = (int) ((controllerConfigGroup.getLastIteration() - controllerConfigGroup.getFirstIteration()) + * replanningConfigGroup.getFractionOfIterationsToDisableInnovation() + controllerConfigGroup.getFirstIteration()); log.info("global innovation switch off after iteration: " + globalInnovationDisableAfter); - for (Map.Entry entry : planStrategies.entrySet()) { + for (Map.Entry entry : planStrategies.entrySet()) { PlanStrategy strategy = entry.getValue(); - StrategyConfigGroup.StrategySettings settings = entry.getKey(); + ReplanningConfigGroup.StrategySettings settings = entry.getKey(); addStrategy(strategy, settings.getSubpopulation(), settings.getWeight()); // now check if this modules should be disabled after some iterations @@ -90,7 +90,7 @@ public class StrategyManager implements MatsimManager { } if (maxIter >= 0) { - if (maxIter >= controlerConfigGroup.getFirstIteration()) { + if (maxIter >= controllerConfigGroup.getFirstIteration()) { addChangeRequest(maxIter + 1, strategy, settings.getSubpopulation(), 0.0); } else { /* The services starts at a later iteration than this change request is scheduled for. diff --git a/matsim/src/main/java/org/matsim/core/replanning/StrategyManagerModule.java b/matsim/src/main/java/org/matsim/core/replanning/StrategyManagerModule.java index 6ce4eba984b..591329a5bcf 100644 --- a/matsim/src/main/java/org/matsim/core/replanning/StrategyManagerModule.java +++ b/matsim/src/main/java/org/matsim/core/replanning/StrategyManagerModule.java @@ -30,7 +30,7 @@ import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.population.Person; import org.matsim.api.core.v01.population.Plan; -import org.matsim.core.config.groups.StrategyConfigGroup; +import org.matsim.core.config.groups.ReplanningConfigGroup; import org.matsim.core.controler.AbstractModule; import org.matsim.core.controler.OutputDirectoryHierarchy; import org.matsim.core.replanning.choosers.StrategyChooser; @@ -55,11 +55,11 @@ public void install() { bind(new TypeLiteral>() {}).to(new TypeLiteral>() {}).asEagerSingleton(); bind(ReplanningContext.class).to(ReplanningContextImpl.class).asEagerSingleton(); - MapBinder planStrategyMapBinder = MapBinder.newMapBinder(binder(), StrategyConfigGroup.StrategySettings.class, PlanStrategy.class); + MapBinder planStrategyMapBinder = MapBinder.newMapBinder(binder(), ReplanningConfigGroup.StrategySettings.class, PlanStrategy.class); // (this will bind a Map that has StrategySettings as key, and PlanStrategy as value. Not sure why StrategySettings as key, and not just the name, but possibly this is mean to allow adding // the same strategy multiple times, with possibly different settings.) - for (StrategyConfigGroup.StrategySettings settings : getConfig().strategy().getStrategySettings()) { + for (ReplanningConfigGroup.StrategySettings settings : getConfig().strategy().getStrategySettings()) { String name = settings.getStrategyName() ; if (name.equals("ExternalModule")) { // plan strategy is some external executable: diff --git a/matsim/src/main/java/org/matsim/core/replanning/annealing/ReplanningAnnealer.java b/matsim/src/main/java/org/matsim/core/replanning/annealing/ReplanningAnnealer.java index 19ec1cc810e..5752b8d7dfc 100644 --- a/matsim/src/main/java/org/matsim/core/replanning/annealing/ReplanningAnnealer.java +++ b/matsim/src/main/java/org/matsim/core/replanning/annealing/ReplanningAnnealer.java @@ -30,7 +30,7 @@ import org.matsim.api.core.v01.population.Plan; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.StrategyConfigGroup; +import org.matsim.core.config.groups.ReplanningConfigGroup; import org.matsim.core.controler.OutputDirectoryHierarchy; import org.matsim.core.controler.events.IterationStartsEvent; import org.matsim.core.controler.events.StartupEvent; @@ -93,7 +93,7 @@ public void notifyStartup(StartupEvent event) { if (av.getAnnealParameter().equals(AnnealParameterOption.globalInnovationRate)) { header.addAll(this.config.strategy().getStrategySettings().stream() .filter(s -> Objects.equals(av.getDefaultSubpopulation(), s.getSubpopulation())) - .map(StrategyConfigGroup.StrategySettings::getStrategyName) + .map(ReplanningConfigGroup.StrategySettings::getStrategyName) .collect(Collectors.toList())); } } else { // if disabled, better remove it @@ -195,7 +195,7 @@ private void anneal(IterationStartsEvent event, AnnealingVariable av, double ann List annealValues = annealReplanning(annealValue, event.getServices().getStrategyManager(), av.getDefaultSubpopulation()); int i = 0; - for (StrategyConfigGroup.StrategySettings ss : this.config.strategy().getStrategySettings()) { + for (ReplanningConfigGroup.StrategySettings ss : this.config.strategy().getStrategySettings()) { if (Objects.equals(ss.getSubpopulation(), av.getDefaultSubpopulation())) { annealStats.put(ss.getStrategyName(), String.format(Locale.US, "%.4f", annealValues.get(i))); i++; @@ -262,9 +262,9 @@ private double getStrategyWeights(Config config, String subpopulation, StratType if (this.currentIter == this.innovationStop + 1 && stratType.equals(StratType.allInnovation)) { return 0.0; } - Collection strategies = config.strategy().getStrategySettings(); + Collection strategies = config.strategy().getStrategySettings(); double totalWeights = 0.0; - for (StrategyConfigGroup.StrategySettings strategy : strategies) { + for (ReplanningConfigGroup.StrategySettings strategy : strategies) { if (Objects.equals(strategy.getSubpopulation(), subpopulation)) { switch (stratType) { case allSelectors: @@ -294,7 +294,7 @@ private int getInnovationStop(Config config) { int innoStop = -1; - for (StrategyConfigGroup.StrategySettings strategy : config.strategy().getStrategySettings()) { + for (ReplanningConfigGroup.StrategySettings strategy : config.strategy().getStrategySettings()) { // check if this modules should be disabled after some iterations int maxIter = strategy.getDisableAfter(); if ((maxIter > globalInnovationDisableAfter || maxIter == -1) && isInnovationStrategy(strategy.getStrategyName())) { @@ -362,8 +362,8 @@ private void rescaleStartupWeights(double innovationStartValue, Config config, S stratMan.changeWeightOfStrategy(strategy, subpopulation, weight); } // adapt also in config for the record - Collection strategiesConfig = config.strategy().getStrategySettings(); - for (StrategyConfigGroup.StrategySettings strategy : strategiesConfig) { + Collection strategiesConfig = config.strategy().getStrategySettings(); + for (ReplanningConfigGroup.StrategySettings strategy : strategiesConfig) { if (Objects.equals(strategy.getSubpopulation(), subpopulation)) { double weight = strategy.getWeight(); if (isInnovationStrategy(strategy.toString())) { diff --git a/matsim/src/main/java/org/matsim/core/replanning/annealing/ReplanningAnnealerConfigGroup.java b/matsim/src/main/java/org/matsim/core/replanning/annealing/ReplanningAnnealerConfigGroup.java index bf63bb63384..c3a9421862f 100644 --- a/matsim/src/main/java/org/matsim/core/replanning/annealing/ReplanningAnnealerConfigGroup.java +++ b/matsim/src/main/java/org/matsim/core/replanning/annealing/ReplanningAnnealerConfigGroup.java @@ -30,7 +30,7 @@ public class ReplanningAnnealerConfigGroup extends ReflectiveConfigGroup { - public static final String GROUP_NAME = "ReplanningAnnealer"; + public static final String GROUP_NAME = "replanningAnnealer"; private static final String ACTIVATE_ANNEALING_MODULE = "activateAnnealingModule"; private boolean activateAnnealingModule = false; @@ -227,4 +227,4 @@ public Map getComments() { } } -} \ No newline at end of file +} diff --git a/matsim/src/main/java/org/matsim/core/replanning/selectors/ExpBetaPlanSelector.java b/matsim/src/main/java/org/matsim/core/replanning/selectors/ExpBetaPlanSelector.java index b7c2f399c99..6bc778ab513 100644 --- a/matsim/src/main/java/org/matsim/core/replanning/selectors/ExpBetaPlanSelector.java +++ b/matsim/src/main/java/org/matsim/core/replanning/selectors/ExpBetaPlanSelector.java @@ -24,10 +24,9 @@ import java.util.Map; import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.population.BasicPlan; import org.matsim.api.core.v01.population.HasPlansAndId; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; import org.matsim.core.gbl.MatsimRandom; /** @@ -40,12 +39,12 @@ public class ExpBetaPlanSelector implements PlanSelector protected static final double MIN_WEIGHT = Double.MIN_VALUE; protected final double beta; - + public ExpBetaPlanSelector( final double logitScaleFactor ) { this.beta = logitScaleFactor ; } - public ExpBetaPlanSelector(PlanCalcScoreConfigGroup charyparNagelScoringConfigGroup) { + public ExpBetaPlanSelector(ScoringConfigGroup charyparNagelScoringConfigGroup) { this( charyparNagelScoringConfigGroup.getBrainExpBeta() ) ; } diff --git a/matsim/src/main/java/org/matsim/core/replanning/selectors/PathSizeLogitSelector.java b/matsim/src/main/java/org/matsim/core/replanning/selectors/PathSizeLogitSelector.java index 8791819e3b3..d63d8109d93 100644 --- a/matsim/src/main/java/org/matsim/core/replanning/selectors/PathSizeLogitSelector.java +++ b/matsim/src/main/java/org/matsim/core/replanning/selectors/PathSizeLogitSelector.java @@ -31,7 +31,7 @@ import org.matsim.api.core.v01.population.Leg; import org.matsim.api.core.v01.population.Plan; import org.matsim.api.core.v01.population.PlanElement; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; import org.matsim.core.population.routes.NetworkRoute; import org.matsim.core.population.routes.RouteUtils; @@ -54,7 +54,7 @@ public PathSizeLogitSelector( final double pathSizeLogitExponent, final double l this.network = network ; } - public PathSizeLogitSelector(final PlanCalcScoreConfigGroup config, final Network network) { + public PathSizeLogitSelector(final ScoringConfigGroup config, final Network network) { this( config.getPathSizeLogitBeta(), config.getBrainExpBeta(), network ) ; } @@ -62,19 +62,19 @@ public PathSizeLogitSelector(final PlanCalcScoreConfigGroup config, final Networ @Override protected Map calcWeights(final List plans ) { // ("plans" is the list of plans of a single person) - + Map weights = new HashMap() ; double maxScore = Double.NEGATIVE_INFINITY; HashMap, ArrayList> linksInTime = new HashMap<>(); // (a data structure that memorizes possible leg start times for link utilization (??)) - + HashMap planLength = new HashMap(); // (a data structure that memorizes the total travel distance of each plan) // (yyyy is it obvious that no two plans can have the same hash code? what happens if they do? kai, oct'12) // (why not just ?????) - + //this gets the choice sets C_n //TODO [GL] since the lack of information in Route(), //the very first and the very last link of a path will be ignored - gl @@ -96,7 +96,7 @@ protected Map calcWeights(final List plans ) { pathSize += RouteUtils.calcDistanceExcludingStartEndLink(r, network); // (i.e. pathSize will be the sum over all routes of the plan) - + for (Id linkId : r.getLinkIds()){ ArrayList lit = linksInTime.get(linkId); if (lit == null){ @@ -140,17 +140,17 @@ protected Map calcWeights(final List plans ) { // tmp is now a number that contains the ``reduced'' travel distance of the plan. Divide it by the full travel distance // of the plan, and take to the power of this.beta: double PSi = Math.pow(tmp/planLength.get(plan.hashCode()), this.pathSizeLogitExponent); - + double weight; if (Double.isInfinite(maxScore)) { - // (isInfinite(x) also returns true when x==-Infinity) - + // (isInfinite(x) also returns true when x==-Infinity) + // likely that wc.maxScore == -Infinity, and thus plan.getScoreAsPrimitiveType() also == -Infinity, handle it like any other case where getScore() == maxScore // I do not understand the line above. kai, oct'12 - + weight = PSi; - // (yy I do not understand. Presumably, wc.maxScore may be -Infinity, in which case ALL plan scores are -Infinity - // (or NaN or null or something similar). In this case, plans are simply weighted by their PSi, so that + // (yy I do not understand. Presumably, wc.maxScore may be -Infinity, in which case ALL plan scores are -Infinity + // (or NaN or null or something similar). In this case, plans are simply weighted by their PSi, so that // overlapping plans get less weight than very different plans. kai, oct'12) } else { weight = Math.exp(this.logitScaleFactor * (plan.getScore() - maxScore))*PSi; @@ -159,12 +159,12 @@ protected Map calcWeights(final List plans ) { } if (weight <= 0.0) weight = 0; - // (yy how can weight become negative?? kai, oct'12) + // (yy how can weight become negative?? kai, oct'12) // the weight is memorized; the sum of all weights in computed. Choice will be based on those weights weights.put( plan, weight) ; } - + return weights ; } diff --git a/matsim/src/main/java/org/matsim/core/replanning/strategies/ChangeExpBeta.java b/matsim/src/main/java/org/matsim/core/replanning/strategies/ChangeExpBeta.java index 83815dba12c..ebf5881b6c3 100644 --- a/matsim/src/main/java/org/matsim/core/replanning/strategies/ChangeExpBeta.java +++ b/matsim/src/main/java/org/matsim/core/replanning/strategies/ChangeExpBeta.java @@ -19,7 +19,7 @@ package org.matsim.core.replanning.strategies; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; import org.matsim.core.replanning.PlanStrategy; import org.matsim.core.replanning.PlanStrategyImpl; import org.matsim.core.replanning.selectors.ExpBetaPlanChanger; @@ -29,7 +29,7 @@ public class ChangeExpBeta implements Provider { - @Inject private PlanCalcScoreConfigGroup config; + @Inject private ScoringConfigGroup config; @Override public PlanStrategy get() { diff --git a/matsim/src/main/java/org/matsim/core/replanning/strategies/DefaultPlanStrategiesModule.java b/matsim/src/main/java/org/matsim/core/replanning/strategies/DefaultPlanStrategiesModule.java index 02afce69dcb..d66df199ebc 100644 --- a/matsim/src/main/java/org/matsim/core/replanning/strategies/DefaultPlanStrategiesModule.java +++ b/matsim/src/main/java/org/matsim/core/replanning/strategies/DefaultPlanStrategiesModule.java @@ -32,8 +32,8 @@ import org.matsim.api.core.v01.network.Network; import org.matsim.api.core.v01.population.Person; import org.matsim.api.core.v01.population.Plan; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; -import org.matsim.core.config.groups.StrategyConfigGroup; +import org.matsim.core.config.groups.ReplanningConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; import org.matsim.core.controler.AbstractModule; import org.matsim.core.population.algorithms.PermissibleModesCalculator; import org.matsim.core.population.algorithms.PermissibleModesCalculatorImpl; @@ -73,7 +73,7 @@ public void install() { // that's fine: The StrategyManager will still only add those strategies to itself which are configured. // But we don't want to clutter the container here. Set usedStrategyNames = new HashSet<>(); - for (StrategyConfigGroup.StrategySettings settings : getConfig().strategy().getStrategySettings()) { + for (ReplanningConfigGroup.StrategySettings settings : getConfig().strategy().getStrategySettings()) { usedStrategyNames.add(settings.getStrategyName()); } @@ -160,7 +160,7 @@ public interface DefaultStrategy { private static class ExpBetaPlanSelectorForRemoval implements Provider> { - @Inject private PlanCalcScoreConfigGroup config; + @Inject private ScoringConfigGroup config; @Override public ExpBetaPlanSelector get() { @@ -170,7 +170,7 @@ public ExpBetaPlanSelector get() { private static class ExpBetaPlanChangerForRemoval implements Provider> { - @Inject private PlanCalcScoreConfigGroup config; + @Inject private ScoringConfigGroup config; @Override public ExpBetaPlanChanger get() { @@ -180,7 +180,8 @@ public ExpBetaPlanChanger get() { private static class PathSizeLogitSelectorForRemoval implements Provider { - @Inject PlanCalcScoreConfigGroup config; + @Inject + ScoringConfigGroup config; @Inject Network network; @Override diff --git a/matsim/src/main/java/org/matsim/core/replanning/strategies/SelectExpBeta.java b/matsim/src/main/java/org/matsim/core/replanning/strategies/SelectExpBeta.java index 1ad7755a512..95c19afd6c3 100644 --- a/matsim/src/main/java/org/matsim/core/replanning/strategies/SelectExpBeta.java +++ b/matsim/src/main/java/org/matsim/core/replanning/strategies/SelectExpBeta.java @@ -19,7 +19,7 @@ package org.matsim.core.replanning.strategies; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; import org.matsim.core.replanning.PlanStrategy; import org.matsim.core.replanning.PlanStrategyImpl; import org.matsim.core.replanning.selectors.ExpBetaPlanSelector; @@ -29,7 +29,7 @@ public class SelectExpBeta implements Provider { - @Inject private PlanCalcScoreConfigGroup config; + @Inject private ScoringConfigGroup config; @Override public PlanStrategy get() { diff --git a/matsim/src/main/java/org/matsim/core/replanning/strategies/SelectPathSizeLogit.java b/matsim/src/main/java/org/matsim/core/replanning/strategies/SelectPathSizeLogit.java index f5fd511744d..037c3a79aca 100644 --- a/matsim/src/main/java/org/matsim/core/replanning/strategies/SelectPathSizeLogit.java +++ b/matsim/src/main/java/org/matsim/core/replanning/strategies/SelectPathSizeLogit.java @@ -20,7 +20,7 @@ package org.matsim.core.replanning.strategies; import org.matsim.api.core.v01.network.Network; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; import org.matsim.core.replanning.PlanStrategy; import org.matsim.core.replanning.PlanStrategyImpl; import org.matsim.core.replanning.selectors.PathSizeLogitSelector; @@ -30,7 +30,7 @@ public class SelectPathSizeLogit implements Provider { - @Inject private PlanCalcScoreConfigGroup config; + @Inject private ScoringConfigGroup config; @Inject private Network network; @Override diff --git a/matsim/src/main/java/org/matsim/core/router/BeelineTeleportationRouting.java b/matsim/src/main/java/org/matsim/core/router/BeelineTeleportationRouting.java index 8988b95c413..721f77c986d 100644 --- a/matsim/src/main/java/org/matsim/core/router/BeelineTeleportationRouting.java +++ b/matsim/src/main/java/org/matsim/core/router/BeelineTeleportationRouting.java @@ -22,16 +22,16 @@ package org.matsim.core.router; import org.matsim.api.core.v01.Scenario; -import org.matsim.core.config.groups.PlansCalcRouteConfigGroup; +import org.matsim.core.config.groups.RoutingConfigGroup; import jakarta.inject.Inject; import jakarta.inject.Provider; class BeelineTeleportationRouting implements Provider { - private final PlansCalcRouteConfigGroup.TeleportedModeParams params; + private final RoutingConfigGroup.TeleportedModeParams params; - public BeelineTeleportationRouting( PlansCalcRouteConfigGroup.TeleportedModeParams params ) { + public BeelineTeleportationRouting( RoutingConfigGroup.TeleportedModeParams params ) { this.params = params; } diff --git a/matsim/src/main/java/org/matsim/core/router/DefaultRoutingModules.java b/matsim/src/main/java/org/matsim/core/router/DefaultRoutingModules.java index 45410a0ce48..8e26e960a76 100644 --- a/matsim/src/main/java/org/matsim/core/router/DefaultRoutingModules.java +++ b/matsim/src/main/java/org/matsim/core/router/DefaultRoutingModules.java @@ -21,8 +21,8 @@ import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.network.Network; import org.matsim.api.core.v01.population.PopulationFactory; -import org.matsim.core.config.groups.PlansCalcRouteConfigGroup; -import org.matsim.core.config.groups.PlansCalcRouteConfigGroup.TeleportedModeParams; +import org.matsim.core.config.groups.RoutingConfigGroup; +import org.matsim.core.config.groups.RoutingConfigGroup.TeleportedModeParams; import org.matsim.core.router.util.LeastCostPathCalculator; import org.matsim.core.utils.timing.TimeInterpretation; @@ -40,7 +40,7 @@ public final class DefaultRoutingModules { private DefaultRoutingModules(){} // do not instantiate public static RoutingModule createPseudoTransitRouter( String mode, PopulationFactory popFac, Network net, LeastCostPathCalculator routeAlgo, - PlansCalcRouteConfigGroup.TeleportedModeParams params ) { + RoutingConfigGroup.TeleportedModeParams params ) { return new FreespeedFactorRoutingModule( mode, popFac, diff --git a/matsim/src/main/java/org/matsim/core/router/FallbackRoutingModuleDefaultImpl.java b/matsim/src/main/java/org/matsim/core/router/FallbackRoutingModuleDefaultImpl.java index 52db4dea30f..42de02022cd 100644 --- a/matsim/src/main/java/org/matsim/core/router/FallbackRoutingModuleDefaultImpl.java +++ b/matsim/src/main/java/org/matsim/core/router/FallbackRoutingModuleDefaultImpl.java @@ -11,8 +11,7 @@ import org.matsim.api.core.v01.population.PlanElement; import org.matsim.api.core.v01.population.Population; import org.matsim.core.config.Config; -import org.matsim.core.config.groups.GlobalConfigGroup; -import org.matsim.core.config.groups.PlansCalcRouteConfigGroup; +import org.matsim.core.config.groups.RoutingConfigGroup; import org.matsim.facilities.FacilitiesUtils; import org.matsim.facilities.Facility; @@ -24,7 +23,7 @@ class FallbackRoutingModuleDefaultImpl implements FallbackRoutingModule { @Deprecated // #deleteBeforeRelease : only used to retrofit plans created since the merge of fallback routing module (sep'-dec'19) public static final String _fallback = "_fallback"; - @Inject private PlansCalcRouteConfigGroup pcrCfg; + @Inject private RoutingConfigGroup pcrCfg; @Inject private Config config ; @Inject private Population population ; @Inject private Network network ; @@ -34,7 +33,7 @@ class FallbackRoutingModuleDefaultImpl implements FallbackRoutingModule { final Facility toFacility = request.getToFacility(); final double departureTime = request.getDepartureTime(); final Person person = request.getPerson(); - + Leg leg = population.getFactory().createLeg( TransportMode.walk ) ; Coord fromCoord = FacilitiesUtils.decideOnCoord( fromFacility, network, config ); Coord toCoord = FacilitiesUtils.decideOnCoord( toFacility, network, config ) ; @@ -45,7 +44,7 @@ class FallbackRoutingModuleDefaultImpl implements FallbackRoutingModule { * would be better if we would try the walkRouter first and fall back to "UltimateFallbackRoutingModule" or a * handwritten teleported walk like below only if the walkRouter returns null. - gl/kn-dec'19 */ - NetworkRoutingInclAccessEgressModule.routeBushwhackingLeg( person, leg, fromCoord, toCoord, departureTime, dpLinkId, arLinkId, population.getFactory(), + NetworkRoutingInclAccessEgressModule.routeBushwhackingLeg( person, leg, fromCoord, toCoord, departureTime, dpLinkId, arLinkId, population.getFactory(), pcrCfg.getModeRoutingParams().get(TransportMode.walk) ) ; return Collections.singletonList( leg ) ; } diff --git a/matsim/src/main/java/org/matsim/core/router/FreespeedFactorRouting.java b/matsim/src/main/java/org/matsim/core/router/FreespeedFactorRouting.java index b6a77a716cb..9962ca9b674 100644 --- a/matsim/src/main/java/org/matsim/core/router/FreespeedFactorRouting.java +++ b/matsim/src/main/java/org/matsim/core/router/FreespeedFactorRouting.java @@ -28,7 +28,7 @@ import org.matsim.api.core.v01.network.Network; import org.matsim.api.core.v01.population.Person; import org.matsim.api.core.v01.population.PopulationFactory; -import org.matsim.core.config.groups.PlansCalcRouteConfigGroup; +import org.matsim.core.config.groups.RoutingConfigGroup; import org.matsim.core.gbl.Gbl; import org.matsim.core.router.util.LeastCostPathCalculator; import org.matsim.core.router.util.LeastCostPathCalculatorFactory; @@ -38,9 +38,9 @@ class FreespeedFactorRouting implements Provider { - private final PlansCalcRouteConfigGroup.TeleportedModeParams params; + private final RoutingConfigGroup.TeleportedModeParams params; - public FreespeedFactorRouting( PlansCalcRouteConfigGroup.TeleportedModeParams params ) { + public FreespeedFactorRouting( RoutingConfigGroup.TeleportedModeParams params ) { this.params = params; } diff --git a/matsim/src/main/java/org/matsim/core/router/FreespeedFactorRoutingModule.java b/matsim/src/main/java/org/matsim/core/router/FreespeedFactorRoutingModule.java index 1a58eb5758d..ddafdcf37e3 100644 --- a/matsim/src/main/java/org/matsim/core/router/FreespeedFactorRoutingModule.java +++ b/matsim/src/main/java/org/matsim/core/router/FreespeedFactorRoutingModule.java @@ -24,7 +24,7 @@ import org.matsim.api.core.v01.network.Network; import org.matsim.api.core.v01.network.Node; import org.matsim.api.core.v01.population.*; -import org.matsim.core.config.groups.PlansCalcRouteConfigGroup.TeleportedModeParams; +import org.matsim.core.config.groups.RoutingConfigGroup.TeleportedModeParams; import org.matsim.core.router.util.LeastCostPathCalculator; import org.matsim.core.router.util.LeastCostPathCalculator.Path; import org.matsim.core.utils.geometry.CoordUtils; @@ -61,7 +61,7 @@ public List calcRoute(RoutingRequest request) { final Facility toFacility = request.getToFacility(); final double departureTime = request.getDepartureTime(); final Person person = request.getPerson(); - + Leg newLeg = this.populationFactory.createLeg( this.mode ); newLeg.setDepartureTime( departureTime ); @@ -99,19 +99,19 @@ public String toString() { // we're still missing the time on the final link, which the agent has to drive on in the java mobsim // so let's calculate the final part. double speed = toLink.getFreespeed(depTime + path.travelTime); - + // correct by speed limit: if ( speed > params.getTeleportedModeFreespeedLimit() ) { speed = params.getTeleportedModeFreespeedLimit() ; } - + // now correct the travel time: double travelTimeLastLink = toLink.getLength() / speed; - + travTime = (int) (((int) path.travelTime + travelTimeLastLink) * this.params.getTeleportedModeFreespeedFactor()); Route route = this.populationFactory.getRouteFactories().createRoute(Route.class, fromLink.getId(), toLink.getId()); route.setTravelTime(travTime); - + // yyyyyy the following should actually rather come from the route! There is a RouteUtils.calcDistance( route ) . kai, nov'16 double dist = 0; if ((fromAct.getCoord() != null) && (toAct.getCoord() != null)) { diff --git a/matsim/src/main/java/org/matsim/core/router/LeastCostPathCalculatorModule.java b/matsim/src/main/java/org/matsim/core/router/LeastCostPathCalculatorModule.java index e11652b3155..d0e8b99a210 100644 --- a/matsim/src/main/java/org/matsim/core/router/LeastCostPathCalculatorModule.java +++ b/matsim/src/main/java/org/matsim/core/router/LeastCostPathCalculatorModule.java @@ -23,7 +23,7 @@ package org.matsim.core.router; import org.matsim.core.config.Config; -import org.matsim.core.config.groups.ControlerConfigGroup; +import org.matsim.core.config.groups.ControllerConfigGroup; import org.matsim.core.controler.AbstractModule; import org.matsim.core.router.speedy.SpeedyALTFactory; import org.matsim.core.router.util.*; @@ -37,11 +37,11 @@ public void install() { // kai/mm, jan'17 Config config = getConfig(); - if (config.controler().getRoutingAlgorithmType().equals(ControlerConfigGroup.RoutingAlgorithmType.Dijkstra)) { + if (config.controler().getRoutingAlgorithmType().equals(ControllerConfigGroup.RoutingAlgorithmType.Dijkstra)) { bind(LeastCostPathCalculatorFactory.class).to(DijkstraFactory.class); - } else if (config.controler().getRoutingAlgorithmType().equals(ControlerConfigGroup.RoutingAlgorithmType.AStarLandmarks)) { + } else if (config.controler().getRoutingAlgorithmType().equals(ControllerConfigGroup.RoutingAlgorithmType.AStarLandmarks)) { bind(LeastCostPathCalculatorFactory.class).to(AStarLandmarksFactory.class); - } else if (config.controler().getRoutingAlgorithmType().equals(ControlerConfigGroup.RoutingAlgorithmType.SpeedyALT)) { + } else if (config.controler().getRoutingAlgorithmType().equals(ControllerConfigGroup.RoutingAlgorithmType.SpeedyALT)) { bind(LeastCostPathCalculatorFactory.class).to(SpeedyALTFactory.class); } } diff --git a/matsim/src/main/java/org/matsim/core/router/LinkToLinkRouting.java b/matsim/src/main/java/org/matsim/core/router/LinkToLinkRouting.java index b4e136e352f..2d83a752dcb 100644 --- a/matsim/src/main/java/org/matsim/core/router/LinkToLinkRouting.java +++ b/matsim/src/main/java/org/matsim/core/router/LinkToLinkRouting.java @@ -30,7 +30,7 @@ import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Network; import org.matsim.api.core.v01.population.PopulationFactory; -import org.matsim.core.config.groups.PlansCalcRouteConfigGroup; +import org.matsim.core.config.groups.RoutingConfigGroup; import org.matsim.core.network.NetworkUtils; import org.matsim.core.network.algorithms.NetworkInverter; import org.matsim.core.network.algorithms.NetworkTurnInfoBuilderI; @@ -50,7 +50,7 @@ public class LinkToLinkRouting SingleModeNetworksCache singleModeNetworksCache; @Inject - PlansCalcRouteConfigGroup plansCalcRouteConfigGroup; + RoutingConfigGroup routingConfigGroup; @Inject LeastCostPathCalculatorFactory leastCostPathCalcFactory; @@ -120,7 +120,7 @@ public RoutingModule get() { ); // see NetworkRoutingProvider for some notes - if (!plansCalcRouteConfigGroup.getAccessEgressType().equals(PlansCalcRouteConfigGroup.AccessEgressType.none)) { + if (!routingConfigGroup.getAccessEgressType().equals(RoutingConfigGroup.AccessEgressType.none)) { if (mode.equals(TransportMode.walk)) { return DefaultRoutingModules.createAccessEgressNetworkRouter(mode, leastCostPathCalculator, scenario, filteredNetwork, invertedNetwork, null,null, timeInterpretation, multimodalLinkChooser); diff --git a/matsim/src/main/java/org/matsim/core/router/NetworkRoutingInclAccessEgressModule.java b/matsim/src/main/java/org/matsim/core/router/NetworkRoutingInclAccessEgressModule.java index f75bfd22a20..ed34a5be20d 100644 --- a/matsim/src/main/java/org/matsim/core/router/NetworkRoutingInclAccessEgressModule.java +++ b/matsim/src/main/java/org/matsim/core/router/NetworkRoutingInclAccessEgressModule.java @@ -19,7 +19,7 @@ package org.matsim.core.router; -import static org.matsim.core.config.groups.PlansCalcRouteConfigGroup.TeleportedModeParams; +import static org.matsim.core.config.groups.RoutingConfigGroup.TeleportedModeParams; import java.util.ArrayList; import java.util.Collections; @@ -42,8 +42,8 @@ import org.matsim.api.core.v01.population.PopulationFactory; import org.matsim.api.core.v01.population.Route; import org.matsim.core.config.Config; -import org.matsim.core.config.groups.PlansCalcRouteConfigGroup; -import org.matsim.core.config.groups.PlansCalcRouteConfigGroup.AccessEgressType; +import org.matsim.core.config.groups.RoutingConfigGroup; +import org.matsim.core.config.groups.RoutingConfigGroup.AccessEgressType; import org.matsim.core.gbl.Gbl; import org.matsim.core.network.NetworkUtils; import org.matsim.core.population.PopulationUtils; @@ -82,7 +82,7 @@ public final class NetworkRoutingInclAccessEgressModule implements RoutingModule private final Config config; private static boolean hasWarnedAccessEgress = false; - private PlansCalcRouteConfigGroup.AccessEgressType accessEgressType; + private RoutingConfigGroup.AccessEgressType accessEgressType; private final TimeInterpretation timeInterpretation; private final MultimodalLinkChooser multimodalLinkChooser; @@ -228,7 +228,7 @@ private List computeEgressTripFromLinkToFacilityIfNecessary(final F Facility fromFacility = FacilitiesUtils.wrapLinkAndCoord(egressActLink,startCoord); List networkRoutedEgressTrip = egressFromNetworkRouter.calcRoute(DefaultRoutingRequest.of(fromFacility, toFacility, departureTime, person, routingAttributes)); if(networkRoutedEgressTrip == null) return null; - if (this.accessEgressType.equals(PlansCalcRouteConfigGroup.AccessEgressType.accessEgressModeToLinkPlusTimeConstant)){ + if (this.accessEgressType.equals(RoutingConfigGroup.AccessEgressType.accessEgressModeToLinkPlusTimeConstant)){ double egressTime = NetworkUtils.getLinkEgressTime(egressActLink,mode).orElseThrow(()->new RuntimeException("Egress Time not set for link "+ egressActLink.getId().toString())); Leg leg0 = TripStructureUtils.getLegs(networkRoutedEgressTrip).get(0); double travelTime = leg0.getTravelTime().seconds()+egressTime; @@ -277,7 +277,7 @@ private List computeAccessTripFromFacilityToLinkIfNecessa // yyyy might be possible to set the link ids to null. kai & dominik, may'16 accessTrip.add(accessLeg); - } else if (accessEgressType.equals(PlansCalcRouteConfigGroup.AccessEgressType.walkConstantTimeToLink)) { + } else if (accessEgressType.equals(RoutingConfigGroup.AccessEgressType.walkConstantTimeToLink)) { Leg accessLeg = populationFactory.createLeg(TransportMode.walk); accessLeg.setDepartureTime(departureTime); Id startLinkId = fromFacility.getLinkId(); @@ -296,7 +296,7 @@ private List computeAccessTripFromFacilityToLinkIfNecessa Facility toFacility = FacilitiesUtils.wrapLinkAndCoord(accessActLink,endCoord); List networkRoutedAccessTrip = accessToNetworkRouter.calcRoute(DefaultRoutingRequest.of(fromFacility, toFacility, departureTime, person, routingAttributes)); if (networkRoutedAccessTrip == null) return null; //no access trip could be computed for accessMode - if (this.accessEgressType.equals(PlansCalcRouteConfigGroup.AccessEgressType.accessEgressModeToLinkPlusTimeConstant)){ + if (this.accessEgressType.equals(RoutingConfigGroup.AccessEgressType.accessEgressModeToLinkPlusTimeConstant)){ double accessTime = NetworkUtils.getLinkAccessTime(accessActLink,mode).orElseThrow(()->new RuntimeException("Access Time not set for link "+ accessActLink.getId().toString())); Leg leg0 = TripStructureUtils.getLegs(networkRoutedAccessTrip).get(0); double travelTime = leg0.getTravelTime().seconds()+accessTime; @@ -321,9 +321,9 @@ private static Activity createInteractionActivity(final Coord interactionCoord, private static void routeBushwhackingLeg(Person person, Leg leg, Coord fromCoord, Coord toCoord, double depTime, Id dpLinkId, Id arLinkId, PopulationFactory pf, Config config) { - final PlansCalcRouteConfigGroup.TeleportedModeParams params; - PlansCalcRouteConfigGroup.TeleportedModeParams tmp; - final Map paramsMap = config.plansCalcRoute().getModeRoutingParams(); + final RoutingConfigGroup.TeleportedModeParams params; + RoutingConfigGroup.TeleportedModeParams tmp; + final Map paramsMap = config.plansCalcRoute().getModeRoutingParams(); if ((tmp = paramsMap.get(TransportMode.non_network_walk)) != null) { params = tmp; } else if ((tmp = paramsMap.get(TransportMode.walk)) != null) { diff --git a/matsim/src/main/java/org/matsim/core/router/NetworkRoutingProvider.java b/matsim/src/main/java/org/matsim/core/router/NetworkRoutingProvider.java index 83eaf596b3f..b40087b6891 100644 --- a/matsim/src/main/java/org/matsim/core/router/NetworkRoutingProvider.java +++ b/matsim/src/main/java/org/matsim/core/router/NetworkRoutingProvider.java @@ -30,7 +30,7 @@ import org.matsim.api.core.v01.network.Network; import org.matsim.api.core.v01.population.PopulationFactory; import org.matsim.core.config.groups.NetworkConfigGroup; -import org.matsim.core.config.groups.PlansCalcRouteConfigGroup; +import org.matsim.core.config.groups.RoutingConfigGroup; import org.matsim.core.network.NetworkUtils; import org.matsim.core.network.algorithms.TransportModeNetworkFilter; import org.matsim.core.router.costcalculators.TravelDisutilityFactory; @@ -53,7 +53,8 @@ public class NetworkRoutingProvider implements Provider{ @Inject Map travelTimes; @Inject Map travelDisutilityFactories; @Inject SingleModeNetworksCache singleModeNetworksCache; - @Inject PlansCalcRouteConfigGroup plansCalcRouteConfigGroup; + @Inject + RoutingConfigGroup routingConfigGroup; @Inject Network network; @Inject NetworkConfigGroup networkConfigGroup; @Inject PopulationFactory populationFactory; @@ -129,7 +130,7 @@ public RoutingModule get() { travelTime); // the following again refers to the (transport)mode, since it will determine the mode of the leg on the network: - if ( !plansCalcRouteConfigGroup.getAccessEgressType().equals(PlansCalcRouteConfigGroup.AccessEgressType.none) ) { + if ( !routingConfigGroup.getAccessEgressType().equals(RoutingConfigGroup.AccessEgressType.none) ) { /* * All network modes should fall back to the TransportMode.walk RoutingModule for access/egress to the Network. * However, TransportMode.walk cannot fallback on itself for access/egress to the Network, so don't pass a standard diff --git a/matsim/src/main/java/org/matsim/core/router/TripRouterModule.java b/matsim/src/main/java/org/matsim/core/router/TripRouterModule.java index 4a369308aed..3202125dca4 100644 --- a/matsim/src/main/java/org/matsim/core/router/TripRouterModule.java +++ b/matsim/src/main/java/org/matsim/core/router/TripRouterModule.java @@ -22,7 +22,7 @@ package org.matsim.core.router; -import org.matsim.core.config.groups.PlansCalcRouteConfigGroup; +import org.matsim.core.config.groups.RoutingConfigGroup; import org.matsim.core.controler.AbstractModule; import org.matsim.core.network.algorithms.NetworkTurnInfoBuilder; import org.matsim.core.network.algorithms.NetworkTurnInfoBuilderI; @@ -47,7 +47,7 @@ public void install() { install(new LeastCostPathCalculatorModule()); install(new TransitRouterModule()); bind(SingleModeNetworksCache.class).asEagerSingleton(); - PlansCalcRouteConfigGroup routeConfigGroup = getConfig().plansCalcRoute(); + RoutingConfigGroup routeConfigGroup = getConfig().plansCalcRoute(); for (String mode : routeConfigGroup.getTeleportedModeFreespeedFactors().keySet()) { if (getConfig().transit().isUseTransit() && getConfig().transit().getTransitModes().contains(mode)) { // default config contains "pt" as teleported mode, but if we have simulated transit, this is supposed to override it diff --git a/matsim/src/main/java/org/matsim/core/router/TripStructureUtils.java b/matsim/src/main/java/org/matsim/core/router/TripStructureUtils.java index bf23e04d526..69ac6c3d0c3 100644 --- a/matsim/src/main/java/org/matsim/core/router/TripStructureUtils.java +++ b/matsim/src/main/java/org/matsim/core/router/TripStructureUtils.java @@ -29,7 +29,7 @@ import org.matsim.api.core.v01.population.Leg; import org.matsim.api.core.v01.population.Plan; import org.matsim.api.core.v01.population.PlanElement; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; import org.matsim.core.gbl.Gbl; import org.matsim.core.utils.geometry.CoordUtils; import org.matsim.core.utils.misc.OptionalTime; @@ -56,7 +56,7 @@ public final class TripStructureUtils { private static final Logger log = LogManager.getLogger(TripStructureUtils.class); public static final String routingMode = "routingMode"; - + public enum StageActivityHandling {StagesAsNormalActivities, ExcludeStageActivities} private TripStructureUtils() {} @@ -150,7 +150,7 @@ public static List getTrips( if ( currentIndex - originActivityIndex > 1 ) { // which means, if I am understanding this right, that two activities without a leg in between will not be considered - // a trip. + // a trip. trips.add( new Trip( (Activity) planElements.get( originActivityIndex ), @@ -421,7 +421,7 @@ public List getTripElements() { public List getLegsOnly() { return legs; } - + /** * Attributes of preceding activity are passed as trip attributes until more explicit encoding is found. */ @@ -625,7 +625,7 @@ public static boolean isStageActivityType( String activityType ) { return StageActivityTypeIdentifier.isStageActivity( activityType ) ; } public static String createStageActivityType( String mode ) { - return PlanCalcScoreConfigGroup.createStageActivityType( mode ) ; + return ScoringConfigGroup.createStageActivityType( mode ) ; } } diff --git a/matsim/src/main/java/org/matsim/core/router/costcalculators/FreespeedTravelTimeAndDisutility.java b/matsim/src/main/java/org/matsim/core/router/costcalculators/FreespeedTravelTimeAndDisutility.java index c361cc362ab..14ccca62bfd 100644 --- a/matsim/src/main/java/org/matsim/core/router/costcalculators/FreespeedTravelTimeAndDisutility.java +++ b/matsim/src/main/java/org/matsim/core/router/costcalculators/FreespeedTravelTimeAndDisutility.java @@ -25,7 +25,7 @@ import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.population.Person; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; import org.matsim.core.gbl.Gbl; import org.matsim.core.router.util.LinkToLinkTravelTime; import org.matsim.core.router.util.TravelDisutility; @@ -46,7 +46,7 @@ * @author dgrether */ public class FreespeedTravelTimeAndDisutility implements TravelDisutility, TravelTime, LinkToLinkTravelTime { - + private static final Logger log = LogManager.getLogger(FreespeedTravelTimeAndDisutility.class); private final double travelCostFactor; @@ -80,7 +80,7 @@ public FreespeedTravelTimeAndDisutility(double scaledMarginalUtilityOfTraveling, this.marginalUtlOfDistance = scaledMarginalUtilityOfDistance; } - public FreespeedTravelTimeAndDisutility(PlanCalcScoreConfigGroup cnScoringGroup){ + public FreespeedTravelTimeAndDisutility(ScoringConfigGroup cnScoringGroup){ this(cnScoringGroup.getModes().get(TransportMode.car).getMarginalUtilityOfTraveling() / 3600.0, cnScoringGroup.getPerforming_utils_hr() / 3600.0, // cnScoringGroup.getMarginalUtlOfDistanceCar()); cnScoringGroup.getModes().get(TransportMode.car).getMonetaryDistanceRate() *cnScoringGroup.getMarginalUtilityOfMoney()); @@ -115,5 +115,5 @@ public double getLinkTravelTime(Link link, double time, Person person, Vehicle v public double getLinkToLinkTravelTime(Link fromLink, Link toLink, double time, Person person, Vehicle vehicle) { return this.getLinkTravelTime(fromLink, time, null, null); } - + } diff --git a/matsim/src/main/java/org/matsim/core/router/costcalculators/RandomizingTimeDistanceTravelDisutilityFactory.java b/matsim/src/main/java/org/matsim/core/router/costcalculators/RandomizingTimeDistanceTravelDisutilityFactory.java index 56f299a0a58..0aa08467797 100644 --- a/matsim/src/main/java/org/matsim/core/router/costcalculators/RandomizingTimeDistanceTravelDisutilityFactory.java +++ b/matsim/src/main/java/org/matsim/core/router/costcalculators/RandomizingTimeDistanceTravelDisutilityFactory.java @@ -23,7 +23,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.matsim.core.config.Config; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; import org.matsim.core.router.util.TravelDisutility; import org.matsim.core.router.util.TravelTime; @@ -50,7 +50,7 @@ public class RandomizingTimeDistanceTravelDisutilityFactory implements TravelDis private final String mode; private final double sigma; - private final PlanCalcScoreConfigGroup cnScoringGroup; + private final ScoringConfigGroup cnScoringGroup; public RandomizingTimeDistanceTravelDisutilityFactory( final String mode, Config config ) { // NOTE: It is difficult to get rid of this constructor completely, since "mode" needs to be passed in. One could still get all other @@ -69,14 +69,14 @@ public TravelDisutility createTravelDisutility( final TravelTime travelTime) { // a warning. However, we know by now that few people think about such warnings. kai, mar'20 logWarningsIfNecessary( cnScoringGroup ); - final PlanCalcScoreConfigGroup.ModeParams params = cnScoringGroup.getModes().get( mode ) ; + final ScoringConfigGroup.ModeParams params = cnScoringGroup.getModes().get( mode ) ; if ( params == null ) { throw new NullPointerException( mode+" is not part of the valid mode parameters "+cnScoringGroup.getModes().keySet() ); } /* Usually, the travel-utility should be negative (it's a disutility) but the cost should be positive. Thus negate the utility.*/ final double marginalCostOfTime_s = (-params.getMarginalUtilityOfTraveling() / 3600.0) + (cnScoringGroup.getPerforming_utils_hr() / 3600.0); - final double marginalCostOfDistance_m = - params.getMonetaryDistanceRate() * cnScoringGroup.getMarginalUtilityOfMoney() + final double marginalCostOfDistance_m = - params.getMonetaryDistanceRate() * cnScoringGroup.getMarginalUtilityOfMoney() - params.getMarginalUtilityOfDistance() ; double normalization = 1; @@ -95,7 +95,7 @@ public TravelDisutility createTravelDisutility( final TravelTime travelTime) { sigma); } - private void logWarningsIfNecessary(final PlanCalcScoreConfigGroup cnScoringGroup) { + private void logWarningsIfNecessary(final ScoringConfigGroup cnScoringGroup) { if ( wrnCnt.getAndIncrement() < 1 ) { if ( cnScoringGroup.getModes().get( mode ).getMonetaryDistanceRate() > 0. ) { log.warn("Monetary distance cost rate needs to be NEGATIVE to produce the normal " + @@ -108,12 +108,12 @@ private void logWarningsIfNecessary(final PlanCalcScoreConfigGroup cnScoringGrou " The routing disutility will only consider the ones of the default subpopulation."); log.warn( "This warning can safely be ignored if disutility of traveling only depends on travel time."); } - + if ( cnScoringGroup.getModes().get( mode ).getMonetaryDistanceRate() == 0. && this.sigma != 0. ) { log.warn("There will be no routing randomness. The randomization of the travel disutility requires the monetary distance rate " + "to be different than zero. Continuing anyway.") ; } - + if ( (cnScoringGroup.getModes().get( mode ).getMarginalUtilityOfTraveling() + cnScoringGroup.getPerforming_utils_hr()) == 0. && this.sigma != 0. ) { log.warn("There will be no routing randomness. The randomization of the travel disutility requires the travel time cost rate " + "to be different than zero. Continuing anyway.") ; diff --git a/matsim/src/main/java/org/matsim/core/router/costcalculators/TravelDisutilityModule.java b/matsim/src/main/java/org/matsim/core/router/costcalculators/TravelDisutilityModule.java index 436bfde5b9c..8d3d3d01b05 100644 --- a/matsim/src/main/java/org/matsim/core/router/costcalculators/TravelDisutilityModule.java +++ b/matsim/src/main/java/org/matsim/core/router/costcalculators/TravelDisutilityModule.java @@ -22,14 +22,14 @@ package org.matsim.core.router.costcalculators; -import org.matsim.core.config.groups.PlansCalcRouteConfigGroup; +import org.matsim.core.config.groups.RoutingConfigGroup; import org.matsim.core.controler.AbstractModule; public class TravelDisutilityModule extends AbstractModule { @Override public void install() { - PlansCalcRouteConfigGroup routeConfigGroup = getConfig().plansCalcRoute(); + RoutingConfigGroup routeConfigGroup = getConfig().plansCalcRoute(); for (String mode : routeConfigGroup.getNetworkModes()) { final RandomizingTimeDistanceTravelDisutilityFactory builder = new RandomizingTimeDistanceTravelDisutilityFactory( mode, getConfig() ); diff --git a/matsim/src/main/java/org/matsim/core/router/util/TravelDisutilityUtils.java b/matsim/src/main/java/org/matsim/core/router/util/TravelDisutilityUtils.java index 800a82a0853..1f6073fe875 100644 --- a/matsim/src/main/java/org/matsim/core/router/util/TravelDisutilityUtils.java +++ b/matsim/src/main/java/org/matsim/core/router/util/TravelDisutilityUtils.java @@ -18,7 +18,7 @@ * *********************************************************************** */ package org.matsim.core.router.util; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; import org.matsim.core.router.costcalculators.FreespeedTravelTimeAndDisutility; /** @@ -27,8 +27,8 @@ */ public final class TravelDisutilityUtils { private TravelDisutilityUtils(){} // do not instantiate - - public static TravelDisutility createFreespeedTravelTimeAndDisutility(PlanCalcScoreConfigGroup cnScoringGroup) { + + public static TravelDisutility createFreespeedTravelTimeAndDisutility(ScoringConfigGroup cnScoringGroup) { return new FreespeedTravelTimeAndDisutility(cnScoringGroup) ; } diff --git a/matsim/src/main/java/org/matsim/core/scoring/NewScoreAssignerImpl.java b/matsim/src/main/java/org/matsim/core/scoring/NewScoreAssignerImpl.java index 6365ed3af25..c6dc3ac3656 100644 --- a/matsim/src/main/java/org/matsim/core/scoring/NewScoreAssignerImpl.java +++ b/matsim/src/main/java/org/matsim/core/scoring/NewScoreAssignerImpl.java @@ -27,8 +27,8 @@ import org.matsim.api.core.v01.population.Person; import org.matsim.api.core.v01.population.Plan; import org.matsim.api.core.v01.population.Population; -import org.matsim.core.config.groups.ControlerConfigGroup; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; +import org.matsim.core.config.groups.ControllerConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; import jakarta.inject.Inject; import java.util.HashMap; @@ -45,13 +45,13 @@ class NewScoreAssignerImpl implements NewScoreAssigner { private long scoreCount = 0; @Inject - NewScoreAssignerImpl(PlanCalcScoreConfigGroup planCalcScoreConfigGroup, ControlerConfigGroup controlerConfigGroup) { - if (planCalcScoreConfigGroup.getFractionOfIterationsToStartScoreMSA()!=null ) { - final int diff = controlerConfigGroup.getLastIteration() - controlerConfigGroup.getFirstIteration(); + NewScoreAssignerImpl(ScoringConfigGroup scoringConfigGroup, ControllerConfigGroup controllerConfigGroup) { + if (scoringConfigGroup.getFractionOfIterationsToStartScoreMSA()!=null ) { + final int diff = controllerConfigGroup.getLastIteration() - controllerConfigGroup.getFirstIteration(); this.scoreMSAstartsAtIteration = (int) (diff - * planCalcScoreConfigGroup.getFractionOfIterationsToStartScoreMSA() + controlerConfigGroup.getFirstIteration()); + * scoringConfigGroup.getFractionOfIterationsToStartScoreMSA() + controllerConfigGroup.getFirstIteration()); } - learningRate = planCalcScoreConfigGroup.getLearningRate(); + learningRate = scoringConfigGroup.getLearningRate(); } public void assignNewScores(int iteration, ScoringFunctionsForPopulation scoringFunctionsForPopulation, Population population) { diff --git a/matsim/src/main/java/org/matsim/core/scoring/PlansScoringImpl.java b/matsim/src/main/java/org/matsim/core/scoring/PlansScoringImpl.java index 79458c4b4d9..bc774cc2c1d 100644 --- a/matsim/src/main/java/org/matsim/core/scoring/PlansScoringImpl.java +++ b/matsim/src/main/java/org/matsim/core/scoring/PlansScoringImpl.java @@ -25,8 +25,8 @@ import org.matsim.api.core.v01.population.Person; import org.matsim.api.core.v01.population.Plan; import org.matsim.api.core.v01.population.Population; -import org.matsim.core.config.groups.ControlerConfigGroup; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; +import org.matsim.core.config.groups.ControllerConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; import org.matsim.core.controler.OutputDirectoryHierarchy; import org.matsim.core.controler.corelisteners.PlansScoring; import org.matsim.core.controler.events.IterationEndsEvent; @@ -46,8 +46,8 @@ @Singleton final class PlansScoringImpl implements PlansScoring, ScoringListener, IterationEndsListener { - @Inject private PlanCalcScoreConfigGroup planCalcScoreConfigGroup; - @Inject private ControlerConfigGroup controlerConfigGroup; + @Inject private ScoringConfigGroup scoringConfigGroup; + @Inject private ControllerConfigGroup controllerConfigGroup; @Inject private Population population; @Inject private OutputDirectoryHierarchy controlerIO; @Inject private ScoringFunctionsForPopulation scoringFunctionsForPopulation; @@ -56,30 +56,30 @@ final class PlansScoringImpl implements PlansScoring, ScoringListener, Iteration @Override public void notifyScoring(final ScoringEvent event) { scoringFunctionsForPopulation.finishScoringFunctions(); - NewScoreAssignerImpl newScoreAssigner = new NewScoreAssignerImpl(this.planCalcScoreConfigGroup, this.controlerConfigGroup); + NewScoreAssignerImpl newScoreAssigner = new NewScoreAssignerImpl(this.scoringConfigGroup, this.controllerConfigGroup); newScoreAssigner.assignNewScores(event.getIteration(), this.scoringFunctionsForPopulation, this.population); } @Override public void notifyIterationEnds(final IterationEndsEvent event) { - this.experiencedPlansService.finishIteration(); + this.experiencedPlansService.finishIteration(); // (currently sets scores to experienced plans) - - if(planCalcScoreConfigGroup.isWriteExperiencedPlans()) { - final int writePlansInterval = controlerConfigGroup.getWritePlansInterval(); + + if(scoringConfigGroup.isWriteExperiencedPlans()) { + final int writePlansInterval = controllerConfigGroup.getWritePlansInterval(); if (writePlansInterval > 0 && (event.getIteration() % writePlansInterval == 0 || event.isLastIteration())) { this.experiencedPlansService.writeExperiencedPlans(controlerIO.getIterationFilename(event.getIteration(), "experienced_plans.xml.gz")); this.scoringFunctionsForPopulation.writePartialScores(controlerIO.getIterationFilename(event.getIteration(), "experienced_plans_scores.txt.gz")); } } - if (planCalcScoreConfigGroup.isMemorizingExperiencedPlans() ) { + if (scoringConfigGroup.isMemorizingExperiencedPlans() ) { for ( Person person : this.population.getPersons().values() ) { Plan experiencedPlan = this.experiencedPlansService.getExperiencedPlans().get( person.getId() ) ; if ( experiencedPlan==null ) { throw new RuntimeException("experienced plan is null; I don't think this should happen") ; } Plan selectedPlan = person.getSelectedPlan() ; - selectedPlan.getCustomAttributes().put(PlanCalcScoreConfigGroup.EXPERIENCED_PLAN_KEY, experiencedPlan ) ; + selectedPlan.getCustomAttributes().put(ScoringConfigGroup.EXPERIENCED_PLAN_KEY, experiencedPlan ) ; } } } diff --git a/matsim/src/main/java/org/matsim/core/scoring/ScoringFunctionsForPopulation.java b/matsim/src/main/java/org/matsim/core/scoring/ScoringFunctionsForPopulation.java index 71b3fbf6f6d..43547e4173c 100644 --- a/matsim/src/main/java/org/matsim/core/scoring/ScoringFunctionsForPopulation.java +++ b/matsim/src/main/java/org/matsim/core/scoring/ScoringFunctionsForPopulation.java @@ -49,7 +49,7 @@ import org.matsim.core.api.experimental.events.TeleportationArrivalEvent; import org.matsim.core.api.experimental.events.VehicleArrivesAtFacilityEvent; import org.matsim.core.config.Config; -import org.matsim.core.config.groups.ControlerConfigGroup; +import org.matsim.core.config.groups.ControllerConfigGroup; import org.matsim.core.controler.ControlerListenerManager; import org.matsim.core.controler.listener.BeforeMobsimListener; import org.matsim.core.controler.listener.IterationStartsListener; @@ -73,15 +73,15 @@ * This class helps EventsToScore by keeping ScoringFunctions for the entire Population - one per Person -, and dispatching Activities * and Legs to the ScoringFunctions. It also gives out the ScoringFunctions, so they can be given other events by EventsToScore. * It is not independently useful. Please do not make public. - * + * * @author michaz * */ final class ScoringFunctionsForPopulation implements BasicEventHandler { - + private final Population population; private final ScoringFunctionFactory scoringFunctionFactory; - + private final EventsToLegs legsDelegate; private final EventsToActivities actsDelegate; @@ -89,17 +89,17 @@ final class ScoringFunctionsForPopulation implements BasicEventHandler { private final IdMap partialScores = new IdMap<>(Person.class); private final AtomicReference exception = new AtomicReference<>(); private final IdMap tripRecords = new IdMap<>(Person.class); - + private final Vehicle2DriverEventHandler vehicles2Drivers = new Vehicle2DriverEventHandler(); @Inject ScoringFunctionsForPopulation(ControlerListenerManager controlerListenerManager, EventsManager eventsManager, EventsToActivities eventsToActivities, EventsToLegs eventsToLegs, Population population, ScoringFunctionFactory scoringFunctionFactory, Config config) { - ControlerConfigGroup controlerConfigGroup = config.controler(); - - if (controlerConfigGroup.getEventTypeToCreateScoringFunctions() == ControlerConfigGroup.EventTypeToCreateScoringFunctions.IterationStarts) { + ControllerConfigGroup controllerConfigGroup = config.controler(); + + if (controllerConfigGroup.getEventTypeToCreateScoringFunctions() == ControllerConfigGroup.EventTypeToCreateScoringFunctions.IterationStarts) { controlerListenerManager.addControlerListener((IterationStartsListener) event -> init()); - } else if (controlerConfigGroup.getEventTypeToCreateScoringFunctions() == ControlerConfigGroup.EventTypeToCreateScoringFunctions.BeforeMobsim) { + } else if (controllerConfigGroup.getEventTypeToCreateScoringFunctions() == ControllerConfigGroup.EventTypeToCreateScoringFunctions.BeforeMobsim) { controlerListenerManager.addControlerListener((BeforeMobsimListener) event -> init()); } else { throw new RuntimeException("Unknown approach when to create the scoring functions for population. Aborting..."); @@ -248,7 +248,7 @@ void handleActivity(PersonExperiencedActivity o) { TDoubleCollection partialScoresForAgent = this.partialScores.get(agentId); partialScoresForAgent.add(scoringFunction.getScore()); } - + Plan plan = this.tripRecords.get( agentId ); // as container for trip if ( plan!= null ) { plan.addActivity( activity ); diff --git a/matsim/src/main/java/org/matsim/core/scoring/functions/ActivityUtilityParameters.java b/matsim/src/main/java/org/matsim/core/scoring/functions/ActivityUtilityParameters.java index 82657accb18..22c4250f8bb 100644 --- a/matsim/src/main/java/org/matsim/core/scoring/functions/ActivityUtilityParameters.java +++ b/matsim/src/main/java/org/matsim/core/scoring/functions/ActivityUtilityParameters.java @@ -21,7 +21,7 @@ package org.matsim.core.scoring.functions; import org.matsim.core.api.internal.MatsimParameters; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup.ActivityParams; +import org.matsim.core.config.groups.ScoringConfigGroup.ActivityParams; import org.matsim.core.utils.misc.OptionalTime; /** @@ -114,7 +114,7 @@ public Builder(ActivityParams ppp ) { throw new RuntimeException("not defined"); } // seems to be somewhat overkill to set a computation method that is only used in the builder ... but the builder has a method to - // (re)set the + // (re)set the } diff --git a/matsim/src/main/java/org/matsim/core/scoring/functions/ModeUtilityParameters.java b/matsim/src/main/java/org/matsim/core/scoring/functions/ModeUtilityParameters.java index 37bb726da35..1e85fcffccd 100644 --- a/matsim/src/main/java/org/matsim/core/scoring/functions/ModeUtilityParameters.java +++ b/matsim/src/main/java/org/matsim/core/scoring/functions/ModeUtilityParameters.java @@ -21,7 +21,7 @@ package org.matsim.core.scoring.functions; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; /** * Class that stores parameters used from the scoring functions @@ -38,7 +38,7 @@ public static class Builder { public Builder() {} - public Builder( PlanCalcScoreConfigGroup.ModeParams params ) { + public Builder( ScoringConfigGroup.ModeParams params ) { this.marginalUtilityOfTraveling_s = params.getMarginalUtilityOfTraveling() / 3600.0; this.marginalUtilityOfDistance_m = params.getMarginalUtilityOfDistance(); this.monetaryDistanceRate = params.getMonetaryDistanceRate(); @@ -61,7 +61,7 @@ public Builder setMonetaryDistanceRate(double monetaryDistanceRate) { this.monetaryDistanceRate = monetaryDistanceRate; return this; } - + public Builder setConstant(double constant) { this.constant = constant; return this; @@ -71,7 +71,7 @@ public Builder setDailyMoneyConstant(double dailyMoneyConstant) { this.dailyMoneyConstant = dailyMoneyConstant; return this; } - + public Builder setDailyUtilityConstant(double dailyUtilityConstant) { this.dailyUtilityConstant = dailyUtilityConstant; return this; diff --git a/matsim/src/main/java/org/matsim/core/scoring/functions/ScoringParameters.java b/matsim/src/main/java/org/matsim/core/scoring/functions/ScoringParameters.java index 7502919af20..f9a347f4ed5 100644 --- a/matsim/src/main/java/org/matsim/core/scoring/functions/ScoringParameters.java +++ b/matsim/src/main/java/org/matsim/core/scoring/functions/ScoringParameters.java @@ -23,12 +23,11 @@ import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.population.Person; import org.matsim.core.api.internal.MatsimParameters; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup.ActivityParams; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup.ModeParams; +import org.matsim.core.config.groups.ScoringConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup.ActivityParams; +import org.matsim.core.config.groups.ScoringConfigGroup.ModeParams; import org.matsim.core.config.groups.ScenarioConfigGroup; import org.matsim.core.population.PopulationUtils; -import org.matsim.core.utils.collections.ArrayMap; import java.util.Map; import java.util.TreeMap; @@ -46,9 +45,9 @@ public class ScoringParameters implements MatsimParameters { public final double marginalUtilityOfMoney; public final double abortedPlanScore; public final boolean scoreActs; - + public final boolean usingOldScoringBelowZeroUtilityDuration ; - + public final double simulationPeriodInDays; private ScoringParameters( @@ -125,11 +124,11 @@ public Builder( */ @Deprecated public Builder( - final PlanCalcScoreConfigGroup configGroup, - final PlanCalcScoreConfigGroup.ScoringParameterSet scoringParameterSet, + final ScoringConfigGroup configGroup, + final ScoringConfigGroup.ScoringParameterSet scoringParameterSet, final ScenarioConfigGroup scenarioConfig) { this.simulationPeriodInDays = scenarioConfig.getSimulationPeriodInDays(); - + this.usingOldScoringBelowZeroUtilityDuration = configGroup.isUsingOldScoringBelowZeroUtilityDuration() ; marginalUtilityOfWaiting_s = scoringParameterSet.getMarginalUtlOfWaiting_utils_hr() / 3600.0; @@ -149,9 +148,9 @@ public Builder( } modeParams = new TreeMap<>() ; - Map modes = scoringParameterSet.getModes(); + Map modes = scoringParameterSet.getModes(); double worstMarginalUtilityOfTraveling_s = 0.0; - for (Map.Entry mode : modes.entrySet()) { + for (Map.Entry mode : modes.entrySet()) { String modeName = mode.getKey(); ModeParams params = mode.getValue(); worstMarginalUtilityOfTraveling_s = Math.min(worstMarginalUtilityOfTraveling_s, params.getMarginalUtilityOfTraveling() / 3600. ); @@ -179,8 +178,8 @@ public Builder( * @param scenarioConfig */ public Builder( - final PlanCalcScoreConfigGroup configGroup, - final PlanCalcScoreConfigGroup.ScoringParameterSet scoringParameterSet, + final ScoringConfigGroup configGroup, + final ScoringConfigGroup.ScoringParameterSet scoringParameterSet, Map activityParams, final ScenarioConfigGroup scenarioConfig) { this.simulationPeriodInDays = scenarioConfig.getSimulationPeriodInDays(); @@ -200,9 +199,9 @@ public Builder( utilParams = activityParams; modeParams = new TreeMap<>() ; - Map modes = scoringParameterSet.getModes(); + Map modes = scoringParameterSet.getModes(); double worstMarginalUtilityOfTraveling_s = 0.0; - for (Map.Entry mode : modes.entrySet()) { + for (Map.Entry mode : modes.entrySet()) { String modeName = mode.getKey(); ModeParams params = mode.getValue(); worstMarginalUtilityOfTraveling_s = Math.min(worstMarginalUtilityOfTraveling_s, params.getMarginalUtilityOfTraveling() / 3600. ); diff --git a/matsim/src/main/java/org/matsim/core/scoring/functions/SubpopulationScoringParameters.java b/matsim/src/main/java/org/matsim/core/scoring/functions/SubpopulationScoringParameters.java index 68ec1cfdc02..ffd603b2b3b 100644 --- a/matsim/src/main/java/org/matsim/core/scoring/functions/SubpopulationScoringParameters.java +++ b/matsim/src/main/java/org/matsim/core/scoring/functions/SubpopulationScoringParameters.java @@ -21,7 +21,7 @@ import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.population.Person; import org.matsim.api.core.v01.population.Population; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; import org.matsim.core.config.groups.PlansConfigGroup; import org.matsim.core.config.groups.ScenarioConfigGroup; import org.matsim.core.population.PopulationUtils; @@ -36,15 +36,15 @@ * @author thibautd */ public class SubpopulationScoringParameters implements ScoringParametersForPerson { - private final PlanCalcScoreConfigGroup config; + private final ScoringConfigGroup config; private final ScenarioConfigGroup scConfig; private final TransitConfigGroup transitConfigGroup; private final Map params = new HashMap<>(); private final Population population; @Inject - SubpopulationScoringParameters(PlansConfigGroup plansConfigGroup, PlanCalcScoreConfigGroup planCalcScoreConfigGroup, ScenarioConfigGroup scenarioConfigGroup, Population population, TransitConfigGroup transitConfigGroup) { - this.config = planCalcScoreConfigGroup; + SubpopulationScoringParameters(PlansConfigGroup plansConfigGroup, ScoringConfigGroup scoringConfigGroup, ScenarioConfigGroup scenarioConfigGroup, Population population, TransitConfigGroup transitConfigGroup) { + this.config = scoringConfigGroup; this.scConfig = scenarioConfigGroup; this.transitConfigGroup = transitConfigGroup; this.population = population ; @@ -71,7 +71,7 @@ public ScoringParameters getScoringParameters(Person person) { - PlanCalcScoreConfigGroup.ActivityParams transitActivityParams = new PlanCalcScoreConfigGroup.ActivityParams(PtConstants.TRANSIT_ACTIVITY_TYPE); + ScoringConfigGroup.ActivityParams transitActivityParams = new ScoringConfigGroup.ActivityParams(PtConstants.TRANSIT_ACTIVITY_TYPE); transitActivityParams.setTypicalDuration(120.0); transitActivityParams.setOpeningTime(0.) ; transitActivityParams.setClosingTime(0.) ; diff --git a/matsim/src/main/java/org/matsim/counts/CountsControlerListener.java b/matsim/src/main/java/org/matsim/counts/CountsControlerListener.java index 670af0ea897..ddff27eca43 100644 --- a/matsim/src/main/java/org/matsim/counts/CountsControlerListener.java +++ b/matsim/src/main/java/org/matsim/counts/CountsControlerListener.java @@ -26,7 +26,7 @@ import org.matsim.api.core.v01.IdMap; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; -import org.matsim.core.config.groups.ControlerConfigGroup; +import org.matsim.core.config.groups.ControllerConfigGroup; import org.matsim.core.config.groups.CountsConfigGroup; import org.matsim.core.config.groups.GlobalConfigGroup; import org.matsim.core.controler.OutputDirectoryHierarchy; @@ -63,7 +63,7 @@ class CountsControlerListener implements StartupListener, IterationEndsListener private GlobalConfigGroup globalConfigGroup; private Network network; - private ControlerConfigGroup controlerConfigGroup; + private ControllerConfigGroup controllerConfigGroup; private final CountsConfigGroup config; private final Set analyzedModes; private final VolumesAnalyzer volumesAnalyzer; @@ -77,10 +77,10 @@ class CountsControlerListener implements StartupListener, IterationEndsListener private int iterationsUsed = 0; @Inject - CountsControlerListener(GlobalConfigGroup globalConfigGroup, Network network, ControlerConfigGroup controlerConfigGroup, CountsConfigGroup countsConfigGroup, VolumesAnalyzer volumesAnalyzer, IterationStopWatch iterationStopwatch, OutputDirectoryHierarchy controlerIO) { + CountsControlerListener(GlobalConfigGroup globalConfigGroup, Network network, ControllerConfigGroup controllerConfigGroup, CountsConfigGroup countsConfigGroup, VolumesAnalyzer volumesAnalyzer, IterationStopWatch iterationStopwatch, OutputDirectoryHierarchy controlerIO) { this.globalConfigGroup = globalConfigGroup; this.network = network; - this.controlerConfigGroup = controlerConfigGroup; + this.controllerConfigGroup = controllerConfigGroup; this.config = countsConfigGroup; this.volumesAnalyzer = volumesAnalyzer; this.analyzedModes = CollectionUtils.stringToSet(this.config.getAnalyzedModes()); @@ -100,7 +100,7 @@ public void notifyStartup(final StartupEvent controlerStartupEvent) { @Override public void notifyIterationEnds(final IterationEndsEvent event) { if (counts != null && this.config.getWriteCountsInterval() > 0) { - if (useVolumesOfIteration(event.getIteration(), controlerConfigGroup.getFirstIteration())) { + if (useVolumesOfIteration(event.getIteration(), controllerConfigGroup.getFirstIteration())) { addVolumes(volumesAnalyzer); } diff --git a/matsim/src/main/java/org/matsim/facilities/FacilitiesFromPopulation.java b/matsim/src/main/java/org/matsim/facilities/FacilitiesFromPopulation.java index 6bd51412034..7b80a8d26e2 100644 --- a/matsim/src/main/java/org/matsim/facilities/FacilitiesFromPopulation.java +++ b/matsim/src/main/java/org/matsim/facilities/FacilitiesFromPopulation.java @@ -41,8 +41,8 @@ import org.matsim.api.core.v01.population.PlanElement; import org.matsim.api.core.v01.population.Population; import org.matsim.core.config.groups.FacilitiesConfigGroup; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup.ActivityParams; +import org.matsim.core.config.groups.ScoringConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup.ActivityParams; import org.matsim.core.gbl.Gbl; import org.matsim.core.network.NetworkUtils; import org.matsim.core.population.PopulationUtils; @@ -67,7 +67,7 @@ public final class FacilitiesFromPopulation { private String idPrefix = ""; private Network network = null; private boolean removeLinksAndCoordinates = true; - private PlanCalcScoreConfigGroup planCalcScoreConfigGroup = null; + private ScoringConfigGroup scoringConfigGroup = null; private boolean addEmptyActivityOptions = false; public FacilitiesFromPopulation(final ActivityFacilities facilities) { @@ -86,7 +86,7 @@ public FacilitiesFromPopulation( Scenario scenario ) { this.addEmptyActivityOptions = true ; this.facilitiesSource = facilityConfigGroup.getFacilitiesSource(); this.network = scenario.getNetwork() ; - this.planCalcScoreConfigGroup = scenario.getConfig().planCalcScore() ; + this.scoringConfigGroup = scenario.getConfig().planCalcScore() ; this.scenario = scenario; } public void setFacilitiesSource( final FacilitiesSource facilitiesSource ) { @@ -137,14 +137,14 @@ public void setRemoveLinksAndCoordinates(final boolean doRemoval) { this.removeLinksAndCoordinates = doRemoval; } - public void assignOpeningTimes( final PlanCalcScoreConfigGroup calcScoreConfigGroup ) { + public void assignOpeningTimes( final ScoringConfigGroup calcScoreConfigGroup ) { Gbl.assertNotNull( calcScoreConfigGroup ); - this.planCalcScoreConfigGroup = calcScoreConfigGroup ; + this.scoringConfigGroup = calcScoreConfigGroup ; } public void run(final Population population) { handleActivities(population); - if (this.planCalcScoreConfigGroup != null ) { + if (this.scoringConfigGroup != null ) { if (this.addEmptyActivityOptions) { this.assignOpeningTimes(); } else{ @@ -269,7 +269,7 @@ private void assignOpeningTimes() { for (ActivityFacility af : this.facilities.getFacilities().values()) { for (ActivityOption ao : af.getActivityOptions().values()) { String actType = ao.getType(); - ActivityParams params = this.planCalcScoreConfigGroup.getActivityParams(actType); + ActivityParams params = this.scoringConfigGroup.getActivityParams(actType); if (params == null) { if (missingActTypes.add(actType)) { log.error("No information for activity type " + actType + " found in given configuration."); diff --git a/matsim/src/main/java/org/matsim/guice/DependencyGraphControlerListener.java b/matsim/src/main/java/org/matsim/guice/DependencyGraphControlerListener.java index 8f0c94b3a82..242757de4d9 100644 --- a/matsim/src/main/java/org/matsim/guice/DependencyGraphControlerListener.java +++ b/matsim/src/main/java/org/matsim/guice/DependencyGraphControlerListener.java @@ -32,7 +32,7 @@ import com.google.inject.grapher.NodeId; import com.google.inject.spi.ProviderBinding; import com.google.inject.util.Types; -import org.matsim.core.config.groups.StrategyConfigGroup; +import org.matsim.core.config.groups.ReplanningConfigGroup; import org.matsim.core.controler.OutputDirectoryHierarchy; import org.matsim.core.controler.events.StartupEvent; import org.matsim.core.controler.listener.ControlerListener; @@ -82,7 +82,7 @@ public void notifyStartup(StartupEvent event) { allAliases.addAll(getMapBinderAliases(String.class, TravelTime.class, bindings)); allAliases.addAll(getMapBinderAliases(String.class, TravelDisutilityFactory.class, bindings)); allAliases.addAll(getMapBinderAliases(String.class, RoutingModule.class, bindings)); - allAliases.addAll(getMapBinderAliases(StrategyConfigGroup.StrategySettings.class, PlanStrategy.class, bindings)); + allAliases.addAll(getMapBinderAliases(ReplanningConfigGroup.StrategySettings.class, PlanStrategy.class, bindings)); allAliases.addAll(getMultibinderAliases(ControlerListener.class, bindings)); allAliases.addAll(getMultibinderAliases(SnapshotWriter.class, bindings)); allAliases.addAll(getMultibinderAliases(MobsimListener.class, bindings)); diff --git a/matsim/src/main/java/org/matsim/pt/PtConstants.java b/matsim/src/main/java/org/matsim/pt/PtConstants.java index 2247f2709f0..4a252332dbe 100644 --- a/matsim/src/main/java/org/matsim/pt/PtConstants.java +++ b/matsim/src/main/java/org/matsim/pt/PtConstants.java @@ -24,11 +24,11 @@ import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.population.Activity; import org.matsim.core.api.internal.MatsimParameters; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; /** * An abstract class containing some constants used for public transportation. - * + * * @author mrieser */ public abstract class PtConstants implements MatsimParameters { @@ -36,11 +36,11 @@ public abstract class PtConstants implements MatsimParameters { /** * Type of an activity that somehow interacts with pt, e.g. to connect a walk leg * to a pt leg, or to connect two pt legs together where agents have to change lines. - * + * * @see Activity#setType(String) */ - public final static String TRANSIT_ACTIVITY_TYPE = PlanCalcScoreConfigGroup.createStageActivityType(TransportMode.pt); - + public final static String TRANSIT_ACTIVITY_TYPE = ScoringConfigGroup.createStageActivityType(TransportMode.pt); + // this is currently used for wait2link events where the mode is not clear (bus, rail...?!), theresa sep'2015 public final static String NETWORK_MODE = "pt unspecified"; diff --git a/matsim/src/main/java/org/matsim/pt/ReconstructingUmlaufBuilder.java b/matsim/src/main/java/org/matsim/pt/ReconstructingUmlaufBuilder.java index ba65434100f..14aede08b8f 100644 --- a/matsim/src/main/java/org/matsim/pt/ReconstructingUmlaufBuilder.java +++ b/matsim/src/main/java/org/matsim/pt/ReconstructingUmlaufBuilder.java @@ -31,8 +31,6 @@ import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; -import org.matsim.api.core.v01.network.Network; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; import org.matsim.core.gbl.Gbl; import org.matsim.pt.transitSchedule.api.Departure; import org.matsim.pt.transitSchedule.api.TransitLine; @@ -103,11 +101,11 @@ private void createUmlaeufe(){ printStatus(cnt); } } - + private Id getUmlaufIdForVehicleId(Id vehId){ return this.umlaufIdsByVehicleId.get(vehId); } - + private Id createUmlaufIdFromVehicle(Vehicle vehicle){ Id id = Id.create(vehicle.getId().toString() + "_" + vehicle.getType().getId().toString(), Umlauf.class); this.umlaufIdsByVehicleId.put(vehicle.getId(), id); @@ -146,7 +144,7 @@ private void createUmlaufStuecke() { log.info("... done generating UmlaufStuecke"); Collections.sort(this.umlaufStuecke, departureTimeComparator); } - + private void printStatus(int cnt){ if ( cnt%100==0 ) { System.out.print('.'); diff --git a/matsim/src/main/java/org/matsim/pt/UmlaufInterpolator.java b/matsim/src/main/java/org/matsim/pt/UmlaufInterpolator.java index 1555772b3ba..794bcb6a61c 100644 --- a/matsim/src/main/java/org/matsim/pt/UmlaufInterpolator.java +++ b/matsim/src/main/java/org/matsim/pt/UmlaufInterpolator.java @@ -27,7 +27,7 @@ import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; import org.matsim.api.core.v01.network.Node; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; import org.matsim.core.network.NetworkUtils; import org.matsim.core.population.routes.NetworkRoute; import org.matsim.core.population.routes.RouteUtils; @@ -41,7 +41,7 @@ public final class UmlaufInterpolator { private final Network network; private final LeastCostPathCalculator routingAlgo; - public UmlaufInterpolator(Network network, final PlanCalcScoreConfigGroup config) { + public UmlaufInterpolator(Network network, final ScoringConfigGroup config) { super(); this.network = network; FreespeedTravelTimeAndDisutility travelTimes = new FreespeedTravelTimeAndDisutility(config); diff --git a/matsim/src/main/java/org/matsim/pt/router/TransitRouterConfig.java b/matsim/src/main/java/org/matsim/pt/router/TransitRouterConfig.java index 6ae4c9cd7af..13dd4eda240 100644 --- a/matsim/src/main/java/org/matsim/pt/router/TransitRouterConfig.java +++ b/matsim/src/main/java/org/matsim/pt/router/TransitRouterConfig.java @@ -25,9 +25,9 @@ import org.matsim.api.core.v01.TransportMode; import org.matsim.core.api.internal.MatsimParameters; import org.matsim.core.config.Config; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; -import org.matsim.core.config.groups.PlansCalcRouteConfigGroup; -import org.matsim.core.config.groups.PlansCalcRouteConfigGroup.TeleportedModeParams; +import org.matsim.core.config.groups.ScoringConfigGroup; +import org.matsim.core.config.groups.RoutingConfigGroup; +import org.matsim.core.config.groups.RoutingConfigGroup.TeleportedModeParams; import org.matsim.core.config.groups.VspExperimentalConfigGroup; import org.matsim.core.gbl.Gbl; import org.matsim.pt.config.TransitRouterConfigGroup; @@ -91,7 +91,7 @@ public class TransitRouterConfig implements MatsimParameters { private double marginalUtilityOfWaitingPt_utl_s; private double marginalUtilityOfTravelDistanceWalk_utl_m; - + private double marginalUtilityOfTravelDistanceTransit_utl_m; private double utilityOfLineSwitch_utl; @@ -99,24 +99,24 @@ public class TransitRouterConfig implements MatsimParameters { private Double beelineDistanceFactor; private final double directWalkFactor ; - + private boolean cacheTree; public TransitRouterConfig(final Config config) { this(config.planCalcScore(), config.plansCalcRoute(), config.transitRouter(), config.vspExperimental()); } - - public TransitRouterConfig(final PlanCalcScoreConfigGroup pcsConfig, final PlansCalcRouteConfigGroup pcrConfig, - final TransitRouterConfigGroup trConfig, final VspExperimentalConfigGroup vspConfig ) + + public TransitRouterConfig(final ScoringConfigGroup pcsConfig, final RoutingConfigGroup pcrConfig, + final TransitRouterConfigGroup trConfig, final VspExperimentalConfigGroup vspConfig ) { pcsConfig.setLocked(); pcrConfig.setLocked() ; trConfig.setLocked() ; vspConfig.setLocked() ; - + if (pcsConfig.getScoringParametersPerSubpopulation().size()>1){ LogManager.getLogger(getClass()).warn("More than one subpopulation is used in plansCalcScore. " + "This is not currently implemented in the TransitRouter (but should work for scoring)," + " so the values for the \"default\" subpopulation will be used. (jb, Feb 2018)"); } - + // walk: { TeleportedModeParams params = pcrConfig.getModeRoutingParams().get( TransportMode.walk ); @@ -126,13 +126,13 @@ public TransitRouterConfig(final PlanCalcScoreConfigGroup pcsConfig, final Plans } // yyyyyy the two above need to be moved away from walk since otherwise one is not able to move walk routing to network routing!!!!!! Now trying access_walk ... kai, // apr'19 - + this.marginalUtilityOfTravelTimeWalk_utl_s = pcsConfig.getModes().get(TransportMode.walk).getMarginalUtilityOfTraveling() /3600.0 - pcsConfig.getPerforming_utils_hr()/3600. ; - + this.marginalUtilityOfTravelDistanceWalk_utl_m = pcsConfig.getMarginalUtilityOfMoney() * pcsConfig.getModes().get(TransportMode.walk).getMonetaryDistanceRate() + pcsConfig.getModes().get(TransportMode.walk).getMarginalUtilityOfDistance(); - + // pt: this.marginalUtilityOfTravelTimeTransit_utl_s = pcsConfig.getModes().get(TransportMode.pt).getMarginalUtilityOfTraveling() /3600.0 - pcsConfig.getPerforming_utils_hr()/3600. ; @@ -177,11 +177,11 @@ public double getMarginalUtilityOfTravelTimeWalk_utl_s() { public void setMarginalUtilityOfTravelTimePt_utl_s(final double marginalUtilityOfTravelTimeTransit_utl_s) { this.marginalUtilityOfTravelTimeTransit_utl_s = marginalUtilityOfTravelTimeTransit_utl_s; } - + public void setMarginalUtilityOfTravelDistanceWalk_utl_m(final double marginalUtilityOfTravelDistanceWalk_utl_m) { this.marginalUtilityOfTravelDistanceWalk_utl_m = marginalUtilityOfTravelDistanceWalk_utl_m; } - + /** * @return the marginal utility of travel time by public transit. */ @@ -212,7 +212,7 @@ public double getMarginalUtilityOfTravelDistancePt_utl_m() { public double getMarginalUtilityOfTravelDistanceWalk_utl_m() { return this.marginalUtilityOfTravelDistanceWalk_utl_m; } - + public void setBeelineWalkSpeed(final double beelineWalkSpeed) { this.beelineWalkSpeed = beelineWalkSpeed; } diff --git a/matsim/src/main/java/org/matsim/run/Events2Snapshot.java b/matsim/src/main/java/org/matsim/run/Events2Snapshot.java index b62af9d7b2d..c6bee1ead04 100644 --- a/matsim/src/main/java/org/matsim/run/Events2Snapshot.java +++ b/matsim/src/main/java/org/matsim/run/Events2Snapshot.java @@ -35,12 +35,11 @@ import org.matsim.core.gbl.MatsimRandom; import org.matsim.core.network.io.MatsimNetworkReader; import org.matsim.core.scenario.ScenarioUtils; -import org.matsim.core.utils.geometry.transformations.TransformationFactory; import org.matsim.core.utils.misc.ArgumentParser; import org.matsim.vis.snapshotwriters.SnapshotWriter; import org.matsim.vis.snapshotwriters.TransimsSnapshotWriter; -import static org.matsim.core.config.groups.ControlerConfigGroup.*; +import static org.matsim.core.config.groups.ControllerConfigGroup.*; /** * Converts an events file to a snapshot file. @@ -190,7 +189,7 @@ private void prepare() { this.events = EventsUtils.createEventsManager(); // create SnapshotGenerator - this.visualizer = new SnapshotGenerator(this.network, this.config.qsim().getSnapshotPeriod(), + this.visualizer = new SnapshotGenerator(this.network, this.config.qsim().getSnapshotPeriod(), this.config.qsim()); this.events.addHandler(this.visualizer); } diff --git a/matsim/src/main/java/org/matsim/vis/snapshotwriters/SnapshotWritersModule.java b/matsim/src/main/java/org/matsim/vis/snapshotwriters/SnapshotWritersModule.java index 7b9b5d325f3..a21d7196690 100644 --- a/matsim/src/main/java/org/matsim/vis/snapshotwriters/SnapshotWritersModule.java +++ b/matsim/src/main/java/org/matsim/vis/snapshotwriters/SnapshotWritersModule.java @@ -22,7 +22,7 @@ package org.matsim.vis.snapshotwriters; -import org.matsim.core.config.groups.ControlerConfigGroup; +import org.matsim.core.config.groups.ControllerConfigGroup; import org.matsim.core.config.groups.QSimConfigGroup; import org.matsim.core.controler.AbstractModule; import org.matsim.core.mobsim.framework.listeners.MobsimListener; @@ -32,7 +32,7 @@ import jakarta.inject.Provider; import java.util.Collection; -import static org.matsim.core.config.groups.ControlerConfigGroup.SnapshotFormat; +import static org.matsim.core.config.groups.ControllerConfigGroup.SnapshotFormat; public class SnapshotWritersModule extends AbstractModule { @@ -54,23 +54,23 @@ public void install() { private static class SnapshotWriterManagerProvider implements Provider { private final QSimConfigGroup qSimConfigGroup; - private final ControlerConfigGroup controlerConfigGroup; + private final ControllerConfigGroup controllerConfigGroup; private final ReplanningContext iterationContext; private final Collection> snapshotWriters; @Inject - private SnapshotWriterManagerProvider(QSimConfigGroup qSimConfigGroup, ControlerConfigGroup controlerConfigGroup, + private SnapshotWriterManagerProvider(QSimConfigGroup qSimConfigGroup, ControllerConfigGroup controllerConfigGroup, ReplanningContext iterationContext, Collection> snapshotWriters) { this.qSimConfigGroup = qSimConfigGroup; - this.controlerConfigGroup = controlerConfigGroup; + this.controllerConfigGroup = controllerConfigGroup; this.iterationContext = iterationContext; this.snapshotWriters = snapshotWriters; } @Override public MobsimListener get() { - if (iterationContext.getIteration() % controlerConfigGroup.getWriteSnapshotsInterval() == 0) { + if (iterationContext.getIteration() % controllerConfigGroup.getWriteSnapshotsInterval() == 0) { SnapshotWriterManager manager = new SnapshotWriterManager((int) qSimConfigGroup.getSnapshotPeriod(), qSimConfigGroup.getFilterSnapshots()); for (com.google.inject.Provider snapshotWriter : this.snapshotWriters) { manager.addSnapshotWriter(snapshotWriter.get()); diff --git a/matsim/src/main/java/org/matsim/withinday/controller/ExampleWithinDayController.java b/matsim/src/main/java/org/matsim/withinday/controller/ExampleWithinDayController.java index b10d49a5ce8..2eb4470272c 100644 --- a/matsim/src/main/java/org/matsim/withinday/controller/ExampleWithinDayController.java +++ b/matsim/src/main/java/org/matsim/withinday/controller/ExampleWithinDayController.java @@ -31,7 +31,7 @@ import org.matsim.api.core.v01.network.Network; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.ControlerConfigGroup; +import org.matsim.core.config.groups.ControllerConfigGroup; import org.matsim.core.controler.AbstractModule; import org.matsim.core.controler.Controler; import org.matsim.core.controler.events.StartupEvent; @@ -133,7 +133,7 @@ public static void main(final String[] args) { } Config config = ConfigUtils.loadConfig( args[0] , new WithinDayConfigGroup() ) ; - config.controler().setRoutingAlgorithmType( ControlerConfigGroup.RoutingAlgorithmType.Dijkstra ); + config.controler().setRoutingAlgorithmType( ControllerConfigGroup.RoutingAlgorithmType.Dijkstra ); Scenario scenario = ScenarioUtils.loadScenario( config) ; diff --git a/matsim/src/main/java/org/matsim/withinday/trafficmonitoring/WithinDayTravelTimeModule.java b/matsim/src/main/java/org/matsim/withinday/trafficmonitoring/WithinDayTravelTimeModule.java index bf1f154ce59..880d31b6465 100644 --- a/matsim/src/main/java/org/matsim/withinday/trafficmonitoring/WithinDayTravelTimeModule.java +++ b/matsim/src/main/java/org/matsim/withinday/trafficmonitoring/WithinDayTravelTimeModule.java @@ -23,7 +23,7 @@ import jakarta.inject.Singleton; -import org.matsim.core.config.groups.ControlerConfigGroup; +import org.matsim.core.config.groups.ControllerConfigGroup; import org.matsim.core.controler.AbstractModule; public class WithinDayTravelTimeModule extends AbstractModule { @@ -33,7 +33,7 @@ public WithinDayTravelTimeModule() { @Override public void install() { - if (getConfig().controler().getRoutingAlgorithmType() != ControlerConfigGroup.RoutingAlgorithmType.Dijkstra) { + if (getConfig().controler().getRoutingAlgorithmType() != ControllerConfigGroup.RoutingAlgorithmType.Dijkstra) { throw new RuntimeException( "for me, in KNAccidentScenario, this works with Dijkstra (default until spring 2019), and does not work with AStarLandmarks " + "(default afterwards). I have not tried the other routing options, nor have I systematically debugged. KN, feb'19"); diff --git a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/RaptorStopFinderTest.java b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/RaptorStopFinderTest.java index ff34ae992b9..dee5ae97f8f 100644 --- a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/RaptorStopFinderTest.java +++ b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/RaptorStopFinderTest.java @@ -16,7 +16,7 @@ import org.matsim.api.core.v01.population.PlanElement; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; import org.matsim.core.population.routes.NetworkRoute; import org.matsim.core.population.routes.RouteUtils; import org.matsim.core.router.DefaultRoutingRequest; @@ -56,10 +56,10 @@ public class RaptorStopFinderTest { * * This functionality is tested for the two RaptorStopFinders: 1) DefaultStopFinder and 2) RandomAccessEgressModeRaptorStopFinder * For each RaptorStopFinder there is one test where StopFilterAttributes are not used to exlclude stops, and one test - * where StopFilterAttributes are used. + * where StopFilterAttributes are used. */ - - + + @Test public void testDefaultStopFinder_EmptyInitialSearchRadius() { /* General Radius includes no stops. Search_Extension_Radius is 0 @@ -88,9 +88,9 @@ public void testDefaultStopFinder_EmptyInitialSearchRadius() { List legs = raptor.calcRoute(DefaultRoutingRequest.withoutAttributes(this.fromFac, this.toFac, 7 * 3600, f0.dummyPerson)); Assert.assertNull("The router should not find a route and return null, but did return something else.", legs); - + } - + /* General Radius includes stop B. Search_Extension_Radius is 0. Expected: Stop Finder will only find stop B. Lines C, D, and E are set to very fast, so as to check that only stop B is included. @@ -215,9 +215,9 @@ public void testDefaultStopFinder_EmptyInitialSearchRadius_StopFilterAttributes( SwissRailRaptor raptor = new SwissRailRaptor.Builder(data, f0.scenario.getConfig()).with(stopFinder).build(); List legs = raptor.calcRoute(DefaultRoutingRequest.withoutAttributes(this.fromFac, this.toFac, 7 * 3600, f0.dummyPerson)); - + Assert.assertNull("The router should not find a route and return null, but did return something else.", legs); - + } /* General Radius includes stop B. Search_Extension_Radius is 0. @@ -405,9 +405,9 @@ public void testRandomAccessEgressModeRaptorStopFinder_EmptyInitialSearchRadius( List legs = raptor.calcRoute(DefaultRoutingRequest.withoutAttributes(this.fromFac, this.toFac, 7 * 3600, f0.dummyPerson)); Assert.assertNull("The router should not find a route and return null, but did return something else.", legs); - + } - + /* General Radius includes stop B. Search_Extension_Radius is 0. Expected: Stop Finder will only find stop B. Lines C, D, and E are set to very fast, so as to check that only stop B is included. @@ -535,7 +535,7 @@ public void testRandomAccessEgressModeRaptorStopFinder_EmptyInitialSearchRadius_ List legs = raptor.calcRoute(DefaultRoutingRequest.withoutAttributes(this.fromFac, this.toFac, 7 * 3600, f0.dummyPerson)); Assert.assertNull("The router should not find a route and return null, but did return something else.", legs); - + } /* General Radius includes stop B. Search_Extension_Radius is 0. @@ -709,7 +709,7 @@ Initial_Search_Radius includes B (not "walkAccessible") * * This functionality is tested for the two RaptorStopFinders: 1) DefaultStopFinder and 2) RandomAccessEgressModeRaptorStopFinder * For each RaptorStopFinder there is one test where StopFilterAttributes are not used to exlclude stops, and one test - * where StopFilterAttributes are used. + * where StopFilterAttributes are used. */ @Test public void testDefaultStopFinder_HalfFullInitialSearchRadius() { @@ -1213,7 +1213,7 @@ public void testRandomAccessEgressModeRaptorStopFinder_HalfFullInitialSearchRadi * * This functionality is tested for the two RaptorStopFinders: 1) DefaultStopFinder and 2) RandomAccessEgressModeRaptorStopFinder * For each RaptorStopFinder there is one test where StopFilterAttributes are not used to exlclude stops, and one test - * where StopFilterAttributes are used. + * where StopFilterAttributes are used. */ @Test public void testDefaultStopFinder_FullInitialSearchRadius() { @@ -1666,7 +1666,7 @@ public void testDefaultStopFinder_testMultipleModes() { routingModules.put("zoomer", new TeleportationRoutingModule("zoomer", f0.scenario, 1000., 1.)); - PlanCalcScoreConfigGroup.ModeParams modeParams = new PlanCalcScoreConfigGroup.ModeParams("zoomer"); + ScoringConfigGroup.ModeParams modeParams = new ScoringConfigGroup.ModeParams("zoomer"); modeParams.setMarginalUtilityOfTraveling(0.); f0.scenario.getConfig().planCalcScore().addModeParams(modeParams); @@ -1732,7 +1732,7 @@ public void testDefaultStopFinder_testMultipleModes() { routingModules.put("zoomer", new TeleportationRoutingModule("zoomer", f0.scenario, 1000., 1.)); - PlanCalcScoreConfigGroup.ModeParams modeParams = new PlanCalcScoreConfigGroup.ModeParams("zoomer"); + ScoringConfigGroup.ModeParams modeParams = new ScoringConfigGroup.ModeParams("zoomer"); modeParams.setMarginalUtilityOfTraveling(0.); f0.scenario.getConfig().planCalcScore().addModeParams(modeParams); diff --git a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorIntermodalTest.java b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorIntermodalTest.java index 7ec0a2f552c..e920e0ca443 100644 --- a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorIntermodalTest.java +++ b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorIntermodalTest.java @@ -23,7 +23,7 @@ import org.matsim.api.core.v01.population.PopulationFactory; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; import org.matsim.core.population.routes.GenericRouteImpl; import org.matsim.core.population.routes.NetworkRoute; import org.matsim.core.population.routes.RouteUtils; @@ -56,7 +56,7 @@ public class SwissRailRaptorIntermodalTest { public void testIntermodalTrip() { IntermodalFixture f = new IntermodalFixture(); - PlanCalcScoreConfigGroup.ModeParams walk = new PlanCalcScoreConfigGroup.ModeParams(TransportMode.walk); + ScoringConfigGroup.ModeParams walk = new ScoringConfigGroup.ModeParams(TransportMode.walk); walk.setMarginalUtilityOfTraveling(0.0); f.config.planCalcScore().addModeParams(walk); @@ -148,7 +148,7 @@ public void testIntermodalTrip_TripRouterIntegration() { bikeAccess.setStopFilterValue("true"); f.srrConfig.addIntermodalAccessEgress(bikeAccess); - PlanCalcScoreConfigGroup.ModeParams walk = new PlanCalcScoreConfigGroup.ModeParams(TransportMode.walk); + ScoringConfigGroup.ModeParams walk = new ScoringConfigGroup.ModeParams(TransportMode.walk); walk.setMarginalUtilityOfTraveling(0.0); f.config.planCalcScore().addModeParams(walk); @@ -201,7 +201,7 @@ public void testIntermodalTrip_TripRouterIntegration() { public void testIntermodalTrip_walkOnlyNoSubpop() { IntermodalFixture f = new IntermodalFixture(); - PlanCalcScoreConfigGroup.ModeParams walk = new PlanCalcScoreConfigGroup.ModeParams(TransportMode.walk); + ScoringConfigGroup.ModeParams walk = new ScoringConfigGroup.ModeParams(TransportMode.walk); walk.setMarginalUtilityOfTraveling(-8.0); f.config.planCalcScore().addModeParams(walk); @@ -253,7 +253,7 @@ public void testIntermodalTrip_walkOnlyNoSubpop() { public void testIntermodalTrip_withoutPt() { IntermodalFixture f = new IntermodalFixture(); - PlanCalcScoreConfigGroup.ModeParams walk = new PlanCalcScoreConfigGroup.ModeParams(TransportMode.walk); + ScoringConfigGroup.ModeParams walk = new ScoringConfigGroup.ModeParams(TransportMode.walk); walk.setMarginalUtilityOfTraveling(0.0); f.config.planCalcScore().addModeParams(walk); @@ -290,10 +290,10 @@ public void testDirectWalkFactor() { IntermodalFixture f = new IntermodalFixture(); f.config.planCalcScore().setPerforming_utils_hr(6.0); - PlanCalcScoreConfigGroup.ModeParams walk = new PlanCalcScoreConfigGroup.ModeParams(TransportMode.walk); + ScoringConfigGroup.ModeParams walk = new ScoringConfigGroup.ModeParams(TransportMode.walk); walk.setMarginalUtilityOfTraveling(0.0); f.config.planCalcScore().addModeParams(walk); - PlanCalcScoreConfigGroup.ModeParams bike = new PlanCalcScoreConfigGroup.ModeParams("bike"); + ScoringConfigGroup.ModeParams bike = new ScoringConfigGroup.ModeParams("bike"); bike.setMarginalUtilityOfTraveling(0.0); f.config.planCalcScore().addModeParams(bike); @@ -385,7 +385,7 @@ public void testAccessEgressModeFasterThanPt() { */ f.config.transitRouter().setDirectWalkFactor(Double.POSITIVE_INFINITY); - PlanCalcScoreConfigGroup.ModeParams walk = new PlanCalcScoreConfigGroup.ModeParams(TransportMode.walk); + ScoringConfigGroup.ModeParams walk = new ScoringConfigGroup.ModeParams(TransportMode.walk); walk.setMarginalUtilityOfTraveling(0.0); f.config.planCalcScore().addModeParams(walk); @@ -484,7 +484,7 @@ public void testIntermodalTrip_competingAccess() { // which would result in all options having the same cost in the end. f.config.planCalcScore().getModes().get(TransportMode.bike).setMarginalUtilityOfTraveling(-8); - PlanCalcScoreConfigGroup.ModeParams walk = new PlanCalcScoreConfigGroup.ModeParams(TransportMode.walk); + ScoringConfigGroup.ModeParams walk = new ScoringConfigGroup.ModeParams(TransportMode.walk); walk.setMarginalUtilityOfTraveling(-7); f.config.planCalcScore().addModeParams(walk); @@ -579,7 +579,7 @@ public void testIntermodalTrip_RandomAccessEgressModeRaptorStopFinder() { // which would result in all options having the same cost in the end. f.config.planCalcScore().getModes().get(TransportMode.bike).setMarginalUtilityOfTraveling(-8); - PlanCalcScoreConfigGroup.ModeParams walk = new PlanCalcScoreConfigGroup.ModeParams(TransportMode.walk); + ScoringConfigGroup.ModeParams walk = new ScoringConfigGroup.ModeParams(TransportMode.walk); walk.setMarginalUtilityOfTraveling(-7); f.config.planCalcScore().addModeParams(walk); @@ -915,7 +915,7 @@ public List calcRoute(RoutingRequest request) { public void testIntermodalTrip_tripLengthShare() { IntermodalFixture f = new IntermodalFixture(); - PlanCalcScoreConfigGroup.ModeParams walk = new PlanCalcScoreConfigGroup.ModeParams(TransportMode.walk); + ScoringConfigGroup.ModeParams walk = new ScoringConfigGroup.ModeParams(TransportMode.walk); walk.setMarginalUtilityOfTraveling(0.0); f.config.planCalcScore().addModeParams(walk); @@ -985,7 +985,7 @@ public void testIntermodalTrip_activityInteraction() { IntermodalFixture f = new IntermodalFixture(); final Scenario scenario = ScenarioUtils.createScenario( ConfigUtils.createConfig() ); PopulationFactory populationFactory = scenario.getPopulation().getFactory(); - PlanCalcScoreConfigGroup.ModeParams walk = new PlanCalcScoreConfigGroup.ModeParams(TransportMode.walk); + ScoringConfigGroup.ModeParams walk = new ScoringConfigGroup.ModeParams(TransportMode.walk); walk.setMarginalUtilityOfTraveling(0.0); f.config.planCalcScore().addModeParams(walk); @@ -1106,7 +1106,7 @@ public void testIntermodalTrip_activityInteractionAdd() { IntermodalFixture f = new IntermodalFixture(); final Scenario scenario = ScenarioUtils.createScenario( ConfigUtils.createConfig() ); PopulationFactory populationFactory = scenario.getPopulation().getFactory(); - PlanCalcScoreConfigGroup.ModeParams walk = new PlanCalcScoreConfigGroup.ModeParams(TransportMode.walk); + ScoringConfigGroup.ModeParams walk = new ScoringConfigGroup.ModeParams(TransportMode.walk); walk.setMarginalUtilityOfTraveling(0.0); f.config.planCalcScore().addModeParams(walk); @@ -1425,7 +1425,7 @@ public IntermodalTransferFixture() { * Instead of TransportMode.non_network_walk we are now (after the introduction of routing mode) using * TransportMode.walk for access and egress to pt. */ - PlanCalcScoreConfigGroup.ModeParams walk = new PlanCalcScoreConfigGroup.ModeParams(TransportMode.walk); + ScoringConfigGroup.ModeParams walk = new ScoringConfigGroup.ModeParams(TransportMode.walk); walk.setMarginalUtilityOfTraveling(-7); this.config.planCalcScore().addModeParams(walk); diff --git a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorModuleTest.java b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorModuleTest.java index c2a85b66d35..fa2d951a881 100644 --- a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorModuleTest.java +++ b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorModuleTest.java @@ -26,8 +26,8 @@ import org.matsim.api.core.v01.population.PopulationFactory; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; -import org.matsim.core.config.groups.StrategyConfigGroup.StrategySettings; +import org.matsim.core.config.groups.ScoringConfigGroup; +import org.matsim.core.config.groups.ReplanningConfigGroup.StrategySettings; import org.matsim.core.controler.AbstractModule; import org.matsim.core.controler.Controler; import org.matsim.core.controler.OutputDirectoryHierarchy.OverwriteFileSetting; @@ -141,14 +141,14 @@ public void testIntermodalIntegration() { // prepare scoring Config config = f.config; - PlanCalcScoreConfigGroup.ActivityParams homeScoring = new PlanCalcScoreConfigGroup.ActivityParams("home"); + ScoringConfigGroup.ActivityParams homeScoring = new ScoringConfigGroup.ActivityParams("home"); homeScoring.setTypicalDuration(16*3600); f.config.planCalcScore().addActivityParams(homeScoring); - PlanCalcScoreConfigGroup.ActivityParams workScoring = new PlanCalcScoreConfigGroup.ActivityParams("work"); + ScoringConfigGroup.ActivityParams workScoring = new ScoringConfigGroup.ActivityParams("work"); workScoring.setTypicalDuration(8*3600); f.config.planCalcScore().addActivityParams(workScoring); - PlanCalcScoreConfigGroup.ModeParams walk = new PlanCalcScoreConfigGroup.ModeParams(TransportMode.walk); + ScoringConfigGroup.ModeParams walk = new ScoringConfigGroup.ModeParams(TransportMode.walk); walk.setMarginalUtilityOfTraveling(0.0); f.config.planCalcScore().addModeParams(walk); @@ -231,7 +231,7 @@ public void install() { // :-( :-( kai, mar'20) } - + /** * Test update of SwissRailRaptorData after TransitScheduleChangedEvent */ @@ -252,13 +252,13 @@ public void testTransitScheduleUpdate() { plan.addActivity(homeAct); plan.addLeg(pf.createLeg(TransportMode.pt)); plan.addActivity(pf.createActivityFromCoord("work", new Coord(24010, 10000))); - + // prepare scoring Config config = f.config; - PlanCalcScoreConfigGroup.ActivityParams homeScoring = new PlanCalcScoreConfigGroup.ActivityParams("home"); + ScoringConfigGroup.ActivityParams homeScoring = new ScoringConfigGroup.ActivityParams("home"); homeScoring.setTypicalDuration(16*3600); f.config.planCalcScore().addActivityParams(homeScoring); - PlanCalcScoreConfigGroup.ActivityParams workScoring = new PlanCalcScoreConfigGroup.ActivityParams("work"); + ScoringConfigGroup.ActivityParams workScoring = new ScoringConfigGroup.ActivityParams("work"); workScoring.setTypicalDuration(8*3600); f.config.planCalcScore().addActivityParams(workScoring); @@ -288,12 +288,12 @@ public void install() { }); controler.run(); - + // test that swiss rail raptor was used TripRouter tripRouter = controler.getInjector().getInstance(TripRouter.class); RoutingModule module = tripRouter.getRoutingModule(TransportMode.pt); Assert.assertTrue(module instanceof SwissRailRaptorRoutingModule); - + // Check routed plan List planElements = p1.getSelectedPlan().getPlanElements(); for (PlanElement pe : planElements) { @@ -317,13 +317,13 @@ public void install() { Assert.assertEquals(TransportMode.walk, ((Leg) planElements.get(1)).getMode()); Assert.assertEquals(TransportMode.pt, ((Leg) planElements.get(3)).getMode()); Assert.assertEquals(TransportMode.walk, ((Leg) planElements.get(5)).getMode()); - + // Check route: should return one of the added lines although the removed green line would be faster Leg ptLeg = (Leg) planElements.get(3); TransitPassengerRoute ptRoute = (TransitPassengerRoute) ptLeg.getRoute(); - Assert.assertEquals(Id.create("AddedLine" + 1, TransitLine.class), ptRoute.getLineId()); + Assert.assertEquals(Id.create("AddedLine" + 1, TransitLine.class), ptRoute.getLineId()); } - + /** * Test individual scoring parameters for agents */ @@ -431,5 +431,5 @@ private void removeGreenLineAndStop(ControlerEvent event) { } } - + } diff --git a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorTest.java b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorTest.java index 4eb2d0f01c5..cb850cb2235 100644 --- a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorTest.java +++ b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorTest.java @@ -21,8 +21,8 @@ import org.matsim.api.core.v01.population.PlanElement; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup.ModeParams; -import org.matsim.core.config.groups.PlansCalcRouteConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup.ModeParams; +import org.matsim.core.config.groups.RoutingConfigGroup; import org.matsim.core.population.routes.NetworkRoute; import org.matsim.core.population.routes.RouteUtils; import org.matsim.core.router.DefaultRoutingModules; @@ -863,7 +863,7 @@ private Config prepareConfig(double transferFixedCost, double transferRelativeCo config.transitRouter().setDirectWalkFactor(1.0); double beelineDistanceFactor = config.plansCalcRoute().getModeRoutingParams().get( TransportMode.walk ).getBeelineDistanceFactor(); - PlansCalcRouteConfigGroup.TeleportedModeParams walkParameters = new PlansCalcRouteConfigGroup.TeleportedModeParams(TransportMode.walk); + RoutingConfigGroup.TeleportedModeParams walkParameters = new RoutingConfigGroup.TeleportedModeParams(TransportMode.walk); walkParameters.setTeleportedModeSpeed(beelineDistanceFactor); // set it such that the beelineWalkSpeed is exactly 1 config.plansCalcRoute().addParameterSet(walkParameters); @@ -1226,7 +1226,7 @@ private static class TransferFixture { this.config.transitRouter().setMaxBeelineWalkConnectionDistance(100.0); double beelineDistanceFactor = this.config.plansCalcRoute().getModeRoutingParams().get( TransportMode.walk ).getBeelineDistanceFactor(); - PlansCalcRouteConfigGroup.TeleportedModeParams walkParameters = new PlansCalcRouteConfigGroup.TeleportedModeParams(TransportMode.walk); + RoutingConfigGroup.TeleportedModeParams walkParameters = new RoutingConfigGroup.TeleportedModeParams(TransportMode.walk); walkParameters.setTeleportedModeSpeed(beelineDistanceFactor); // set it such that the beelineWalkSpeed is exactly 1 this.config.plansCalcRoute().addParameterSet(walkParameters); diff --git a/matsim/src/test/java/org/matsim/analysis/ModeChoiceCoverageControlerListenerTest.java b/matsim/src/test/java/org/matsim/analysis/ModeChoiceCoverageControlerListenerTest.java index 093aae7460d..051f1485cf6 100644 --- a/matsim/src/test/java/org/matsim/analysis/ModeChoiceCoverageControlerListenerTest.java +++ b/matsim/src/test/java/org/matsim/analysis/ModeChoiceCoverageControlerListenerTest.java @@ -8,9 +8,9 @@ import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.population.*; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.ControlerConfigGroup; -import org.matsim.core.config.groups.ControlerConfigGroup.CompressionType; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; +import org.matsim.core.config.groups.ControllerConfigGroup; +import org.matsim.core.config.groups.ControllerConfigGroup.CompressionType; +import org.matsim.core.config.groups.ScoringConfigGroup; import org.matsim.core.controler.OutputDirectoryHierarchy; import org.matsim.core.controler.OutputDirectoryHierarchy.OverwriteFileSetting; import org.matsim.core.controler.events.IterationEndsEvent; @@ -38,17 +38,17 @@ public class ModeChoiceCoverageControlerListenerTest { public void testChangePlanModes() { Population population = PopulationUtils.createPopulation(ConfigUtils.createConfig()); - PlanCalcScoreConfigGroup scoreConfig = new PlanCalcScoreConfigGroup(); + ScoringConfigGroup scoreConfig = new ScoringConfigGroup(); TransportPlanningMainModeIdentifier transportId = new TransportPlanningMainModeIdentifier(); - ControlerConfigGroup controlerConfigGroup = new ControlerConfigGroup(); + ControllerConfigGroup controllerConfigGroup = new ControllerConfigGroup(); OutputDirectoryHierarchy controlerIO = new OutputDirectoryHierarchy(utils.getOutputDirectory() + "/ModeChoiceCoverageControlerListener", OverwriteFileSetting.overwriteExistingFiles, CompressionType.gzip); Person person = PopulationUtils.getFactory().createPerson(Id.create(1, Person.class)); population.addPerson(person); - ModeChoiceCoverageControlerListener modeCC = new ModeChoiceCoverageControlerListener(controlerConfigGroup, population, controlerIO, scoreConfig, transportId); + ModeChoiceCoverageControlerListener modeCC = new ModeChoiceCoverageControlerListener(controllerConfigGroup, population, controlerIO, scoreConfig, transportId); modeCC.notifyStartup(new StartupEvent(null)); // Iteration 0: walk - walk @@ -95,10 +95,10 @@ public void testChangePlanModes() { @Test public void testTwoAgents() { Population population = PopulationUtils.createPopulation(ConfigUtils.createConfig()); - PlanCalcScoreConfigGroup scoreConfig = new PlanCalcScoreConfigGroup(); + ScoringConfigGroup scoreConfig = new ScoringConfigGroup(); TransportPlanningMainModeIdentifier transportId = new TransportPlanningMainModeIdentifier(); - ControlerConfigGroup controlerConfigGroup = new ControlerConfigGroup(); + ControllerConfigGroup controllerConfigGroup = new ControllerConfigGroup(); OutputDirectoryHierarchy controlerIO = new OutputDirectoryHierarchy(utils.getOutputDirectory() + "/ModeChoiceCoverageControlerListener", OverwriteFileSetting.overwriteExistingFiles, CompressionType.gzip); @@ -108,7 +108,7 @@ public void testTwoAgents() { population.addPerson(person2); - ModeChoiceCoverageControlerListener modeCC = new ModeChoiceCoverageControlerListener(controlerConfigGroup, population, controlerIO, scoreConfig, transportId); + ModeChoiceCoverageControlerListener modeCC = new ModeChoiceCoverageControlerListener(controllerConfigGroup, population, controlerIO, scoreConfig, transportId); modeCC.notifyStartup(new StartupEvent(null)); // Iteration 0: walk - walk @@ -166,17 +166,17 @@ public void testTwoAgents() { public void testDifferentLevels() { Population population = PopulationUtils.createPopulation(ConfigUtils.createConfig()); - PlanCalcScoreConfigGroup scoreConfig = new PlanCalcScoreConfigGroup(); + ScoringConfigGroup scoreConfig = new ScoringConfigGroup(); TransportPlanningMainModeIdentifier transportId = new TransportPlanningMainModeIdentifier(); - ControlerConfigGroup controlerConfigGroup = new ControlerConfigGroup(); + ControllerConfigGroup controllerConfigGroup = new ControllerConfigGroup(); OutputDirectoryHierarchy controlerIO = new OutputDirectoryHierarchy(utils.getOutputDirectory() + "/ModeChoiceCoverageControlerListener", OverwriteFileSetting.overwriteExistingFiles, CompressionType.gzip); Person person = PopulationUtils.getFactory().createPerson(Id.create(1, Person.class)); population.addPerson(person); - ModeChoiceCoverageControlerListener modeCC = new ModeChoiceCoverageControlerListener(controlerConfigGroup, population, controlerIO, scoreConfig, transportId); + ModeChoiceCoverageControlerListener modeCC = new ModeChoiceCoverageControlerListener(controllerConfigGroup, population, controlerIO, scoreConfig, transportId); modeCC.notifyStartup(new StartupEvent(null)); // After 1 iteration @@ -243,4 +243,4 @@ private Plan makePlan( Person person, String modeLeg1, String modeLeg2) { plan.addActivity(act3); return plan; } -} \ No newline at end of file +} diff --git a/matsim/src/test/java/org/matsim/analysis/ModeStatsControlerListenerTest.java b/matsim/src/test/java/org/matsim/analysis/ModeStatsControlerListenerTest.java index ec04b4c6874..cd0201d94d1 100644 --- a/matsim/src/test/java/org/matsim/analysis/ModeStatsControlerListenerTest.java +++ b/matsim/src/test/java/org/matsim/analysis/ModeStatsControlerListenerTest.java @@ -1,5 +1,5 @@ /** - * + * */ package org.matsim.analysis; @@ -23,14 +23,13 @@ import org.matsim.api.core.v01.population.PlanElement; import org.matsim.api.core.v01.population.Population; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.ControlerConfigGroup; -import org.matsim.core.config.groups.ControlerConfigGroup.CompressionType; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup.ModeParams; +import org.matsim.core.config.groups.ControllerConfigGroup; +import org.matsim.core.config.groups.ControllerConfigGroup.CompressionType; +import org.matsim.core.config.groups.ScoringConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup.ModeParams; import org.matsim.core.controler.OutputDirectoryHierarchy; import org.matsim.core.controler.OutputDirectoryHierarchy.OverwriteFileSetting; import org.matsim.core.controler.events.IterationEndsEvent; -import org.matsim.core.controler.events.ShutdownEvent; import org.matsim.core.controler.events.StartupEvent; import org.matsim.core.population.PopulationUtils; import org.matsim.testcases.MatsimTestUtils; @@ -60,7 +59,7 @@ public void testModeStatsControlerListener() { Population population = PopulationUtils.createPopulation(ConfigUtils.createConfig()); final List planElem = new ArrayList(); - PlanCalcScoreConfigGroup scoreConfig = new PlanCalcScoreConfigGroup(); + ScoringConfigGroup scoreConfig = new ScoringConfigGroup(); TransportPlanningMainModeIdentifier transportId = new TransportPlanningMainModeIdentifier(); ModeParams modeParam1 = new ModeParams(TransportMode.walk); ModeParams modeParam2 = new ModeParams(TransportMode.car); @@ -349,14 +348,14 @@ public void testModeStatsControlerListener() { } private void performTest(Population population, TransportPlanningMainModeIdentifier transportId, - PlanCalcScoreConfigGroup scoreConfig, String outputDirectory, List planElem) { + ScoringConfigGroup scoreConfig, String outputDirectory, List planElem) { - ControlerConfigGroup controlerConfigGroup = new ControlerConfigGroup(); + ControllerConfigGroup controllerConfigGroup = new ControllerConfigGroup(); OutputDirectoryHierarchy controlerIO = new OutputDirectoryHierarchy(outputDirectory, OverwriteFileSetting.overwriteExistingFiles, CompressionType.gzip); - controlerConfigGroup.setCreateGraphs(true); - controlerConfigGroup.setFirstIteration(0); - ModeStatsControlerListener modStatListner = new ModeStatsControlerListener(controlerConfigGroup, population, + controllerConfigGroup.setCreateGraphs(true); + controllerConfigGroup.setFirstIteration(0); + ModeStatsControlerListener modStatListner = new ModeStatsControlerListener(controllerConfigGroup, population, controlerIO, scoreConfig, transportId); StartupEvent eventStart = new StartupEvent(null); @@ -373,7 +372,7 @@ private void performTest(Population population, TransportPlanningMainModeIdentif person3modes.forEach((k, v) -> modesIter0.merge(k, v, Integer::sum)); readAndcompareValues(modesIter0, 0); - + //Remove one person population.getPersons().remove(Id.create("2", Person.class)); diff --git a/matsim/src/test/java/org/matsim/analysis/PHbyModeCalculatorTest.java b/matsim/src/test/java/org/matsim/analysis/PHbyModeCalculatorTest.java index ff7ee2442c6..51be57b965e 100644 --- a/matsim/src/test/java/org/matsim/analysis/PHbyModeCalculatorTest.java +++ b/matsim/src/test/java/org/matsim/analysis/PHbyModeCalculatorTest.java @@ -1,5 +1,5 @@ /** - * + * */ package org.matsim.analysis; @@ -19,8 +19,8 @@ import org.matsim.api.core.v01.population.Person; import org.matsim.api.core.v01.population.Plan; import org.matsim.api.core.v01.population.PlanElement; -import org.matsim.core.config.groups.ControlerConfigGroup; -import org.matsim.core.config.groups.ControlerConfigGroup.CompressionType; +import org.matsim.core.config.groups.ControllerConfigGroup; +import org.matsim.core.config.groups.ControllerConfigGroup.CompressionType; import org.matsim.core.controler.OutputDirectoryHierarchy; import org.matsim.core.controler.OutputDirectoryHierarchy.OverwriteFileSetting; import org.matsim.core.router.StageActivityTypeIdentifier; @@ -38,7 +38,7 @@ public class PHbyModeCalculatorTest { private int walk_travel; private int pt_wait; private int stageActivity_wait; - + Id person1 = Id.create("person1", Person.class); Id person2 = Id.create("person2", Person.class); @@ -86,18 +86,18 @@ public void testPKMbyModeCalculator() { private void performTest(IdMap map, String outputDirectory) { - ControlerConfigGroup controlerConfigGroup = new ControlerConfigGroup(); + ControllerConfigGroup controllerConfigGroup = new ControllerConfigGroup(); OutputDirectoryHierarchy controlerIO = new OutputDirectoryHierarchy(outputDirectory, OverwriteFileSetting.overwriteExistingFiles, CompressionType.gzip); - controlerConfigGroup.setCreateGraphs(true); - controlerConfigGroup.setFirstIteration(0); - controlerConfigGroup.setLastIteration(10); - PHbyModeCalculator phbyModeCalculator = new PHbyModeCalculator(controlerConfigGroup, controlerIO); + controllerConfigGroup.setCreateGraphs(true); + controllerConfigGroup.setFirstIteration(0); + controllerConfigGroup.setLastIteration(10); + PHbyModeCalculator phbyModeCalculator = new PHbyModeCalculator(controllerConfigGroup, controlerIO); phbyModeCalculator.addIteration(1, map); phbyModeCalculator.writeOutput(); readAndValidateValues(1, map); - + // removing person 2 map.remove(person2); phbyModeCalculator.addIteration(2, map); @@ -145,7 +145,7 @@ private void readAndValidateValues(int itr, IdMap map) { .getAttribute(EventsToLegs.ENTER_VEHICLE_TIME_ATTRIBUTE_NAME) - ((Leg) elem).getDepartureTime().seconds(); modeValues.put("pt_wait", wait_value); } - + }else if(elem instanceof Activity) { Activity act = (Activity) elem; if (StageActivityTypeIdentifier.isStageActivity(act.getType())) { @@ -218,11 +218,11 @@ private void decideColumns(String[] columnNames) { case "walk_travel": walk_travel = i; break; - + case "pt_wait": pt_wait = i; break; - + case "stageActivity_wait": stageActivity_wait = i; break; diff --git a/matsim/src/test/java/org/matsim/analysis/PKMbyModeCalculatorTest.java b/matsim/src/test/java/org/matsim/analysis/PKMbyModeCalculatorTest.java index 648fda65cd8..b516327d3c3 100644 --- a/matsim/src/test/java/org/matsim/analysis/PKMbyModeCalculatorTest.java +++ b/matsim/src/test/java/org/matsim/analysis/PKMbyModeCalculatorTest.java @@ -1,5 +1,5 @@ /** - * + * */ package org.matsim.analysis; @@ -17,8 +17,8 @@ import org.matsim.api.core.v01.population.Leg; import org.matsim.api.core.v01.population.Person; import org.matsim.api.core.v01.population.Plan; -import org.matsim.core.config.groups.ControlerConfigGroup; -import org.matsim.core.config.groups.ControlerConfigGroup.CompressionType; +import org.matsim.core.config.groups.ControllerConfigGroup; +import org.matsim.core.config.groups.ControllerConfigGroup.CompressionType; import org.matsim.core.controler.OutputDirectoryHierarchy; import org.matsim.core.controler.OutputDirectoryHierarchy.OverwriteFileSetting; import org.matsim.core.population.PopulationUtils; @@ -51,7 +51,7 @@ public void testPKMbyModeCalculator() { /**************************** * Person - creating person 1 ************************************/ - + Plan plan = plans.createPlanOne(); // counting the total distance traveled in each mode @@ -153,13 +153,13 @@ public void testPKMbyModeCalculator() { private void performTest(IdMap map, HashMap modeCalcDist, String outputDirectory) { - ControlerConfigGroup controlerConfigGroup = new ControlerConfigGroup(); + ControllerConfigGroup controllerConfigGroup = new ControllerConfigGroup(); OutputDirectoryHierarchy controlerIO = new OutputDirectoryHierarchy(outputDirectory, OverwriteFileSetting.overwriteExistingFiles, CompressionType.gzip); - controlerConfigGroup.setCreateGraphs(true); - controlerConfigGroup.setFirstIteration(0); - controlerConfigGroup.setLastIteration(10); - PKMbyModeCalculator pkmbyModeCalculator = new PKMbyModeCalculator(controlerConfigGroup, controlerIO); + controllerConfigGroup.setCreateGraphs(true); + controllerConfigGroup.setFirstIteration(0); + controllerConfigGroup.setLastIteration(10); + PKMbyModeCalculator pkmbyModeCalculator = new PKMbyModeCalculator(controllerConfigGroup, controlerIO); // iteration 0 pkmbyModeCalculator.addIteration(0, map); pkmbyModeCalculator.writeOutput(); diff --git a/matsim/src/test/java/org/matsim/analysis/ScoreStatsControlerListenerTest.java b/matsim/src/test/java/org/matsim/analysis/ScoreStatsControlerListenerTest.java index 6d944d4de95..ae2fd2e7596 100644 --- a/matsim/src/test/java/org/matsim/analysis/ScoreStatsControlerListenerTest.java +++ b/matsim/src/test/java/org/matsim/analysis/ScoreStatsControlerListenerTest.java @@ -20,8 +20,8 @@ import org.matsim.api.core.v01.population.Population; import org.matsim.api.core.v01.population.Route; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.ControlerConfigGroup; -import org.matsim.core.config.groups.ControlerConfigGroup.CompressionType; +import org.matsim.core.config.groups.ControllerConfigGroup; +import org.matsim.core.config.groups.ControllerConfigGroup.CompressionType; import org.matsim.core.controler.OutputDirectoryHierarchy; import org.matsim.core.controler.OutputDirectoryHierarchy.OverwriteFileSetting; import org.matsim.core.controler.events.IterationEndsEvent; @@ -474,13 +474,13 @@ public void testScoreStatsControlerListner() throws IOException { private void performTest(String outputDirectory, Population population) throws IOException { - ControlerConfigGroup controlerConfigGroup = new ControlerConfigGroup(); + ControllerConfigGroup controllerConfigGroup = new ControllerConfigGroup(); OutputDirectoryHierarchy controlerIO = new OutputDirectoryHierarchy(outputDirectory, OverwriteFileSetting.overwriteExistingFiles, CompressionType.gzip); - controlerConfigGroup.setCreateGraphs(true); - controlerConfigGroup.setFirstIteration(0); - controlerConfigGroup.setLastIteration(10); - ScoreStatsControlerListener scoreStatsControlerListener = new ScoreStatsControlerListener(controlerConfigGroup, population, controlerIO, null, null); + controllerConfigGroup.setCreateGraphs(true); + controllerConfigGroup.setFirstIteration(0); + controllerConfigGroup.setLastIteration(10); + ScoreStatsControlerListener scoreStatsControlerListener = new ScoreStatsControlerListener(controllerConfigGroup, population, controlerIO, null, null); String outDir = utils.getOutputDirectory() + "/ScoreStatsControlerListener"; diff --git a/matsim/src/test/java/org/matsim/analysis/TravelDistanceStatsTest.java b/matsim/src/test/java/org/matsim/analysis/TravelDistanceStatsTest.java index 1c1897c8bac..627ba72c840 100644 --- a/matsim/src/test/java/org/matsim/analysis/TravelDistanceStatsTest.java +++ b/matsim/src/test/java/org/matsim/analysis/TravelDistanceStatsTest.java @@ -1,5 +1,5 @@ /** - * + * */ package org.matsim.analysis; @@ -21,8 +21,8 @@ import org.matsim.api.core.v01.population.Person; import org.matsim.api.core.v01.population.Plan; import org.matsim.api.core.v01.population.Route; -import org.matsim.core.config.groups.ControlerConfigGroup; -import org.matsim.core.config.groups.ControlerConfigGroup.CompressionType; +import org.matsim.core.config.groups.ControllerConfigGroup; +import org.matsim.core.config.groups.ControllerConfigGroup.CompressionType; import org.matsim.core.controler.OutputDirectoryHierarchy; import org.matsim.core.controler.OutputDirectoryHierarchy.OverwriteFileSetting; import org.matsim.core.population.PopulationUtils; @@ -336,13 +336,13 @@ public void testTravelDistanceStats() { private void performTest(IdMap map, String outputDirectory) { - ControlerConfigGroup controlerConfigGroup = new ControlerConfigGroup(); + ControllerConfigGroup controllerConfigGroup = new ControllerConfigGroup(); OutputDirectoryHierarchy controlerIO = new OutputDirectoryHierarchy(outputDirectory, OverwriteFileSetting.overwriteExistingFiles, CompressionType.gzip); - controlerConfigGroup.setCreateGraphs(true); - controlerConfigGroup.setFirstIteration(0); - controlerConfigGroup.setLastIteration(10); - TravelDistanceStats travelDistanceStats = new TravelDistanceStats(controlerConfigGroup, controlerIO); + controllerConfigGroup.setCreateGraphs(true); + controllerConfigGroup.setFirstIteration(0); + controllerConfigGroup.setLastIteration(10); + TravelDistanceStats travelDistanceStats = new TravelDistanceStats(controllerConfigGroup, controlerIO); travelDistanceStats.addIteration(0, map); readAndValidateValues(0, person1legsum + person2legsum + person3legsum, 12, person1TotalNumberOfLegs + person2TotalNumberOfLegs + person3TotalNumberOfLegs); diff --git a/matsim/src/test/java/org/matsim/core/config/ConfigReaderMatsimV2Test.java b/matsim/src/test/java/org/matsim/core/config/ConfigReaderMatsimV2Test.java index 1e157d3bc05..5acc3a3d142 100644 --- a/matsim/src/test/java/org/matsim/core/config/ConfigReaderMatsimV2Test.java +++ b/matsim/src/test/java/org/matsim/core/config/ConfigReaderMatsimV2Test.java @@ -2,7 +2,7 @@ import org.junit.Assert; import org.junit.Test; -import org.matsim.core.config.groups.ControlerConfigGroup; +import org.matsim.core.config.groups.ControllerConfigGroup; import java.io.ByteArrayInputStream; import java.nio.charset.StandardCharsets; @@ -30,7 +30,7 @@ public void testModuleNameAlias() { """; ByteArrayInputStream bais = new ByteArrayInputStream(xml.getBytes(StandardCharsets.UTF_8)); - r2.addAlias("theController", ControlerConfigGroup.GROUP_NAME); + r2.addAlias("theController", ControllerConfigGroup.GROUP_NAME); r2.readStream(bais); Assert.assertEquals(27, config.controler().getLastIteration()); @@ -74,7 +74,7 @@ public void testModuleAndParamNameAlias() { """; ByteArrayInputStream bais = new ByteArrayInputStream(xml.getBytes(StandardCharsets.UTF_8)); - r2.addAlias("theController", ControlerConfigGroup.GROUP_NAME); + r2.addAlias("theController", ControllerConfigGroup.GROUP_NAME); r2.addAlias("theLastIteration", "lastIteration"); r2.readStream(bais); diff --git a/matsim/src/test/java/org/matsim/core/config/consistency/ConfigConsistencyCheckerImplTest.java b/matsim/src/test/java/org/matsim/core/config/consistency/ConfigConsistencyCheckerImplTest.java index 60ed86ec921..34b8461e6d7 100644 --- a/matsim/src/test/java/org/matsim/core/config/consistency/ConfigConsistencyCheckerImplTest.java +++ b/matsim/src/test/java/org/matsim/core/config/consistency/ConfigConsistencyCheckerImplTest.java @@ -25,7 +25,7 @@ import org.matsim.api.core.v01.TransportMode; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup.ActivityParams; +import org.matsim.core.config.groups.ScoringConfigGroup.ActivityParams; import org.matsim.pt.PtConstants; import org.matsim.testcases.utils.LogCounter; @@ -124,7 +124,7 @@ public void testCheckPlanCalcScore_TravelingWalk() { logger.deactivate(); } } - + @Test public void testCheckPlanCalcScore_PtInteractionActivity() { Config config = new Config(); @@ -138,18 +138,18 @@ public void testCheckPlanCalcScore_PtInteractionActivity() { ConfigConsistencyCheckerImpl.checkPlanCalcScore(config); Assert.assertEquals(0,1) ; // should never get here } catch ( Exception ee ){ - + System.out.println("expected exception") ; } - + config.vspExperimental().setAbleToOverwritePtInteractionParams(true) ; - + try { ConfigConsistencyCheckerImpl.checkPlanCalcScore(config ); } catch ( Exception ee ){ Assert.assertEquals(0,1) ; // should never get here } - + } diff --git a/matsim/src/test/java/org/matsim/core/config/groups/ControlerConfigGroupTest.java b/matsim/src/test/java/org/matsim/core/config/groups/ControllerConfigGroupTest.java similarity index 77% rename from matsim/src/test/java/org/matsim/core/config/groups/ControlerConfigGroupTest.java rename to matsim/src/test/java/org/matsim/core/config/groups/ControllerConfigGroupTest.java index 4b479ad330c..a1c50b1d46f 100644 --- a/matsim/src/test/java/org/matsim/core/config/groups/ControlerConfigGroupTest.java +++ b/matsim/src/test/java/org/matsim/core/config/groups/ControllerConfigGroupTest.java @@ -25,9 +25,9 @@ import org.junit.Assert; import org.junit.Test; -import org.matsim.core.config.groups.ControlerConfigGroup.EventsFileFormat; +import org.matsim.core.config.groups.ControllerConfigGroup.EventsFileFormat; -public class ControlerConfigGroupTest { +public class ControllerConfigGroupTest { /** * Ensure that the events-file-format is correctly stored @@ -37,46 +37,46 @@ public class ControlerConfigGroupTest { */ @Test public void testEventsFileFormat() { - ControlerConfigGroup cg = new ControlerConfigGroup(); + ControllerConfigGroup cg = new ControllerConfigGroup(); Set formats; // test initial value formats = cg.getEventsFileFormats(); Assert.assertEquals(1, formats.size()); Assert.assertTrue(formats.contains(EventsFileFormat.xml)); - Assert.assertEquals("xml", cg.getValue(ControlerConfigGroup.EVENTS_FILE_FORMAT)); + Assert.assertEquals("xml", cg.getValue(ControllerConfigGroup.EVENTS_FILE_FORMAT)); // test setting with setEventsFileFormat cg.setEventsFileFormats(EnumSet.of(EventsFileFormat.xml)); formats = cg.getEventsFileFormats(); Assert.assertEquals(1, formats.size()); Assert.assertTrue(formats.contains(EventsFileFormat.xml)); - Assert.assertEquals("xml", cg.getValue(ControlerConfigGroup.EVENTS_FILE_FORMAT)); + Assert.assertEquals("xml", cg.getValue(ControllerConfigGroup.EVENTS_FILE_FORMAT)); // test setting to none cg.setEventsFileFormats(EnumSet.noneOf(EventsFileFormat.class)); formats = cg.getEventsFileFormats(); Assert.assertEquals(0, formats.size()); - Assert.assertEquals("", cg.getValue(ControlerConfigGroup.EVENTS_FILE_FORMAT)); + Assert.assertEquals("", cg.getValue(ControllerConfigGroup.EVENTS_FILE_FORMAT)); // test setting with addParam - cg.addParam(ControlerConfigGroup.EVENTS_FILE_FORMAT, "xml"); + cg.addParam(ControllerConfigGroup.EVENTS_FILE_FORMAT, "xml"); formats = cg.getEventsFileFormats(); Assert.assertEquals(1, formats.size()); Assert.assertTrue(formats.contains(EventsFileFormat.xml)); - Assert.assertEquals("xml", cg.getValue(ControlerConfigGroup.EVENTS_FILE_FORMAT)); + Assert.assertEquals("xml", cg.getValue(ControllerConfigGroup.EVENTS_FILE_FORMAT)); // test setting to none - cg.addParam(ControlerConfigGroup.EVENTS_FILE_FORMAT, ""); + cg.addParam(ControllerConfigGroup.EVENTS_FILE_FORMAT, ""); formats = cg.getEventsFileFormats(); Assert.assertEquals(0, formats.size()); - Assert.assertEquals("", cg.getValue(ControlerConfigGroup.EVENTS_FILE_FORMAT)); + Assert.assertEquals("", cg.getValue(ControllerConfigGroup.EVENTS_FILE_FORMAT)); // test setting with non-conform formatting - cg.addParam(ControlerConfigGroup.EVENTS_FILE_FORMAT, " xml\t\t "); + cg.addParam(ControllerConfigGroup.EVENTS_FILE_FORMAT, " xml\t\t "); formats = cg.getEventsFileFormats(); Assert.assertEquals(1, formats.size()); Assert.assertTrue(formats.contains(EventsFileFormat.xml)); - Assert.assertEquals("xml", cg.getValue(ControlerConfigGroup.EVENTS_FILE_FORMAT)); + Assert.assertEquals("xml", cg.getValue(ControllerConfigGroup.EVENTS_FILE_FORMAT)); // test setting to non-conform none - cg.addParam(ControlerConfigGroup.EVENTS_FILE_FORMAT, " \t "); + cg.addParam(ControllerConfigGroup.EVENTS_FILE_FORMAT, " \t "); formats = cg.getEventsFileFormats(); Assert.assertEquals(0, formats.size()); - Assert.assertEquals("", cg.getValue(ControlerConfigGroup.EVENTS_FILE_FORMAT)); + Assert.assertEquals("", cg.getValue(ControllerConfigGroup.EVENTS_FILE_FORMAT)); } /** @@ -87,18 +87,18 @@ public void testEventsFileFormat() { */ @Test public void testMobsim() { - ControlerConfigGroup cg = new ControlerConfigGroup(); + ControllerConfigGroup cg = new ControllerConfigGroup(); // test initial value Assert.assertEquals("qsim", cg.getMobsim()); - Assert.assertEquals("qsim", cg.getValue(ControlerConfigGroup.MOBSIM)); + Assert.assertEquals("qsim", cg.getValue(ControllerConfigGroup.MOBSIM)); // test setting to null cg.setMobsim(null); Assert.assertNull(cg.getMobsim()); - Assert.assertNull(cg.getValue(ControlerConfigGroup.MOBSIM)); + Assert.assertNull(cg.getValue(ControllerConfigGroup.MOBSIM)); // test setting with addParam - cg.addParam(ControlerConfigGroup.MOBSIM, "queueSimulation"); + cg.addParam(ControllerConfigGroup.MOBSIM, "queueSimulation"); Assert.assertEquals("queueSimulation", cg.getMobsim()); - Assert.assertEquals("queueSimulation", cg.getValue(ControlerConfigGroup.MOBSIM)); + Assert.assertEquals("queueSimulation", cg.getValue(ControllerConfigGroup.MOBSIM)); } /** @@ -109,7 +109,7 @@ public void testMobsim() { */ @Test public void testWritePlansInterval() { - ControlerConfigGroup cg = new ControlerConfigGroup(); + ControllerConfigGroup cg = new ControllerConfigGroup(); // test initial value Assert.assertEquals(50, cg.getWritePlansInterval()); // test setting with setMobsim @@ -121,12 +121,12 @@ public void testWritePlansInterval() { } /** - * Ensure that the enableLinkToLinkRouting value is correctly stored and + * Ensure that the enableLinkToLinkRouting value is correctly stored and * returned with the getters and setters. */ @Test public void testLink2LinkRouting(){ - ControlerConfigGroup cg = new ControlerConfigGroup(); + ControllerConfigGroup cg = new ControllerConfigGroup(); //initial value Assert.assertFalse(cg.isLinkToLinkRoutingEnabled()); //modify by string @@ -144,12 +144,12 @@ public void testLink2LinkRouting(){ } /** - * Ensure that the writeSnapshotsInterval value is correctly stored and + * Ensure that the writeSnapshotsInterval value is correctly stored and * returned with the getters and setters. */ @Test public void testWriteSnapshotInterval(){ - ControlerConfigGroup cg = new ControlerConfigGroup(); + ControllerConfigGroup cg = new ControllerConfigGroup(); //initial value Assert.assertEquals(1, cg.getWriteSnapshotsInterval()); //modify by string @@ -161,5 +161,5 @@ public void testWriteSnapshotInterval(){ Assert.assertEquals(42, cg.getWriteSnapshotsInterval()); } - + } diff --git a/matsim/src/test/java/org/matsim/core/config/groups/StrategyConfigGroupTest.java b/matsim/src/test/java/org/matsim/core/config/groups/ReplanningConfigGroupTest.java similarity index 92% rename from matsim/src/test/java/org/matsim/core/config/groups/StrategyConfigGroupTest.java rename to matsim/src/test/java/org/matsim/core/config/groups/ReplanningConfigGroupTest.java index 42d60cd29ed..bbc2fab6a94 100644 --- a/matsim/src/test/java/org/matsim/core/config/groups/StrategyConfigGroupTest.java +++ b/matsim/src/test/java/org/matsim/core/config/groups/ReplanningConfigGroupTest.java @@ -35,17 +35,17 @@ import org.matsim.core.config.ConfigUtils; import org.matsim.core.config.ConfigWriter; import org.matsim.core.config.ConfigReader; -import org.matsim.core.config.groups.StrategyConfigGroup.StrategySettings; +import org.matsim.core.config.groups.ReplanningConfigGroup.StrategySettings; import org.matsim.testcases.MatsimTestUtils; /** - * Test for {@link StrategyConfigGroup}. + * Test for {@link ReplanningConfigGroup}. * * @author mrieser */ -public class StrategyConfigGroupTest { +public class ReplanningConfigGroupTest { - private static final Logger log = LogManager.getLogger(StrategyConfigGroupTest.class); + private static final Logger log = LogManager.getLogger(ReplanningConfigGroupTest.class); @Rule public final MatsimTestUtils utils = new MatsimTestUtils(); @@ -56,7 +56,7 @@ public class StrategyConfigGroupTest { */ @Test public void testParamNames() { - StrategyConfigGroup configGroup = new StrategyConfigGroup(); + ReplanningConfigGroup configGroup = new ReplanningConfigGroup(); configGroup.addParam("maxAgentPlanMemorySize", "3"); configGroup.addParam("Module_1", "ReRoute"); configGroup.addParam("ModuleProbability_1", "0.5"); @@ -81,7 +81,7 @@ public void testParamNames() { @Test public void testCheckConsistency() { // start with a simple configuration with exactly one module defined - StrategyConfigGroup configGroup = new StrategyConfigGroup(); + ReplanningConfigGroup configGroup = new ReplanningConfigGroup(); configGroup.addParam("maxAgentPlanMemorySize", "3"); configGroup.addParam("Module_1", "ReRoute"); configGroup.addParam("ModuleProbability_1", "0.5"); @@ -149,7 +149,7 @@ public void testCheckConsistency() { @Test public void testIOWithFormatChange() { - final StrategyConfigGroup initialGroup = createTestConfigGroup(); + final ReplanningConfigGroup initialGroup = createTestConfigGroup(); final String v1path = utils.getOutputDirectory() + "/configv1_out.xml"; final Config configV1 = new Config(); @@ -174,8 +174,8 @@ public void testIOWithFormatChange() { private void assertIdentical( final String msg, - final StrategyConfigGroup initialGroup, - final StrategyConfigGroup inputConfigGroup) { + final ReplanningConfigGroup initialGroup, + final ReplanningConfigGroup inputConfigGroup) { assertEquals( "wrong config template for "+msg, initialGroup.getExternalExeConfigTemplate(), @@ -213,10 +213,10 @@ private void assertIdentical( inputConfigGroup.getStrategySettings().size() ); } - private ConfigGroup toUnderscoredModule(final StrategyConfigGroup initialGroup) { + private ConfigGroup toUnderscoredModule(final ReplanningConfigGroup initialGroup) { // yyyy is this method/this execution path still necessary? Maybe we need to be able to read config v1, but certainly // we don't need to WRITE it, do we? kai/mz, nov'15 - + final ConfigGroup module = new ConfigGroup( initialGroup.getName() ); for ( Map.Entry e : initialGroup.getParams().entrySet() ) { @@ -236,8 +236,8 @@ private ConfigGroup toUnderscoredModule(final StrategyConfigGroup initialGroup) return module; } - private StrategyConfigGroup createTestConfigGroup() { - final StrategyConfigGroup group = new StrategyConfigGroup(); + private ReplanningConfigGroup createTestConfigGroup() { + final ReplanningConfigGroup group = new ReplanningConfigGroup(); group.setExternalExeConfigTemplate( "bwark" ); group.setExternalExeTimeOut( 999 ); group.setExternalExeTmpFileRootDir( "some/random/location" ); diff --git a/matsim/src/test/java/org/matsim/core/config/groups/PlansCalcRouteConfigGroupTest.java b/matsim/src/test/java/org/matsim/core/config/groups/RoutingConfigGroupTest.java similarity index 88% rename from matsim/src/test/java/org/matsim/core/config/groups/PlansCalcRouteConfigGroupTest.java rename to matsim/src/test/java/org/matsim/core/config/groups/RoutingConfigGroupTest.java index 86847b25448..813154b79f3 100644 --- a/matsim/src/test/java/org/matsim/core/config/groups/PlansCalcRouteConfigGroupTest.java +++ b/matsim/src/test/java/org/matsim/core/config/groups/RoutingConfigGroupTest.java @@ -33,11 +33,11 @@ import org.matsim.core.config.ConfigUtils; import org.matsim.core.config.ConfigWriter; import org.matsim.core.config.ConfigReader; -import org.matsim.core.config.groups.PlansCalcRouteConfigGroup.TeleportedModeParams; +import org.matsim.core.config.groups.RoutingConfigGroup.TeleportedModeParams; import org.matsim.testcases.MatsimTestUtils; -public class PlansCalcRouteConfigGroupTest { - private final static Logger log = LogManager.getLogger(PlansCalcRouteConfigGroupTest.class); +public class RoutingConfigGroupTest { + private final static Logger log = LogManager.getLogger(RoutingConfigGroupTest.class); private final static int N_MODE_ROUTING_PARAMS_DEFAULT = 5 ; @Rule @@ -49,7 +49,7 @@ public void testAddModeParamsTwice() { final String filename = outdir + "config.xml"; { Config config = ConfigUtils.createConfig(); - PlansCalcRouteConfigGroup group = config.plansCalcRoute(); + RoutingConfigGroup group = config.plansCalcRoute(); Assert.assertEquals( N_MODE_ROUTING_PARAMS_DEFAULT, group.getModeRoutingParams().size() ); group.clearModeRoutingParams(); // group.setTeleportedModeSpeed( TransportMode.bike, 1. ); @@ -63,7 +63,7 @@ public void testAddModeParamsTwice() { } { Config config = ConfigUtils.loadConfig( filename ) ; - PlansCalcRouteConfigGroup group = config.plansCalcRoute(); + RoutingConfigGroup group = config.plansCalcRoute(); Assert.assertEquals( 0, group.getModeRoutingParams().size() ); } } @@ -73,7 +73,7 @@ public void testClearParamsWriteRead() { final String filename = outdir + "config.xml"; { Config config = ConfigUtils.createConfig(); - PlansCalcRouteConfigGroup group = config.plansCalcRoute(); + RoutingConfigGroup group = config.plansCalcRoute(); Assert.assertEquals( N_MODE_ROUTING_PARAMS_DEFAULT, group.getModeRoutingParams().size() ); group.clearModeRoutingParams(); group.setTeleportedModeSpeed( TransportMode.bike, 1. ); @@ -87,7 +87,7 @@ public void testClearParamsWriteRead() { } { Config config = ConfigUtils.loadConfig( filename ) ; - PlansCalcRouteConfigGroup group = config.plansCalcRoute(); + RoutingConfigGroup group = config.plansCalcRoute(); Assert.assertEquals( 0, group.getModeRoutingParams().size() ); } } @@ -97,7 +97,7 @@ public void testRemoveParamsWriteRead() { final String filename = outdir + "config.xml"; { Config config = ConfigUtils.createConfig(); - PlansCalcRouteConfigGroup group = config.plansCalcRoute(); + RoutingConfigGroup group = config.plansCalcRoute(); Assert.assertEquals( N_MODE_ROUTING_PARAMS_DEFAULT, group.getModeRoutingParams().size() ); group.setTeleportedModeSpeed( TransportMode.bike, 1. ); Assert.assertEquals( 1, group.getModeRoutingParams().size() ); @@ -112,14 +112,14 @@ public void testRemoveParamsWriteRead() { } { Config config = ConfigUtils.loadConfig( filename ) ; - PlansCalcRouteConfigGroup group = config.plansCalcRoute(); + RoutingConfigGroup group = config.plansCalcRoute(); Assert.assertEquals( 0, group.getModeRoutingParams().size() ); } } @Test public void testClearDefaults() { Config config = ConfigUtils.createConfig( ) ; - PlansCalcRouteConfigGroup group = config.plansCalcRoute() ; + RoutingConfigGroup group = config.plansCalcRoute() ; Assert.assertEquals( N_MODE_ROUTING_PARAMS_DEFAULT, group.getModeRoutingParams().size() ); group.setTeleportedModeSpeed( "def", 1. ); Assert.assertEquals( 1, group.getModeRoutingParams().size() ); @@ -131,20 +131,20 @@ public void testClearDefaults() { @Test public void test3() { Config config = ConfigUtils.createConfig( ) ; - PlansCalcRouteConfigGroup group = config.plansCalcRoute() ; + RoutingConfigGroup group = config.plansCalcRoute() ; group.clearModeRoutingParams(); group.setClearingDefaultModeRoutingParams( true ); // should be ok } @Test( expected = RuntimeException.class ) public void testInconsistencyBetweenActionAndState() { - PlansCalcRouteConfigGroup group = new PlansCalcRouteConfigGroup() ; + RoutingConfigGroup group = new RoutingConfigGroup() ; group.clearModeRoutingParams(); group.setClearingDefaultModeRoutingParams( false ); // should fail } @Test public void testBackwardsCompatibility() { - PlansCalcRouteConfigGroup group = new PlansCalcRouteConfigGroup(); + RoutingConfigGroup group = new RoutingConfigGroup(); // test default Assert.assertEquals("different default than expected.", 3.0 / 3.6, group.getTeleportedModeSpeeds().get(TransportMode.walk), MatsimTestUtils.EPSILON); @@ -162,7 +162,7 @@ public void testBackwardsCompatibility() { @Test public void testDefaultsAreCleared() { - PlansCalcRouteConfigGroup group = new PlansCalcRouteConfigGroup(); + RoutingConfigGroup group = new RoutingConfigGroup(); // group.clearModeRoutingParams(); group.setTeleportedModeSpeed( "skateboard" , 20 / 3.6 ); group.setTeleportedModeSpeed( "longboard" , 20 / 3.6 ); @@ -173,9 +173,9 @@ public void testDefaultsAreCleared() { } @Test - public void testIODifferentVersions() + public void testIODifferentVersions() { - final PlansCalcRouteConfigGroup initialGroup = createTestConfigGroup(); + final RoutingConfigGroup initialGroup = createTestConfigGroup(); log.info( "constructing new config ..."); final Config configV1 = new Config(); @@ -209,7 +209,7 @@ public void testIODifferentVersions() assertIdentical("re-read v2", initialGroup, configV2.plansCalcRoute()); } - + @Test( expected=RuntimeException.class ) public void testConsistencyCheckIfNoTeleportedSpeed() { final Config config = ConfigUtils.createConfig(); @@ -237,8 +237,8 @@ public void testCannotAddFactorAfterSpeed() { private static void assertIdentical( final String msg, - final PlansCalcRouteConfigGroup initialGroup, - final PlansCalcRouteConfigGroup inputConfigGroup) { + final RoutingConfigGroup initialGroup, + final RoutingConfigGroup inputConfigGroup) { Assert.assertEquals( "unexpected beelineDistanceFactor", // initialGroup.getBeelineDistanceFactor(), @@ -260,14 +260,14 @@ private static void assertIdentical( inputConfigGroup.getTeleportedModeSpeeds() ); } - private static ConfigGroup toUnderscoredModule(final PlansCalcRouteConfigGroup initialGroup) { + private static ConfigGroup toUnderscoredModule(final RoutingConfigGroup initialGroup) { final ConfigGroup module = new ConfigGroup( initialGroup.getName() ); for ( Map.Entry e : initialGroup.getParams().entrySet() ) { log.info( "add param="+e.getKey() + " with value=" + e.getValue() ); module.addParam( e.getKey() , e.getValue() ); } - + for ( TeleportedModeParams settings : initialGroup.getModeRoutingParams().values() ) { final String mode = settings.getMode(); module.addParam( "teleportedModeSpeed_"+mode , ""+settings.getTeleportedModeSpeed() ); @@ -283,23 +283,23 @@ private static ConfigGroup toUnderscoredModule(final PlansCalcRouteConfigGroup i } else if ( !settings.getBeelineDistanceFactor().equals( val ) ) { throw new RuntimeException( "beeline distance factor varies by mode; this cannot be covered by this test" ) ; } - } + } module.addParam( "beelineDistanceFactor", ""+val ); - + return module; } - private static PlansCalcRouteConfigGroup createTestConfigGroup() { - log.info( "creating test config group ... "); - - final PlansCalcRouteConfigGroup group = new PlansCalcRouteConfigGroup(); + private static RoutingConfigGroup createTestConfigGroup() { + log.info( "creating test config group ... "); + + final RoutingConfigGroup group = new RoutingConfigGroup(); group.setNetworkModes( Arrays.asList( "electricity" , "water_supply" ) ); // two modes with only one speed group.setTeleportedModeFreespeedFactor( "inline skate" , 0.1 ); // group.getModeRoutingParams().get("inline skate").setBeelineDistanceFactor( 10000000. ); - + group.setTeleportedModeSpeed( "ice skates" , 10 ); // group.getModeRoutingParams().get("ice skates").setBeelineDistanceFactor( 10000000. ); @@ -310,7 +310,7 @@ private static PlansCalcRouteConfigGroup createTestConfigGroup() { //group.setTeleportedModeFreespeedFactor( "overboard" , 100 ); //group.setTeleportedModeSpeed( "overboard" , 999 ); - log.info( "... done creating test config group."); + log.info( "... done creating test config group."); return group; } } diff --git a/matsim/src/test/java/org/matsim/core/config/groups/PlanCalcScoreConfigGroupTest.java b/matsim/src/test/java/org/matsim/core/config/groups/ScoringConfigGroupTest.java similarity index 93% rename from matsim/src/test/java/org/matsim/core/config/groups/PlanCalcScoreConfigGroupTest.java rename to matsim/src/test/java/org/matsim/core/config/groups/ScoringConfigGroupTest.java index 95dfb44e7cf..d214f679a40 100644 --- a/matsim/src/test/java/org/matsim/core/config/groups/PlanCalcScoreConfigGroupTest.java +++ b/matsim/src/test/java/org/matsim/core/config/groups/ScoringConfigGroupTest.java @@ -21,7 +21,7 @@ package org.matsim.core.config.groups; -import static org.matsim.core.config.groups.PlanCalcScoreConfigGroup.createStageActivityType; +import static org.matsim.core.config.groups.ScoringConfigGroup.createStageActivityType; import java.util.Map; import java.util.Random; @@ -37,19 +37,19 @@ import org.matsim.core.config.ConfigReader; import org.matsim.core.config.ConfigUtils; import org.matsim.core.config.ConfigWriter; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup.ActivityParams; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup.ModeParams; +import org.matsim.core.config.groups.ScoringConfigGroup.ActivityParams; +import org.matsim.core.config.groups.ScoringConfigGroup.ModeParams; import org.matsim.testcases.MatsimTestUtils; -public class PlanCalcScoreConfigGroupTest { +public class ScoringConfigGroupTest { private static final Logger log = - LogManager.getLogger(PlanCalcScoreConfigGroupTest.class); + LogManager.getLogger(ScoringConfigGroupTest.class); @Rule public final MatsimTestUtils utils = new MatsimTestUtils(); private void testResultsBeforeCheckConsistency( Config config, boolean fullyHierarchical ) { - PlanCalcScoreConfigGroup scoringConfig = config.planCalcScore() ; + ScoringConfigGroup scoringConfig = config.planCalcScore() ; if ( ! fullyHierarchical ){ // mode params are there for default modes: @@ -70,7 +70,7 @@ private void testResultsBeforeCheckConsistency( Config config, boolean fullyHier // } } private void testResultsAfterCheckConsistency( Config config ) { - PlanCalcScoreConfigGroup scoringConfig = config.planCalcScore() ; + ScoringConfigGroup scoringConfig = config.planCalcScore() ; // default stage/interaction params for modes routed on the network are now there: for( String networkMode : config.plansCalcRoute().getNetworkModes() ){ @@ -81,7 +81,7 @@ private void testResultsAfterCheckConsistency( Config config ) { @Test public void testFullyHierarchicalVersion() { Config config = ConfigUtils.loadConfig( utils.getClassInputDirectory() + "config_v2_w_scoringparams.xml" ) ; - PlanCalcScoreConfigGroup scoringConfig = config.planCalcScore() ; + ScoringConfigGroup scoringConfig = config.planCalcScore() ; testResultsBeforeCheckConsistency( config, true ) ; log.warn( "" ); for( ModeParams modeParams : scoringConfig.getModes().values() ){ @@ -93,7 +93,7 @@ public void testFullyHierarchicalVersion() { } log.warn( "" ); log.warn( "checking consistency ..." ); - config.plansCalcRoute().setAccessEgressType(PlansCalcRouteConfigGroup.AccessEgressType.accessEgressModeToLink); + config.plansCalcRoute().setAccessEgressType(RoutingConfigGroup.AccessEgressType.accessEgressModeToLink); scoringConfig.checkConsistency( config ); testResultsAfterCheckConsistency( config ); log.warn( "" ); @@ -109,7 +109,7 @@ public void testFullyHierarchicalVersion() { @Test public void testVersionWoScoringparams() { Config config = ConfigUtils.loadConfig( utils.getClassInputDirectory() + "config_v2_wo_scoringparams.xml" ) ; - PlanCalcScoreConfigGroup scoringConfig = config.planCalcScore() ; + ScoringConfigGroup scoringConfig = config.planCalcScore() ; testResultsBeforeCheckConsistency( config, false ) ; log.warn( "" ); for( ModeParams modeParams : scoringConfig.getModes().values() ){ @@ -121,7 +121,7 @@ public void testVersionWoScoringparams() { } log.warn( "" ); log.warn( "checking consistency ..." ); - config.plansCalcRoute().setAccessEgressType( PlansCalcRouteConfigGroup.AccessEgressType.accessEgressModeToLink); + config.plansCalcRoute().setAccessEgressType( RoutingConfigGroup.AccessEgressType.accessEgressModeToLink); scoringConfig.checkConsistency( config ); testResultsAfterCheckConsistency( config ); log.warn( "" ); @@ -137,7 +137,7 @@ public void testVersionWoScoringparams() { @Test public void testAddActivityParams() { - PlanCalcScoreConfigGroup c = new PlanCalcScoreConfigGroup(); + ScoringConfigGroup c = new ScoringConfigGroup(); int originalSize = c.getActivityParams().size(); Assert.assertNull(c.getActivityParams("type1")); Assert.assertEquals(originalSize, c.getActivityParams().size()); @@ -150,7 +150,7 @@ public void testAddActivityParams() { @Test public void testIODifferentVersions() { - final PlanCalcScoreConfigGroup initialGroup = createTestConfigGroup(); + final ScoringConfigGroup initialGroup = createTestConfigGroup(); final String v1path = utils.getOutputDirectory() + "/configv1_out.xml"; final Config configV1 = new Config(); @@ -175,8 +175,8 @@ public void testIODifferentVersions() { private void assertIdentical( final String msg, - final PlanCalcScoreConfigGroup initialGroup, - final PlanCalcScoreConfigGroup inputConfigGroup) { + final ScoringConfigGroup initialGroup, + final ScoringConfigGroup inputConfigGroup) { Assert.assertEquals( "wrong brainExpBeta "+msg, initialGroup.getBrainExpBeta(), @@ -359,7 +359,7 @@ private void assertIdentical( } - private static ConfigGroup toUnderscoredModule(final PlanCalcScoreConfigGroup initialGroup) { + private static ConfigGroup toUnderscoredModule(final ScoringConfigGroup initialGroup) { final ConfigGroup module = new ConfigGroup( initialGroup.getName() ); for ( Map.Entry e : initialGroup.getParams().entrySet() ) { @@ -401,8 +401,8 @@ private static ConfigGroup toUnderscoredModule(final PlanCalcScoreConfigGroup in return module; } - private PlanCalcScoreConfigGroup createTestConfigGroup() { - final PlanCalcScoreConfigGroup group = new PlanCalcScoreConfigGroup(); + private ScoringConfigGroup createTestConfigGroup() { + final ScoringConfigGroup group = new ScoringConfigGroup(); group.setBrainExpBeta( 124); group.getModes().get(TransportMode.bike).setConstant((double) 98); diff --git a/matsim/src/test/java/org/matsim/core/controler/ControlerIT.java b/matsim/src/test/java/org/matsim/core/controler/ControlerIT.java index 41a7370e3f9..c5589cfef3b 100644 --- a/matsim/src/test/java/org/matsim/core/controler/ControlerIT.java +++ b/matsim/src/test/java/org/matsim/core/controler/ControlerIT.java @@ -21,8 +21,8 @@ package org.matsim.core.controler; import static org.junit.Assert.*; -import static org.matsim.core.config.groups.ControlerConfigGroup.CompressionType; -import static org.matsim.core.config.groups.ControlerConfigGroup.SnapshotFormat; +import static org.matsim.core.config.groups.ControllerConfigGroup.CompressionType; +import static org.matsim.core.config.groups.ControllerConfigGroup.SnapshotFormat; import java.io.File; import java.util.ArrayList; @@ -54,12 +54,12 @@ import org.matsim.api.core.v01.population.PopulationFactory; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.ControlerConfigGroup; -import org.matsim.core.config.groups.ControlerConfigGroup.EventsFileFormat; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup.ActivityParams; -import org.matsim.core.config.groups.PlansCalcRouteConfigGroup; +import org.matsim.core.config.groups.ControllerConfigGroup; +import org.matsim.core.config.groups.ControllerConfigGroup.EventsFileFormat; +import org.matsim.core.config.groups.ScoringConfigGroup.ActivityParams; +import org.matsim.core.config.groups.RoutingConfigGroup; import org.matsim.core.config.groups.QSimConfigGroup.SnapshotStyle; -import org.matsim.core.config.groups.StrategyConfigGroup.StrategySettings; +import org.matsim.core.config.groups.ReplanningConfigGroup.StrategySettings; import org.matsim.core.mobsim.framework.Mobsim; import org.matsim.core.population.PopulationUtils; import org.matsim.core.population.routes.NetworkRoute; @@ -82,18 +82,18 @@ public class ControlerIT { @Rule public MatsimTestUtils utils = new MatsimTestUtils(); private final boolean isUsingFastCapacityUpdate; - + public ControlerIT(boolean isUsingFastCapacityUpdate) { this.isUsingFastCapacityUpdate = isUsingFastCapacityUpdate; } - + @Parameters(name = "{index}: isUsingfastCapacityUpdate == {0}") public static Collection parameterObjects () { Object [] capacityUpdates = new Object [] { false, true }; return Arrays.asList(capacityUpdates); // yyyy I am not sure why it is doing this ... it is necessary to do this around the qsim, but why here? kai, aug'16 } - + @Test public void testScenarioLoading() { final Config config = utils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("equil"), "config.xml")); @@ -101,7 +101,7 @@ public void testScenarioLoading() { // need to run the controler to get Scenario initilized controler.getConfig().controler().setLastIteration( 0 ); - controler.getConfig().controler().setCleanItersAtEnd(ControlerConfigGroup.CleanIterations.keep); + controler.getConfig().controler().setCleanItersAtEnd(ControllerConfigGroup.CleanIterations.keep); controler.run(); assertNotNull(controler.getScenario().getNetwork()); // is required, e.g. for changing the factories @@ -159,11 +159,11 @@ public void testConstructor_EventsManagerTypeImmutable() { public void testTravelTimeCalculation() { Fixture f = new Fixture(ConfigUtils.createConfig()); Config config = f.scenario.getConfig(); - + /* Create 2 persons driving from link 1 to link 3, both starting at the same time at 7am. */ Population population = f.scenario.getPopulation(); PopulationFactory factory = population.getFactory(); - + Person person1 = factory.createPerson(Id.create("1", Person.class)); Plan plan1 = factory.createPlan(); person1.addPlan(plan1); @@ -193,8 +193,8 @@ public void testTravelTimeCalculation() { route2.setLinkIds(f.link1.getId(), linkIds, f.link3.getId()); plan2.addActivity(factory.createActivityFromLinkId("h", f.link3.getId())); population.addPerson(person2); - - /* the first agent needs 101 seconds (100 seconds free speed + 1s buffer) for link2; + + /* the first agent needs 101 seconds (100 seconds free speed + 1s buffer) for link2; * the second agent needs 200 seconds (has to wait for 100 seconds because of flow capacity) */ double avgTravelTimeLink2 = 150.5; @@ -202,7 +202,7 @@ public void testTravelTimeCalculation() { config.controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles); config.controler().setCreateGraphs(false); config.controler().setWriteEventsInterval(0); - config.controler().setDumpDataAtEnd(false); + config.controler().setDumpDataAtEnd(false); // - set scoring parameters ActivityParams actParams = new ActivityParams("h"); actParams.setTypicalDuration(8*3600); @@ -214,7 +214,7 @@ public void testTravelTimeCalculation() { config.global().setNumberOfThreads(0); config.qsim().setUsingFastCapacityUpdate(this.isUsingFastCapacityUpdate); - + // Now run the simulation Controler controler = new Controler(f.scenario); controler.run(); @@ -236,7 +236,7 @@ public void testTravelTimeCalculation() { controler = new Controler(f.scenario); controler.run(); - // test that the plans have the correct travel times + // test that the plans have the correct travel times // (travel time of the plan does not contain first and last link) assertEquals("ReRoute seems to have wrong travel times.", avgTravelTimeLink2, ((Leg)(person1.getPlans().get(1).getPlanElements().get(1))).getTravelTime().seconds(), MatsimTestUtils.EPSILON); @@ -254,7 +254,7 @@ public void testSetScoringFunctionFactory() { config.controler().setLastIteration(0); config.qsim().setUsingFastCapacityUpdate( this.isUsingFastCapacityUpdate ); - + MutableScenario scenario = (MutableScenario) ScenarioUtils.createScenario(config); // create a very simple network with one link only and an empty population Network network = scenario.getNetwork(); @@ -344,7 +344,7 @@ public void testCalcMissingRoutes() { config.global().setNumberOfThreads(1); config.qsim().setUsingFastCapacityUpdate( this.isUsingFastCapacityUpdate ); - + // Now run the simulation Controler controler = new Controler(f.scenario); controler.getConfig().controler().setCreateGraphs(false); @@ -442,7 +442,7 @@ public void testCalcMissingActLinks() { config.global().setNumberOfThreads(1); config.qsim().setUsingFastCapacityUpdate( this.isUsingFastCapacityUpdate ); - + // Now run the simulation Controler controler = new Controler(f.scenario); controler.getConfig().controler().setCreateGraphs(false); @@ -468,9 +468,9 @@ public Mobsim get() { assertEquals(f.link3.getId(), act1b.getLinkId()); assertEquals(f.link1.getId(), act2a.getLinkId()); assertEquals(f.link3.getId(), act2b.getLinkId()); - + int expectedPlanLength = 3 ; - if ( !f.scenario.getConfig().plansCalcRoute().getAccessEgressType().equals(PlansCalcRouteConfigGroup.AccessEgressType.none) ) { + if ( !f.scenario.getConfig().plansCalcRoute().getAccessEgressType().equals(RoutingConfigGroup.AccessEgressType.none) ) { // now 7 instead of earlier 3: h-wlk-iact-car-iact-walk-h expectedPlanLength = 7 ; } @@ -487,7 +487,7 @@ public Mobsim get() { assertNotNull( "null route in plan "+plan.getPlanElements(), ((Leg) plan.getPlanElements().get( 1 )).getRoute()); - if ( !f.scenario.getConfig().plansCalcRoute().getAccessEgressType().equals(PlansCalcRouteConfigGroup.AccessEgressType.none) ) { + if ( !f.scenario.getConfig().plansCalcRoute().getAccessEgressType().equals(RoutingConfigGroup.AccessEgressType.none) ) { assertNotNull( "null route in plan "+plan.getPlanElements(), ((Leg) plan.getPlanElements().get( 3 )).getRoute()); @@ -503,7 +503,7 @@ public void testCompressionType() { final Config config = utils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("equil"), "config_plans1.xml")); config.controler().setLastIteration(0); config.controler().setCompressionType( CompressionType.zst ); - config.controler().setCleanItersAtEnd(ControlerConfigGroup.CleanIterations.keep); + config.controler().setCleanItersAtEnd(ControllerConfigGroup.CleanIterations.keep); final Controler controler = new Controler(config); @@ -817,11 +817,11 @@ public Mobsim get() { controler.getConfig().controler().setDumpDataAtEnd(false); controler.run(); Assert.fail("expected exception, got none."); - + // note: I moved loadScenario in the controler from run() into the constructor to mirror the loading sequence one has - // when calling new Controler(scenario). In consequence, it fails already in the constructor; one could stop after that. + // when calling new Controler(scenario). In consequence, it fails already in the constructor; one could stop after that. // kai, apr'15 - + } catch (RuntimeException e) { log.info("catched expected exception.", e); } @@ -852,11 +852,11 @@ public Mobsim get() { controler.getConfig().controler().setDumpDataAtEnd(false); controler.run(); Assert.fail("expected exception, got none."); - + // note: I moved loadScenario in the controler from run() into the constructor to mirror the loading sequence one has - // when calling new Controler(scenario). In consequence, it fails already in the constructor; one could stop after that. + // when calling new Controler(scenario). In consequence, it fails already in the constructor; one could stop after that. // kai, apr'15 - + } catch (RuntimeException e) { log.info("catched expected exception.", e); } @@ -887,11 +887,11 @@ public Mobsim get() { controler.getConfig().controler().setDumpDataAtEnd(false); controler.run(); Assert.fail("expected exception, got none."); - + // note: I moved loadScenario in the controler from run() into the constructor to mirror the loading sequence one has - // when calling new Controler(scenario). In consequence, it fails already in the constructor; one could stop after that. + // when calling new Controler(scenario). In consequence, it fails already in the constructor; one could stop after that. // kai, apr'15 - + } catch (RuntimeException e) { log.info("catched expected exception.", e); } @@ -942,7 +942,7 @@ public void testTransimsSnapshotWriterOnQSim() { * which itself adds a Guice module... but too late. * * @thibautd - * + * */ @Test( expected = RuntimeException.class ) public void testGuiceModulesCannotAddModules() { diff --git a/matsim/src/test/java/org/matsim/core/controler/OutputDirectoryHierarchyTest.java b/matsim/src/test/java/org/matsim/core/controler/OutputDirectoryHierarchyTest.java index 7bf52f3abb7..66facce68ab 100644 --- a/matsim/src/test/java/org/matsim/core/controler/OutputDirectoryHierarchyTest.java +++ b/matsim/src/test/java/org/matsim/core/controler/OutputDirectoryHierarchyTest.java @@ -21,7 +21,7 @@ import org.junit.Assert; import org.junit.Rule; import org.junit.Test; -import org.matsim.core.config.groups.ControlerConfigGroup; +import org.matsim.core.config.groups.ControllerConfigGroup; import org.matsim.core.utils.io.IOUtils; import org.matsim.core.utils.io.UncheckedIOException; import org.matsim.testcases.MatsimTestUtils; @@ -46,7 +46,7 @@ public void testFailureIfDirectoryExists() { new OutputDirectoryHierarchy( outputDirectory, OutputDirectoryHierarchy.OverwriteFileSetting.failIfDirectoryExists, - ControlerConfigGroup.CompressionType.none); + ControllerConfigGroup.CompressionType.none); Assert.assertTrue( "Directory was not created", @@ -65,7 +65,7 @@ public void testFailureIfDirectoryExists() { new OutputDirectoryHierarchy( outputDirectory, OutputDirectoryHierarchy.OverwriteFileSetting.failIfDirectoryExists, - ControlerConfigGroup.CompressionType.none); + ControllerConfigGroup.CompressionType.none); } catch ( RuntimeException e ) { return; @@ -82,7 +82,7 @@ public void testOverrideIfDirectoryExists() { new OutputDirectoryHierarchy( outputDirectory, OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles, - ControlerConfigGroup.CompressionType.none); + ControllerConfigGroup.CompressionType.none); Assert.assertTrue( "Directory was not created", @@ -100,7 +100,7 @@ public void testOverrideIfDirectoryExists() { new OutputDirectoryHierarchy( outputDirectory, OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles, - ControlerConfigGroup.CompressionType.none); + ControllerConfigGroup.CompressionType.none); Assert.assertTrue( "Directory was cleared", @@ -117,7 +117,7 @@ public void testDeleteIfDirectoryExists() { new OutputDirectoryHierarchy( outputDirectory, OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists, - ControlerConfigGroup.CompressionType.none); + ControllerConfigGroup.CompressionType.none); Assert.assertTrue( "Directory was not created", @@ -135,7 +135,7 @@ public void testDeleteIfDirectoryExists() { new OutputDirectoryHierarchy( outputDirectory, OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists, - ControlerConfigGroup.CompressionType.none); + ControllerConfigGroup.CompressionType.none); Assert.assertTrue( "Directory was deleted but not re-created!", diff --git a/matsim/src/test/java/org/matsim/core/controler/TerminationTest.java b/matsim/src/test/java/org/matsim/core/controler/TerminationTest.java index f486ee58278..f15544055a8 100644 --- a/matsim/src/test/java/org/matsim/core/controler/TerminationTest.java +++ b/matsim/src/test/java/org/matsim/core/controler/TerminationTest.java @@ -11,8 +11,8 @@ import org.matsim.api.core.v01.population.Leg; import org.matsim.api.core.v01.population.Person; import org.matsim.core.config.Config; -import org.matsim.core.config.groups.ControlerConfigGroup; -import org.matsim.core.config.groups.StrategyConfigGroup.StrategySettings; +import org.matsim.core.config.groups.ControllerConfigGroup; +import org.matsim.core.config.groups.ReplanningConfigGroup.StrategySettings; import org.matsim.core.controler.events.IterationStartsEvent; import org.matsim.core.controler.listener.IterationStartsListener; import org.matsim.core.replanning.strategies.DefaultPlanStrategiesModule.DefaultStrategy; @@ -35,7 +35,7 @@ public class TerminationTest { @Test public void testSimulationEndsOnInterval() { - prepareExperiment(2, 4, ControlerConfigGroup.CleanIterations.keep).run(); + prepareExperiment(2, 4, ControllerConfigGroup.CleanIterations.keep).run(); Assert.assertTrue(new File(utils.getOutputDirectory(), "/ITERS/it.4/4.events.xml.gz").exists()); Assert.assertTrue(new File(utils.getOutputDirectory(), "/output_events.xml.gz").exists()); @@ -47,7 +47,7 @@ public void testSimulationEndsOnInterval() { @Test public void testOnlyRunIterationZero() { - prepareExperiment(2, 0, ControlerConfigGroup.CleanIterations.keep).run(); + prepareExperiment(2, 0, ControllerConfigGroup.CleanIterations.keep).run(); Assert.assertTrue(new File(utils.getOutputDirectory(), "/ITERS/it.0/0.events.xml.gz").exists()); Assert.assertTrue(new File(utils.getOutputDirectory(), "/output_events.xml.gz").exists()); @@ -62,7 +62,7 @@ public void testSimulationEndsOffInterval() { // This is the case when the TerminationCriterion decides that the simulation is // done, but it does not fall at the same time as the output interval. - prepareExperiment(2, 3, ControlerConfigGroup.CleanIterations.keep).run(); + prepareExperiment(2, 3, ControllerConfigGroup.CleanIterations.keep).run(); Assert.assertTrue(new File(utils.getOutputDirectory(), "/ITERS/it.2/2.events.xml.gz").exists()); Assert.assertTrue(new File(utils.getOutputDirectory(), "/ITERS/it.3/3.events.xml.gz").exists()); @@ -75,11 +75,11 @@ public void testSimulationEndsOffInterval() { @Test public void testSimulationEndDeleteIters() { - prepareExperiment(2, 3, ControlerConfigGroup.CleanIterations.delete).run(); + prepareExperiment(2, 3, ControllerConfigGroup.CleanIterations.delete).run(); Assert.assertFalse(new File(utils.getOutputDirectory(), "/ITERS").exists()); } - private Controler prepareExperiment(int interval, int criterion, ControlerConfigGroup.CleanIterations iters) { + private Controler prepareExperiment(int interval, int criterion, ControllerConfigGroup.CleanIterations iters) { Config config = utils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("equil"), "config.xml")); config.controler().setOutputDirectory(utils.getOutputDirectory()); config.controler().setCleanItersAtEnd(iters); @@ -98,7 +98,7 @@ public void testMultipleLastIterations() { * is written, decides that more iterations need to be run. */ - Controler controller = prepareExperiment(2, 1000, ControlerConfigGroup.CleanIterations.keep); + Controler controller = prepareExperiment(2, 1000, ControllerConfigGroup.CleanIterations.keep); controller.setTerminationCriterion(new TerminationCriterion() { @Override @@ -133,7 +133,7 @@ public void testCustomConverenceCriterion() { Config config = utils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("equil"), "config.xml")); config.controler().setOutputDirectory(utils.getOutputDirectory()); - config.controler().setCleanItersAtEnd(ControlerConfigGroup.CleanIterations.keep); + config.controler().setCleanItersAtEnd(ControllerConfigGroup.CleanIterations.keep); { // Set up mode choice config.changeMode().setModes(new String[] { "car", "walk" }); diff --git a/matsim/src/test/java/org/matsim/core/controler/TransitControlerIntegrationTest.java b/matsim/src/test/java/org/matsim/core/controler/TransitControlerIntegrationTest.java index 49192781892..2e800250e8a 100644 --- a/matsim/src/test/java/org/matsim/core/controler/TransitControlerIntegrationTest.java +++ b/matsim/src/test/java/org/matsim/core/controler/TransitControlerIntegrationTest.java @@ -41,8 +41,8 @@ import org.matsim.api.core.v01.population.Population; import org.matsim.api.core.v01.population.PopulationFactory; import org.matsim.core.config.Config; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup.ActivityParams; -import org.matsim.core.config.groups.StrategyConfigGroup.StrategySettings; +import org.matsim.core.config.groups.ScoringConfigGroup.ActivityParams; +import org.matsim.core.config.groups.ReplanningConfigGroup.StrategySettings; import org.matsim.core.population.routes.NetworkRoute; import org.matsim.core.population.routes.RouteUtils; import org.matsim.core.scenario.MutableScenario; diff --git a/matsim/src/test/java/org/matsim/core/events/algorithms/EventWriterJsonTest.java b/matsim/src/test/java/org/matsim/core/events/algorithms/EventWriterJsonTest.java index 09606e024e2..9756af4c134 100644 --- a/matsim/src/test/java/org/matsim/core/events/algorithms/EventWriterJsonTest.java +++ b/matsim/src/test/java/org/matsim/core/events/algorithms/EventWriterJsonTest.java @@ -7,7 +7,7 @@ import org.matsim.api.core.v01.events.LinkLeaveEvent; import org.matsim.api.core.v01.network.Link; import org.matsim.core.api.experimental.events.EventsManager; -import org.matsim.core.config.groups.ControlerConfigGroup; +import org.matsim.core.config.groups.ControllerConfigGroup; import org.matsim.core.events.EventsUtils; import org.matsim.core.events.MatsimEventsReader; import org.matsim.testcases.utils.EventsCollector; @@ -40,7 +40,7 @@ public void testSpecialCharacters() { EventsCollector collector = new EventsCollector(); events.addHandler(collector); events.initProcessing(); - new MatsimEventsReader(events).readStream(bios, ControlerConfigGroup.EventsFileFormat.json); + new MatsimEventsReader(events).readStream(bios, ControllerConfigGroup.EventsFileFormat.json); events.finishProcessing(); Assert.assertEquals("there must be 2 events.", 2, collector.getEvents().size()); @@ -72,7 +72,7 @@ public void testNullAttribute() { EventsCollector collector = new EventsCollector(); events.addHandler(collector); events.initProcessing(); - new MatsimEventsReader(events).readStream(bios, ControlerConfigGroup.EventsFileFormat.json); + new MatsimEventsReader(events).readStream(bios, ControllerConfigGroup.EventsFileFormat.json); events.finishProcessing(); Assert.assertEquals("there must be 1 event.", 1, collector.getEvents().size()); diff --git a/matsim/src/test/java/org/matsim/core/mobsim/hermes/HermesRoundaboutTest.java b/matsim/src/test/java/org/matsim/core/mobsim/hermes/HermesRoundaboutTest.java index b5ca0b9ea82..295e049cea0 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/hermes/HermesRoundaboutTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/hermes/HermesRoundaboutTest.java @@ -39,9 +39,9 @@ import org.matsim.api.core.v01.population.PopulationFactory; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; -import org.matsim.core.config.groups.PlansCalcRouteConfigGroup; -import org.matsim.core.config.groups.StrategyConfigGroup; +import org.matsim.core.config.groups.ReplanningConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; +import org.matsim.core.config.groups.RoutingConfigGroup; import org.matsim.core.controler.Controler; import org.matsim.core.controler.OutputDirectoryHierarchy; import org.matsim.core.network.NetworkUtils; @@ -93,17 +93,17 @@ private Config createConfig() { config.controler().setFirstIteration(0); config.controler().setLastIteration(2); config.controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles); - config.plansCalcRoute().setAccessEgressType(PlansCalcRouteConfigGroup.AccessEgressType.accessEgressModeToLink); //standard accessEgressMode is walk + config.plansCalcRoute().setAccessEgressType(RoutingConfigGroup.AccessEgressType.accessEgressModeToLink); //standard accessEgressMode is walk - final PlanCalcScoreConfigGroup.ActivityParams homeParams = new PlanCalcScoreConfigGroup.ActivityParams("home"); + final ScoringConfigGroup.ActivityParams homeParams = new ScoringConfigGroup.ActivityParams("home"); homeParams.setTypicalDuration(1); config.planCalcScore().addActivityParams(homeParams); - final PlanCalcScoreConfigGroup.ActivityParams workParams = new PlanCalcScoreConfigGroup.ActivityParams("work"); + final ScoringConfigGroup.ActivityParams workParams = new ScoringConfigGroup.ActivityParams("work"); workParams.setTypicalDuration(1); config.planCalcScore().addActivityParams(workParams); - StrategyConfigGroup.StrategySettings replanning = new StrategyConfigGroup.StrategySettings(); + ReplanningConfigGroup.StrategySettings replanning = new ReplanningConfigGroup.StrategySettings(); replanning.setStrategyName("ReRoute"); replanning.setWeight(1.0); config.strategy().addStrategySettings(replanning); @@ -190,7 +190,7 @@ private void buildRoundaboutNetwork(Scenario scenario) { Link dd1 = NetworkUtils.createAndAddLink(network,Id.createLinkId("d_d1"),d,d1,20,8,1100,1); Link d1d2 = NetworkUtils.createAndAddLink(network,Id.createLinkId("d1_d2"),d1,d2,2000,8,720000,1); Link d2d1 = NetworkUtils.createAndAddLink(network,Id.createLinkId("d2_d1"),d2,d1,2000,8,720000,1); - + } diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/AgentNotificationTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/AgentNotificationTest.java index 908e80db324..75ace02794a 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/AgentNotificationTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/AgentNotificationTest.java @@ -52,7 +52,7 @@ import org.matsim.core.api.experimental.events.EventsManager; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.PlansCalcRouteConfigGroup; +import org.matsim.core.config.groups.RoutingConfigGroup; import org.matsim.core.events.EventsUtils; import org.matsim.core.mobsim.framework.MobsimAgent; import org.matsim.core.mobsim.framework.MobsimDriverAgent; @@ -306,7 +306,7 @@ protected Double featureValueOf(Event event) { private static Scenario createSimpleScenario() { final Config config = ConfigUtils.createConfig(); - PlansCalcRouteConfigGroup.TeleportedModeParams params = new PlansCalcRouteConfigGroup.TeleportedModeParams( TransportMode.walk ) ; + RoutingConfigGroup.TeleportedModeParams params = new RoutingConfigGroup.TeleportedModeParams( TransportMode.walk ) ; params.setBeelineDistanceFactor(1.3); params.setTeleportedModeSpeed(1.); config.plansCalcRoute().addModeRoutingParams( params ); diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/NetsimRoutingConsistencyTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/NetsimRoutingConsistencyTest.java index 5e778cd0ebc..aaf4f99f1ee 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/NetsimRoutingConsistencyTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/NetsimRoutingConsistencyTest.java @@ -46,7 +46,7 @@ import org.matsim.core.api.experimental.events.EventsManager; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup.ActivityParams; +import org.matsim.core.config.groups.ScoringConfigGroup.ActivityParams; import org.matsim.core.controler.AbstractModule; import org.matsim.core.controler.Controler; import org.matsim.core.controler.OutputDirectoryHierarchy.OverwriteFileSetting; @@ -70,53 +70,53 @@ public class NetsimRoutingConsistencyTest { * This test shows that the travel time that is predicted with the * NetworkRoutingModule is NOT equivalent to the travel time that is produced by * the Netsim. - * + * * The scenario is as follows: - * - * N1 ----- N2 ----- N3 ----- N4 ----- N5 + * + * N1 ----- N2 ----- N3 ----- N4 ----- N5 * L12 L23 L34 L45 - * + * * There are nodes Ni and connecting links Lij. There is one agent P who wants * to depart at L12 and arrive at L45. He has a plan with an activity at L12 and * another one at L45 and a connecting leg by car. - * + * * This car leg is produced (as would be in the full stack simulation) using the * NetworkRoutingModule. For the disutility OnlyTimeDependentDisutility is used, * for the TravelTime, freespeed is used. The freespeed of all links is 10, * while the length is 1000, hence the traversal time for each link is 100. - * + * * Accordingly, the NetworkRoutingModule produces a Leg for the agent with a * travel time of - * + * * routingTravelTime = 200.0 - * + * * because link L23 and L45 are taken into account. As expected the routing goes * from the end node of the departure link to the start node of the arrival * link. We already know that this will not be the true Netsim simulated time, * because traversal times are rounded up. So we would expect a - * + * * adjustedRoutingTravelTime = 202.0 - * + * * because we need to add 1s per traversed link. - * + * * Now, the scenario is simulated using the QSim/Netsim. An event handler is set * up that captures the only "departure" event and the only "arrival" event in * the simulation (which is produced by the leg of the agent). The travel time * can be computed an we get: - * + * * netsimTravelTime = 303.0 - * + * * Apparently, looking at QueueWithBuffer::moveQueueToBuffer , the agent needs * to traverse the arrival link before he can arrive there. This leads to a * travel time that is higher than expected by the router and so predictions * done by the NetworkRoutingModule are inconsistent. - * - * Not sure, what to do about that. Possible options: - * - Adjust Netsim such that agents arrive before they traverse the arrival link - * - Adjust the car routing such that the travel time of the final link is added - * - Adjust the car routing such that the routing goes to the end node of the arrival link + * + * Not sure, what to do about that. Possible options: + * - Adjust Netsim such that agents arrive before they traverse the arrival link + * - Adjust the car routing such that the travel time of the final link is added + * - Adjust the car routing such that the routing goes to the end node of the arrival link * - Explicitly document this behaviour somewhere - * + * * I guess usually this should not make such a big difference for MATSim, * because the shortest path is found anyway. However, if one wants to predict * travel times one should state that the NetworkRoutingModule has a bias by the @@ -208,19 +208,19 @@ public void testRoutingVsSimulation() { @Test /* - * The same test as above, but here the full stack MATSim setup is used (i.e. the + * The same test as above, but here the full stack MATSim setup is used (i.e. the * NetworkRoutingModule, etc. are created implicitly by the Controler). */ public void testRoutingVsSimulationFullStack() { Config config = ConfigUtils.createConfig(); - + config.controler().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); config.controler().setLastIteration(0); - + ActivityParams activityParams = new ActivityParams("A"); activityParams.setTypicalDuration(100.0); config.planCalcScore().addActivityParams(activityParams); - + Scenario scenario = ScenarioUtils.createScenario(config); Network network = scenario.getNetwork(); @@ -266,11 +266,11 @@ public void testRoutingVsSimulationFullStack() { Plan plan = population.getFactory().createPlan(); person.addPlan(plan); - + plan.addActivity(startActivity); plan.addLeg(population.getFactory().createLeg(TransportMode.car)); plan.addActivity(endActivity); - + DepartureArrivalListener listener = new DepartureArrivalListener(); Controler controler = new Controler(scenario); @@ -280,7 +280,7 @@ public void install() { addEventHandlerBinding().toInstance(listener); } }); - + controler.run(); double netsimTravelTime = listener.arrivalTime - listener.departureTime; @@ -293,7 +293,7 @@ public void install() { Assert.assertEquals(netsimTravelTime, 303.0, 1e-3); Assert.assertEquals(adjustedRoutingTravelTime, 202.0, 1e-3); } - + class DepartureArrivalListener implements PersonDepartureEventHandler, PersonArrivalEventHandler { public double departureTime = Double.NaN; public double arrivalTime = Double.NaN; diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/NodeTransitionTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/NodeTransitionTest.java index 5aeef0878d4..6fb3401ac8b 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/NodeTransitionTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/NodeTransitionTest.java @@ -46,7 +46,7 @@ import org.matsim.core.api.experimental.events.EventsManager; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; import org.matsim.core.config.groups.QSimConfigGroup.NodeTransition; import org.matsim.core.controler.OutputDirectoryHierarchy.OverwriteFileSetting; import org.matsim.core.controler.PrepareForSimUtils; @@ -59,22 +59,22 @@ /** * Test the different node transition options that one can choose in the qsim config group. * EmptyBufferAfterBuffer and blockNodeWhenSingleOutlinkFull = false currently is the MATSim standard. - * - * This test checks the throughput of links in two different scenarios: + * + * This test checks the throughput of links in two different scenarios: * 1. A merge situation, where agents coming from three different links all want to enter the same downstream link with restricted capacity. * 2. An intersection, where agents coming from two different links do not use same links but might affect each other when the flag blockNodeWhenSingleOutlinkFull is set to true. - * + * * While implementing and significantly testing the new node transitions some bugs have been found in QueueWithBuffer regarding half empty buffers and time step sizes < 1. * This tests therefore also validates the bug fixes (see e.g. testNodeTransitionWithTimeStepSizeSmallerOne). - * + * * The results should be the same independently of slow/fast capacity update. That's why the test is run for both (parameterized). - * + * * @author tthunig * */ @RunWith(Parameterized.class) public class NodeTransitionTest { - + @Parameterized.Parameters(name = "{index}: useFastCapUpdate == {0};") public static Collection parameterObjects() { return Arrays.asList(new Object[][]{ @@ -82,19 +82,19 @@ public static Collection parameterObjects() { {false} }); } - + private boolean useFastCapUpdate; - + public NodeTransitionTest(boolean useFastCapUpdate) { this.useFastCapUpdate = useFastCapUpdate; } - + @Test public void testMergeSituationWithEmptyBufferAfterBufferRandomDistribution() { Scenario scenario = Fixture.createMergeScenario(); scenario.getConfig().qsim().setNodeTransitionLogic(NodeTransition.emptyBufferAfterBufferRandomDistribution_dontBlockNode); scenario.getConfig().qsim().setUsingFastCapacityUpdate(useFastCapUpdate); - + EventsManager events = EventsUtils.createEventsManager(); List> linksOfInterest = new LinkedList<>(); linksOfInterest.add(Id.createLinkId("2_7")); @@ -102,14 +102,14 @@ public void testMergeSituationWithEmptyBufferAfterBufferRandomDistribution() { linksOfInterest.add(Id.createLinkId("6_7")); ThroughputAnalyzer throughputAnalyzer = new ThroughputAnalyzer(linksOfInterest); events.addHandler(throughputAnalyzer); - + PrepareForSimUtils.createDefaultPrepareForSim(scenario).run(); new QSimBuilder(scenario.getConfig()) .useDefaults() .build(scenario, events) .run(); - + // this is the time before the downstream link (7_8) gets full and with that no inflow capacity is valid int timeInterval1Start = 110; int timeInterval1End = 180; Map, Double> avgThroughputFreeFlow = throughputAnalyzer.calculateAvgThroughputPerTimeStepOfTimeInterval(timeInterval1Start, timeInterval1End, 1); @@ -124,31 +124,31 @@ public void testMergeSituationWithEmptyBufferAfterBufferRandomDistribution() { + "\t; time interval [" + timeInterval2Start + ", " + timeInterval2End + "]: " + avgThroughputCongestedTwoLinks.get(link) + "\t; time interval [" + timeInterval3Start + ", " + timeInterval3End + "]: " + avgThroughputCongestedThreeLinks.get(link)); } - - /* since this node dynamic is a random distribution we allow a somewhat bigger difference here. + + /* since this node dynamic is a random distribution we allow a somewhat bigger difference here. * otherwise we would need to run the test for a longer period or different random seeds which would increase the run time of this test. */ double delta = 0.1; - + // test throughput for the first time interval - /* the downstream link is not full, i.e. the links can send vehicles with their full outflow capacity. + /* the downstream link is not full, i.e. the links can send vehicles with their full outflow capacity. * the commodity on link 6_7 has not begun to send vehicles, i.e. the corresponding throughput should be 0 */ Assert.assertEquals("Troughput on link 2_7 is wrong", 1, avgThroughputFreeFlow.get(Id.createLinkId("2_7")), MatsimTestUtils.EPSILON); Assert.assertEquals("Troughput on link 4_7 is wrong", 2, avgThroughputFreeFlow.get(Id.createLinkId("4_7")), MatsimTestUtils.EPSILON); Assert.assertEquals("Troughput on link 6_7 is wrong", 0, avgThroughputFreeFlow.get(Id.createLinkId("6_7")), MatsimTestUtils.EPSILON); - + // test throughput for the second time interval - /* with probability of 2/3 link 4_7 is selected and sends all vehicles from its buffer, i.e. 2; + /* with probability of 2/3 link 4_7 is selected and sends all vehicles from its buffer, i.e. 2; * with probability of 1/3 link 2_7 is selected and sends all vehicles from its buffer, i.e. 1 and afterwards link 4_7 can send the remaining 1. * this means, the expected average throughput of link 2_7 is 1/3 and the expected average throughput of link 4_7 is 2*2/3 + 1/3 = 5/3. */ Assert.assertEquals("Troughput on link 2_7 is wrong", 1./3, avgThroughputCongestedTwoLinks.get(Id.createLinkId("2_7")), delta); // 0.25384615384615383 Assert.assertEquals("Troughput on link 4_7 is wrong", 5./3, avgThroughputCongestedTwoLinks.get(Id.createLinkId("4_7")), delta); // 1.7461538461538462 Assert.assertEquals("Troughput on link 6_7 is wrong", 0, avgThroughputCongestedTwoLinks.get(Id.createLinkId("6_7")), MatsimTestUtils.EPSILON); - + // test throughput for the third time interval /* with probability of 2/5 link 4_7 is selected and sends all vehicles from its buffer, i.e. 2; - * with probability of 2/5 link 6_7 is selected and sends all vehicles from its buffer, i.e. 2; + * with probability of 2/5 link 6_7 is selected and sends all vehicles from its buffer, i.e. 2; * with probability of 1/5 link 2_7 is selected and sends all vehicles from its buffer, i.e. 1 and afterwards link 4_7 or link 6_7 can send the remaining 1. * this means, the expected average throughput of link 2_7 is 1/5 and the expected average throughput of link 4_7 and link 6_7 is 2*2/5 + 1/10 = 9/10. */ @@ -156,13 +156,13 @@ public void testMergeSituationWithEmptyBufferAfterBufferRandomDistribution() { Assert.assertEquals("Troughput on link 4_7 is wrong", 9./10, avgThroughputCongestedThreeLinks.get(Id.createLinkId("4_7")), delta); // 0.8928571428571429 Assert.assertEquals("Troughput on link 6_7 is wrong", 9./10, avgThroughputCongestedThreeLinks.get(Id.createLinkId("6_7")), delta); // 0.9285714285714286 } - + @Test public void testMergeSituationWithMoveVehByVehRandomDistribution() { Scenario scenario = Fixture.createMergeScenario(); scenario.getConfig().qsim().setNodeTransitionLogic(NodeTransition.moveVehByVehRandomDistribution_dontBlockNode); scenario.getConfig().qsim().setUsingFastCapacityUpdate(useFastCapUpdate); - + EventsManager events = EventsUtils.createEventsManager(); List> linksOfInterest = new LinkedList<>(); linksOfInterest.add(Id.createLinkId("2_7")); @@ -170,14 +170,14 @@ public void testMergeSituationWithMoveVehByVehRandomDistribution() { linksOfInterest.add(Id.createLinkId("6_7")); ThroughputAnalyzer throughputAnalyzer = new ThroughputAnalyzer(linksOfInterest); events.addHandler(throughputAnalyzer); - + PrepareForSimUtils.createDefaultPrepareForSim(scenario).run(); new QSimBuilder(scenario.getConfig()) .useDefaults() .build(scenario, events) .run(); - + // this is the time before the downstream link (7_8) gets full and with that no inflow capacity is valid int timeInterval1Start = 110; int timeInterval1End = 180; Map, Double> avgThroughputFreeFlow = throughputAnalyzer.calculateAvgThroughputPerTimeStepOfTimeInterval(timeInterval1Start, timeInterval1End, 1); @@ -192,32 +192,32 @@ public void testMergeSituationWithMoveVehByVehRandomDistribution() { + "\t; time interval [" + timeInterval2Start + ", " + timeInterval2End + "]: " + avgThroughputCongestedTwoLinks.get(link) + "\t; time interval [" + timeInterval3Start + ", " + timeInterval3End + "]: " + avgThroughputCongestedThreeLinks.get(link)); } - - /* since this node dynamic is a random distribution we allow a somewhat bigger difference here. + + /* since this node dynamic is a random distribution we allow a somewhat bigger difference here. * otherwise we would need to run the test for a longer period or different random seeds which would increase the run time of this test. * note, that these random values can even differ when all tests are run after each other or when they are run separately */ double delta = 0.04; - + // test throughput for the first time interval - /* the downstream link is not full, i.e. the links can send vehicles with their full outflow capacity. + /* the downstream link is not full, i.e. the links can send vehicles with their full outflow capacity. * the commodity on link 6_7 has not begun to send vehicles, i.e. the corresponding throughput should be 0 */ Assert.assertEquals("Troughput on link 2_7 is wrong", 1, avgThroughputFreeFlow.get(Id.createLinkId("2_7")), MatsimTestUtils.EPSILON); Assert.assertEquals("Troughput on link 4_7 is wrong", 2, avgThroughputFreeFlow.get(Id.createLinkId("4_7")), MatsimTestUtils.EPSILON); Assert.assertEquals("Troughput on link 6_7 is wrong", 0, avgThroughputFreeFlow.get(Id.createLinkId("6_7")), MatsimTestUtils.EPSILON); - + // test throughput for the second time interval /* with probability of 2/3 link 4_7 is selected and sends one vehicle; afterwards with probability of 2/3 link 4_7 is allowed to send the second vehicle, with probability 1/3 link 2_7 is allowed to send one. * with probability of 1/3 link 2_7 is selected and sends one vehicle; afterwards link 4_7 will send the remaining one, because the buffer of link 2_7 is empty anyway. * this means, the expected average throughput of link 2_7 will get underestimated because the random distribution is cut at one and will never overestimate above this number. * consequently, the expected average throughput of link 4_7 will get overestimated. - * the numbers are as follows: the expected average throughput of link 2_7 is 2/3*1/3*1 + 1/3*1 = 5/9 + * the numbers are as follows: the expected average throughput of link 2_7 is 2/3*1/3*1 + 1/3*1 = 5/9 * and the expected average throughput of link 4_7 is 2/3*2/3*2 + 2/3*1/3*1 + 1/3*1 = 13/9 */ Assert.assertEquals("Troughput on link 2_7 is wrong", 5./9, avgThroughputCongestedTwoLinks.get(Id.createLinkId("2_7")), delta); // 0.5307692307692308 Assert.assertEquals("Troughput on link 4_7 is wrong", 13./9, avgThroughputCongestedTwoLinks.get(Id.createLinkId("4_7")), delta); // 1.4692307692307693 Assert.assertEquals("Troughput on link 6_7 is wrong", 0, avgThroughputCongestedTwoLinks.get(Id.createLinkId("6_7")), MatsimTestUtils.EPSILON); - + // test throughput for the third time interval /* the first vehicle is send by link 2_7 with probability of 1/5 and by one of the other two links with probability 2/5. * if link 4_7 or 6_7 have send the first vehicle, the same probability will hold for the second vehicle. @@ -231,14 +231,14 @@ public void testMergeSituationWithMoveVehByVehRandomDistribution() { Assert.assertEquals("Troughput on link 4_7 is wrong", 41./50, avgThroughputCongestedThreeLinks.get(Id.createLinkId("4_7")), delta); // 0.8 Assert.assertEquals("Troughput on link 6_7 is wrong", 41./50, avgThroughputCongestedThreeLinks.get(Id.createLinkId("6_7")), delta); // 0.8571428571428571 } - + @Test public void testMergeSituationWithMoveVehByVehDeterministicPriorities() { Scenario scenario = Fixture.createMergeScenario(); scenario.getConfig().qsim().setNodeTransitionLogic(NodeTransition.moveVehByVehDeterministicPriorities_nodeBlockedWhenSingleOutlinkFull); // note: the deterministic node transition is only implemented for the case when the node is blocked as soon as one outgoing link is full scenario.getConfig().qsim().setUsingFastCapacityUpdate(useFastCapUpdate); - + EventsManager events = EventsUtils.createEventsManager(); List> linksOfInterest = new LinkedList<>(); linksOfInterest.add(Id.createLinkId("2_7")); @@ -246,14 +246,14 @@ public void testMergeSituationWithMoveVehByVehDeterministicPriorities() { linksOfInterest.add(Id.createLinkId("6_7")); ThroughputAnalyzer throughputAnalyzer = new ThroughputAnalyzer(linksOfInterest); events.addHandler(throughputAnalyzer); - + PrepareForSimUtils.createDefaultPrepareForSim(scenario).run(); new QSimBuilder(scenario.getConfig()) .useDefaults() .build(scenario, events) .run(); - + // this is the time before the downstream link (7_8) gets full and with that no inflow capacity is valid int timeInterval1Start = 110; int timeInterval1End = 180; Map, Double> avgThroughputFreeFlow = throughputAnalyzer.calculateAvgThroughputPerTimeStepOfTimeInterval(timeInterval1Start, timeInterval1End, 1); @@ -268,22 +268,22 @@ public void testMergeSituationWithMoveVehByVehDeterministicPriorities() { + "\t; time interval [" + timeInterval2Start + ", " + timeInterval2End + "]: " + avgThroughputCongestedTwoLinks.get(link) + "\t; time interval [" + timeInterval3Start + ", " + timeInterval3End + "]: " + avgThroughputCongestedThreeLinks.get(link)); } - - /* since this node dynamic does not rely on a random distribution but updates link priorities each time step, - * i.e. remembers decisions made in previous time steps, + + /* since this node dynamic does not rely on a random distribution but updates link priorities each time step, + * i.e. remembers decisions made in previous time steps, * the difference to the expected values should be much smaller compared to the other node transition logic. * still, for periodic numbers a higher accuracy would only be reached by longer simulation times */ double delta = MatsimTestUtils.EPSILON; double deltaPeriodic = 0.01; - + // test throughput for the first time interval - /* the downstream link is not full, i.e. the links can send vehicles with their full outflow capacity. + /* the downstream link is not full, i.e. the links can send vehicles with their full outflow capacity. * the commodity on link 6_7 has not begun to send vehicles, i.e. the corresponding throughput should be 0 */ Assert.assertEquals("Troughput on link 2_7 is wrong", 1, avgThroughputFreeFlow.get(Id.createLinkId("2_7")), delta); Assert.assertEquals("Troughput on link 4_7 is wrong", 2, avgThroughputFreeFlow.get(Id.createLinkId("4_7")), delta); Assert.assertEquals("Troughput on link 6_7 is wrong", 0, avgThroughputFreeFlow.get(Id.createLinkId("6_7")), delta); - + // test throughput for the second time interval /* the deterministic node transition should distribute the free slots on the downstream link exactly proportional to the outflow capacity of the links, * i.e. 1:2 in this case @@ -291,7 +291,7 @@ public void testMergeSituationWithMoveVehByVehDeterministicPriorities() { Assert.assertEquals("Troughput on link 2_7 is wrong", 1./3 * 2, avgThroughputCongestedTwoLinks.get(Id.createLinkId("2_7")), deltaPeriodic); // 0.6692307692307692 Assert.assertEquals("Troughput on link 4_7 is wrong", 2./3 * 2, avgThroughputCongestedTwoLinks.get(Id.createLinkId("4_7")), deltaPeriodic); // 1.3307692307692307 Assert.assertEquals("Troughput on link 6_7 is wrong", 0, avgThroughputCongestedTwoLinks.get(Id.createLinkId("6_7")), delta); - + // test throughput for the third time interval /* the deterministic node transition should distribute the free slots on the downstream link exactly proportional to the outflow capacity of the links, * i.e. 1:2:2 in this case. @@ -300,13 +300,13 @@ public void testMergeSituationWithMoveVehByVehDeterministicPriorities() { Assert.assertEquals("Troughput on link 4_7 is wrong", 2./5 * 2, avgThroughputCongestedThreeLinks.get(Id.createLinkId("4_7")), delta); // 0.8 Assert.assertEquals("Troughput on link 6_7 is wrong", 2./5 * 2, avgThroughputCongestedThreeLinks.get(Id.createLinkId("6_7")), delta); // 0.8 } - + @Test public void testBlockedNodeSituationWithEmptyBufferAfterBufferRandomDistribution() { Scenario scenario = Fixture.createBlockedNodeScenario(); scenario.getConfig().qsim().setNodeTransitionLogic(NodeTransition.emptyBufferAfterBufferRandomDistribution_nodeBlockedWhenSingleOutlinkFull); scenario.getConfig().qsim().setUsingFastCapacityUpdate(useFastCapUpdate); - + EventsManager events = EventsUtils.createEventsManager(); List> linksOfInterest = new LinkedList<>(); linksOfInterest.add(Id.createLinkId("2_5")); @@ -314,25 +314,25 @@ public void testBlockedNodeSituationWithEmptyBufferAfterBufferRandomDistribution linksOfInterest.add(Id.createLinkId("5_8")); ThroughputAnalyzer throughputAnalyzer = new ThroughputAnalyzer(linksOfInterest); events.addHandler(throughputAnalyzer); - + PrepareForSimUtils.createDefaultPrepareForSim(scenario).run(); new QSimBuilder(scenario.getConfig()) .useDefaults() .build(scenario, events) .run(); - + // // output for debugging // for (int start = 0; start <= 800; start+=10) { // Map, Double> avgThroughputThisInterval = throughputAnalyzer.calculateAvgThroughputPerTimeStepOfTimeInterval(start, start+10, 1); -// System.out.println("[" + start + ", " + (start+10) + "]. link 2_5: " + avgThroughputThisInterval.get(Id.createLinkId("2_5")) +// System.out.println("[" + start + ", " + (start+10) + "]. link 2_5: " + avgThroughputThisInterval.get(Id.createLinkId("2_5")) // + ", link 4_5: " + avgThroughputThisInterval.get(Id.createLinkId("4_5")) -// + ", link 5_8: " + avgThroughputThisInterval.get(Id.createLinkId("5_8"))); +// + ", link 5_8: " + avgThroughputThisInterval.get(Id.createLinkId("5_8"))); // } // Map, Double> avgThroughputUntil210 = throughputAnalyzer.calculateAvgThroughputPerTimeStepOfTimeInterval(0, 210, 1); // System.out.println("absolute throughput [" + 0 + ", " + 210 + "]. link 2_5: " + (avgThroughputUntil210.get(Id.createLinkId("2_5")) * 210 / 1) // + ", link 4_5: " + (avgThroughputUntil210.get(Id.createLinkId("4_5")) * 210 / 1) ); - + // this is the time before the downstream link (5_8) gets full and with that no inflow capacity is valid and no node is blocked int timeInterval1Start = 110; int timeInterval1End = 200; Map, Double> avgThroughputFreeFlow = throughputAnalyzer.calculateAvgThroughputPerTimeStepOfTimeInterval(timeInterval1Start, timeInterval1End, 1); @@ -347,20 +347,20 @@ public void testBlockedNodeSituationWithEmptyBufferAfterBufferRandomDistribution + "\t; time interval [" + timeInterval2Start + ", " + timeInterval2End + "]: " + avgThroughputCongestedNodeBlocked.get(link) + "\t; time interval [" + timeInterval3Start + ", " + timeInterval3End + "]: " + avgThroughputCongestedRestrictFlow.get(link)); } - - /* since this node dynamic is a random distribution we allow a somewhat bigger difference here. + + /* since this node dynamic is a random distribution we allow a somewhat bigger difference here. * otherwise we would need to run the test for a longer period or different random seeds which would increase the run time of this test. */ double delta = 0.04; - + // test throughput for the first time interval - /* the downstream link is not full, i.e. the links can send vehicles with their full outflow capacity. + /* the downstream link is not full, i.e. the links can send vehicles with their full outflow capacity. * the first vehicles reach the end of link 5_8 around sec 300, i.e. throughput of link 5_8 should be zero here. */ Assert.assertEquals("Troughput on link 2_5 is wrong", 2, avgThroughputFreeFlow.get(Id.createLinkId("2_5")), MatsimTestUtils.EPSILON); Assert.assertEquals("Troughput on link 4_5 is wrong", 1, avgThroughputFreeFlow.get(Id.createLinkId("4_5")), MatsimTestUtils.EPSILON); Assert.assertEquals("Troughput on link 5_8 is wrong", 0, avgThroughputFreeFlow.get(Id.createLinkId("5_8")), MatsimTestUtils.EPSILON); - + // test throughput for the second time interval /* with probability 1/3 link 4_5 is selected first and can send all its vehicles from the buffer (i.e. one) before link 2_5 blocks the intersection. * if link 2_5 is selected first the intersection is blocked immediately. @@ -369,25 +369,25 @@ public void testBlockedNodeSituationWithEmptyBufferAfterBufferRandomDistribution Assert.assertEquals("Troughput on link 2_5 is wrong", 0, avgThroughputCongestedNodeBlocked.get(Id.createLinkId("2_5")), MatsimTestUtils.EPSILON); Assert.assertEquals("Troughput on link 4_5 is wrong", 1./3, avgThroughputCongestedNodeBlocked.get(Id.createLinkId("4_5")), delta); // 0.36666666666666664 Assert.assertEquals("Troughput on link 5_8 is wrong", 0, avgThroughputCongestedNodeBlocked.get(Id.createLinkId("5_8")), MatsimTestUtils.EPSILON); - + // test throughput for the third time interval /* with probability 1/3 link 4_5 is selected first and can send all its vehicles from the buffer (i.e. one) before link 2_5 sends its first one and blocks the intersection. * with probability 2/3 link 2_5 is selected first, sends one vehicle and thereby blocks the intersection. * this means the correct expected throughput values are: 1/3*1 for link 4_5 and 1/3*1 + 2/3*1 = 1 for link 2_5. - * the first vehicles reach the end of link 5_8 around sec 300, i.e. throughput of link 5_8 should be equal to the flow + * the first vehicles reach the end of link 5_8 around sec 300, i.e. throughput of link 5_8 should be equal to the flow * capacity of link 5_8 here, i.e. 1 veh per time step (=sec). */ Assert.assertEquals("Troughput on link 2_5 is wrong", 1, avgThroughputCongestedRestrictFlow.get(Id.createLinkId("2_5")), MatsimTestUtils.EPSILON); Assert.assertEquals("Troughput on link 4_5 is wrong", 1./3, avgThroughputCongestedRestrictFlow.get(Id.createLinkId("4_5")), delta); // 0.3263157894736842 Assert.assertEquals("Troughput on link 5_8 is wrong", 1, avgThroughputCongestedRestrictFlow.get(Id.createLinkId("5_8")), MatsimTestUtils.EPSILON); } - + @Test public void testBlockedNodeSituationWithMoveVehByVehRandomDistribution() { Scenario scenario = Fixture.createBlockedNodeScenario(); scenario.getConfig().qsim().setNodeTransitionLogic(NodeTransition.moveVehByVehRandomDistribution_nodeBlockedWhenSingleOutlinkFull); scenario.getConfig().qsim().setUsingFastCapacityUpdate(useFastCapUpdate); - + EventsManager events = EventsUtils.createEventsManager(); List> linksOfInterest = new LinkedList<>(); linksOfInterest.add(Id.createLinkId("2_5")); @@ -395,25 +395,25 @@ public void testBlockedNodeSituationWithMoveVehByVehRandomDistribution() { linksOfInterest.add(Id.createLinkId("5_8")); ThroughputAnalyzer throughputAnalyzer = new ThroughputAnalyzer(linksOfInterest); events.addHandler(throughputAnalyzer); - + PrepareForSimUtils.createDefaultPrepareForSim(scenario).run(); new QSimBuilder(scenario.getConfig()) .useDefaults() .build(scenario, events) - .run(); + .run(); // // output for debugging // for (int start = 0; start <= 800; start+=10) { // Map, Double> avgThroughputThisInterval = throughputAnalyzer.calculateAvgThroughputPerTimeStepOfTimeInterval(start, start+10, 1); -// System.out.println("[" + start + ", " + (start+10) + "]. link 2_5: " + avgThroughputThisInterval.get(Id.createLinkId("2_5")) +// System.out.println("[" + start + ", " + (start+10) + "]. link 2_5: " + avgThroughputThisInterval.get(Id.createLinkId("2_5")) // + ", link 4_5: " + avgThroughputThisInterval.get(Id.createLinkId("4_5")) -// + ", link 5_8: " + avgThroughputThisInterval.get(Id.createLinkId("5_8"))); +// + ", link 5_8: " + avgThroughputThisInterval.get(Id.createLinkId("5_8"))); // } // Map, Double> avgThroughputUntil210 = throughputAnalyzer.calculateAvgThroughputPerTimeStepOfTimeInterval(0, 210, 1); // System.out.println("absolute throughput [" + 0 + ", " + 210 + "]. link 2_5: " + (avgThroughputUntil210.get(Id.createLinkId("2_5")) * 210 / 1) // + ", link 4_5: " + (avgThroughputUntil210.get(Id.createLinkId("4_5")) * 210 / 1) ); - + // this is the time before the downstream link (5_8) gets full and with that no inflow capacity is valid and no node is blocked int timeInterval1Start = 110; int timeInterval1End = 200; Map, Double> avgThroughputFreeFlow = throughputAnalyzer.calculateAvgThroughputPerTimeStepOfTimeInterval(timeInterval1Start, timeInterval1End, 1); @@ -428,20 +428,20 @@ public void testBlockedNodeSituationWithMoveVehByVehRandomDistribution() { + "\t; time interval [" + timeInterval2Start + ", " + timeInterval2End + "]: " + avgThroughputCongestedNodeBlocked.get(link) + "\t; time interval [" + timeInterval3Start + ", " + timeInterval3End + "]: " + avgThroughputCongestedRestrictFlow.get(link)); } - - /* since this node dynamic is a random distribution we allow a somewhat bigger difference here. + + /* since this node dynamic is a random distribution we allow a somewhat bigger difference here. * otherwise we would need to run the test for a longer period or different random seeds which would increase the run time of this test. */ double delta = 0.02; - + // test throughput for the first time interval - /* the downstream link is not full, i.e. the links can send vehicles with their full outflow capacity. + /* the downstream link is not full, i.e. the links can send vehicles with their full outflow capacity. * the first vehicles reach the end of link 5_8 around sec 300, i.e. throughput of link 5_8 should be zero here. */ Assert.assertEquals("Troughput on link 2_5 is wrong", 2, avgThroughputFreeFlow.get(Id.createLinkId("2_5")), MatsimTestUtils.EPSILON); Assert.assertEquals("Troughput on link 4_5 is wrong", 1, avgThroughputFreeFlow.get(Id.createLinkId("4_5")), MatsimTestUtils.EPSILON); Assert.assertEquals("Troughput on link 5_8 is wrong", 0, avgThroughputFreeFlow.get(Id.createLinkId("5_8")), MatsimTestUtils.EPSILON); - + // test throughput for the second time interval /* with probability 1/3 link 4_5 is selected first and can send one vehicle before link 2_5 blocks the intersection. * if link 2_5 is selected first the intersection is blocked immediately. @@ -450,26 +450,26 @@ public void testBlockedNodeSituationWithMoveVehByVehRandomDistribution() { Assert.assertEquals("Troughput on link 2_5 is wrong", 0, avgThroughputCongestedNodeBlocked.get(Id.createLinkId("2_5")), MatsimTestUtils.EPSILON); Assert.assertEquals("Troughput on link 4_5 is wrong", 1./3, avgThroughputCongestedNodeBlocked.get(Id.createLinkId("4_5")), delta); // 0.3333333333333333 Assert.assertEquals("Troughput on link 5_8 is wrong", 0, avgThroughputCongestedNodeBlocked.get(Id.createLinkId("5_8")), MatsimTestUtils.EPSILON); - + // test throughput for the third time interval /* with probability 1/3 link 4_5 is selected first and can send one vehicle before link 2_5 sends its first one and blocks the intersection. - * with probability 2/3 link 2_5 is selected first and sends one vehicle; + * with probability 2/3 link 2_5 is selected first and sends one vehicle; * afterwards with probability 1/3 link 4_5 sends one vehicle before link 2_5 blocks the intersection, with probability 2/3 it is blocked immediately. * this means the correct expected throughput values are: 1/3*1 + 2/3*1/3*1 = 5/9 for link 4_5 and 1/3*1 + 2/3*1 = 1 for link 2_5. - * the first vehicles reach the end of link 5_8 around sec 300, i.e. throughput of link 5_8 should be equal to the flow + * the first vehicles reach the end of link 5_8 around sec 300, i.e. throughput of link 5_8 should be equal to the flow * capacity of link 5_8 here, i.e. 1 veh per time step (=sec). */ Assert.assertEquals("Troughput on link 2_5 is wrong", 1, avgThroughputCongestedRestrictFlow.get(Id.createLinkId("2_5")), MatsimTestUtils.EPSILON); Assert.assertEquals("Troughput on link 4_5 is wrong", 5./9, avgThroughputCongestedRestrictFlow.get(Id.createLinkId("4_5")), delta); // 0.5736842105263158 Assert.assertEquals("Troughput on link 5_8 is wrong", 1, avgThroughputCongestedRestrictFlow.get(Id.createLinkId("5_8")), MatsimTestUtils.EPSILON); } - + @Test public void testBlockedNodeSituationWithMoveVehByVehDeterministicPriorities() { Scenario scenario = Fixture.createBlockedNodeScenario(); scenario.getConfig().qsim().setNodeTransitionLogic(NodeTransition.moveVehByVehDeterministicPriorities_nodeBlockedWhenSingleOutlinkFull); scenario.getConfig().qsim().setUsingFastCapacityUpdate(useFastCapUpdate); - + EventsManager events = EventsUtils.createEventsManager(); List> linksOfInterest = new LinkedList<>(); linksOfInterest.add(Id.createLinkId("2_5")); @@ -477,25 +477,25 @@ public void testBlockedNodeSituationWithMoveVehByVehDeterministicPriorities() { linksOfInterest.add(Id.createLinkId("5_8")); ThroughputAnalyzer throughputAnalyzer = new ThroughputAnalyzer(linksOfInterest); events.addHandler(throughputAnalyzer); - + PrepareForSimUtils.createDefaultPrepareForSim(scenario).run(); new QSimBuilder(scenario.getConfig()) .useDefaults() .build(scenario, events) .run(); - + // // output for debugging // for (int start = 0; start <= 800; start+=10) { // Map, Double> avgThroughputThisInterval = throughputAnalyzer.calculateAvgThroughputPerTimeStepOfTimeInterval(start, start+10, 1); -// System.out.println("[" + start + ", " + (start+10) + "]. link 2_5: " + avgThroughputThisInterval.get(Id.createLinkId("2_5")) +// System.out.println("[" + start + ", " + (start+10) + "]. link 2_5: " + avgThroughputThisInterval.get(Id.createLinkId("2_5")) // + ", link 4_5: " + avgThroughputThisInterval.get(Id.createLinkId("4_5")) -// + ", link 5_8: " + avgThroughputThisInterval.get(Id.createLinkId("5_8"))); +// + ", link 5_8: " + avgThroughputThisInterval.get(Id.createLinkId("5_8"))); // } // Map, Double> avgThroughputUntil210 = throughputAnalyzer.calculateAvgThroughputPerTimeStepOfTimeInterval(0, 210, 1); // System.out.println("absolute throughput [" + 0 + ", " + 210 + "]. link 2_5: " + (avgThroughputUntil210.get(Id.createLinkId("2_5")) * 210 / 1) // + ", link 4_5: " + (avgThroughputUntil210.get(Id.createLinkId("4_5")) * 210 / 1) ); - + // this is the time before the downstream link (5_8) gets full and with that no inflow capacity is valid and no node is blocked int timeInterval1Start = 110; int timeInterval1End = 200; Map, Double> avgThroughputFreeFlow = throughputAnalyzer.calculateAvgThroughputPerTimeStepOfTimeInterval(timeInterval1Start, timeInterval1End, 1); @@ -510,21 +510,21 @@ public void testBlockedNodeSituationWithMoveVehByVehDeterministicPriorities() { + "\t; time interval [" + timeInterval2Start + ", " + timeInterval2End + "]: " + avgThroughputCongestedNodeBlocked.get(link) + "\t; time interval [" + timeInterval3Start + ", " + timeInterval3End + "]: " + avgThroughputCongestedRestrictFlow.get(link)); } - - /* since this node dynamic does not rely on a random distribution but updates link priorities each time step, - * i.e. remembers decisions made in previous time steps, + + /* since this node dynamic does not rely on a random distribution but updates link priorities each time step, + * i.e. remembers decisions made in previous time steps, * the difference to the expected values should be much smaller compared to the other node transition logic. */ double delta = MatsimTestUtils.EPSILON; - + // test throughput for the first time interval - /* the downstream link is not full, i.e. the links can send vehicles with their full outflow capacity. + /* the downstream link is not full, i.e. the links can send vehicles with their full outflow capacity. * the first vehicles reach the end of link 5_8 around sec 300, i.e. throughput of link 5_8 should be zero here. */ Assert.assertEquals("Troughput on link 2_5 is wrong", 2, avgThroughputFreeFlow.get(Id.createLinkId("2_5")), delta); Assert.assertEquals("Troughput on link 4_5 is wrong", 1, avgThroughputFreeFlow.get(Id.createLinkId("4_5")), delta); Assert.assertEquals("Troughput on link 5_8 is wrong", 0, avgThroughputFreeFlow.get(Id.createLinkId("5_8")), delta); - + // test throughput for the second time interval /* the deterministic node transition should reduce the outflow of all links by the same percentage with which the outflow of links has to be reduced that lead to congested links. * in this case link 2_5 needs to be reduced by 100%, i.e. link 4_5 is also reduced by 100%, i.e. no link is allowed to send vehicles. @@ -534,20 +534,20 @@ public void testBlockedNodeSituationWithMoveVehByVehDeterministicPriorities() { Assert.assertEquals("Troughput on link 2_5 is wrong", 0, avgThroughputCongestedNodeBlocked.get(Id.createLinkId("2_5")), delta); Assert.assertEquals("Troughput on link 4_5 is wrong", 0, avgThroughputCongestedNodeBlocked.get(Id.createLinkId("4_5")), delta); Assert.assertEquals("Troughput on link 5_8 is wrong", 0, avgThroughputCongestedNodeBlocked.get(Id.createLinkId("5_8")), delta); - + // test throughput for the third time interval /* the deterministic node transition should reduce the outflow of all links by the same percentage with which the outflow of links has to be reduced that lead to congested links. * in this case link 2_5 needs to be reduced by 1/2, i.e. link 4_5 is also reduced by 1/2. - * the first vehicles reach the end of link 5_8 around sec 300, i.e. throughput of link 5_8 should be equal to the flow + * the first vehicles reach the end of link 5_8 around sec 300, i.e. throughput of link 5_8 should be equal to the flow * capacity of link 5_8 here, i.e. 1 veh per time step (=sec). */ Assert.assertEquals("Troughput on link 2_5 is wrong", 1./2 * 2, avgThroughputCongestedRestrictFlow.get(Id.createLinkId("2_5")), delta); Assert.assertEquals("Troughput on link 4_5 is wrong", 1./2 * 1, avgThroughputCongestedRestrictFlow.get(Id.createLinkId("4_5")), delta); Assert.assertEquals("Troughput on link 5_8 is wrong", 1, avgThroughputCongestedRestrictFlow.get(Id.createLinkId("5_8")), delta); } - + /** - * Test single intersection scenario with old emptyBufferAfterBuffer node transition and blockNode=false. Use time bin size 0.5 seconds. + * Test single intersection scenario with old emptyBufferAfterBuffer node transition and blockNode=false. Use time bin size 0.5 seconds. * With that the tests validates the following things: * 1. correct throughput for a time bin size smaller than 1 (see e.g. former bug in QueueWithBuffer removeFirstVehicle); * 2. correct storage capacity bounds for a time bin size smaller than 1 (see e.g. former bug in QueueWithBuffer calculateStorageCapacity); @@ -559,7 +559,7 @@ public void testNodeTransitionWithTimeStepSizeSmallerOne() { scenario.getConfig().qsim().setNodeTransitionLogic(NodeTransition.emptyBufferAfterBufferRandomDistribution_dontBlockNode); scenario.getConfig().qsim().setTimeStepSize(0.5); scenario.getConfig().qsim().setUsingFastCapacityUpdate(useFastCapUpdate); - + EventsManager events = EventsUtils.createEventsManager(); List> linksOfInterest = new LinkedList<>(); linksOfInterest.add(Id.createLinkId("2_5")); @@ -567,25 +567,25 @@ public void testNodeTransitionWithTimeStepSizeSmallerOne() { linksOfInterest.add(Id.createLinkId("5_8")); ThroughputAnalyzer throughputAnalyzer = new ThroughputAnalyzer(linksOfInterest); events.addHandler(throughputAnalyzer); - + PrepareForSimUtils.createDefaultPrepareForSim(scenario).run(); new QSimBuilder(scenario.getConfig()) .useDefaults() .build(scenario, events) .run(); - + // // output for debugging // for (int start = 0; start <= 800; start+=10) { // Map, Double> avgThroughputThisInterval = throughputAnalyzer.calculateAvgThroughputPerTimeStepOfTimeInterval(start, start+10, 0.5); -// System.out.println("[" + start + ", " + (start+10) + "]. link 2_5: " + avgThroughputThisInterval.get(Id.createLinkId("2_5")) +// System.out.println("[" + start + ", " + (start+10) + "]. link 2_5: " + avgThroughputThisInterval.get(Id.createLinkId("2_5")) // + ", link 4_5: " + avgThroughputThisInterval.get(Id.createLinkId("4_5")) -// + ", link 5_8: " + avgThroughputThisInterval.get(Id.createLinkId("5_8"))); +// + ", link 5_8: " + avgThroughputThisInterval.get(Id.createLinkId("5_8"))); // } // Map, Double> avgThroughputUntil210 = throughputAnalyzer.calculateAvgThroughputPerTimeStepOfTimeInterval(0, 210, 0.5); // System.out.println("absolute throughput [" + 0 + ", " + 210 + "]. link 2_5: " + (avgThroughputUntil210.get(Id.createLinkId("2_5")) * 210 / 0.5) -// + ", link 4_5: " + (avgThroughputUntil210.get(Id.createLinkId("4_5")) * 210 / 0.5) ); - +// + ", link 4_5: " + (avgThroughputUntil210.get(Id.createLinkId("4_5")) * 210 / 0.5) ); + // this is the time before the downstream link (5_8) gets full and with that no inflow capacity is valid and no node is blocked int timeInterval1Start = 110; int timeInterval1End = 200; Map, Double> avgThroughputFreeFlow = throughputAnalyzer.calculateAvgThroughputPerTimeStepOfTimeInterval(timeInterval1Start, timeInterval1End, 0.5); @@ -600,21 +600,21 @@ public void testNodeTransitionWithTimeStepSizeSmallerOne() { + "\t; time interval [" + timeInterval2Start + ", " + timeInterval2End + "]: " + avgThroughputCongestedNodeBlocked.get(link) + "\t; time interval [" + timeInterval3Start + ", " + timeInterval3End + "]: " + avgThroughputCongestedRestrictFlow.get(link)); } - - /* since this node dynamic does not rely on a random distribution but updates link priorities each time step, - * i.e. remembers decisions made in previous time steps, + + /* since this node dynamic does not rely on a random distribution but updates link priorities each time step, + * i.e. remembers decisions made in previous time steps, * the difference to the expected values should be much smaller compared to the other node transition logic. */ double delta = MatsimTestUtils.EPSILON; - + // test throughput for the first time interval - /* the downstream link is not full, i.e. the links can send vehicles with their full outflow capacity. + /* the downstream link is not full, i.e. the links can send vehicles with their full outflow capacity. * the first vehicles reach the end of link 5_8 around sec 300, i.e. throughput of link 5_8 should be zero here. */ Assert.assertEquals("Troughput on link 2_5 is wrong", 1, avgThroughputFreeFlow.get(Id.createLinkId("2_5")), delta); Assert.assertEquals("Troughput on link 4_5 is wrong", 0.5, avgThroughputFreeFlow.get(Id.createLinkId("4_5")), delta); Assert.assertEquals("Troughput on link 5_8 is wrong", 0.0, avgThroughputFreeFlow.get(Id.createLinkId("5_8")), delta); - + // test throughput for the second time interval /* the downstream link of 2_5 is full, i.e. no vehicles can leave 2_5 in this time interval. * link 4_5 is not affected by this, because blockNodeWhenSingleOutlinkFull is set to false. @@ -623,20 +623,20 @@ public void testNodeTransitionWithTimeStepSizeSmallerOne() { Assert.assertEquals("Troughput on link 2_5 is wrong", 0, avgThroughputCongestedNodeBlocked.get(Id.createLinkId("2_5")), delta); Assert.assertEquals("Troughput on link 4_5 is wrong", 0.5, avgThroughputCongestedNodeBlocked.get(Id.createLinkId("4_5")), delta); Assert.assertEquals("Troughput on link 5_8 is wrong", 0.0, avgThroughputCongestedNodeBlocked.get(Id.createLinkId("5_8")), delta); - + // test throughput for the third time interval /* the downstream link of 2_5 lets 1 veh in every two time steps, i.e. throughput of link 2_5 should be 0.5 per time step. * link 4_5 should still be not affected by this and send vehicles with its outflow capacity, i.e 0.5 per time step. - * the first vehicles reach the end of link 5_8 around sec 300, i.e. throughput of link 5_8 should be equal to the flow + * the first vehicles reach the end of link 5_8 around sec 300, i.e. throughput of link 5_8 should be equal to the flow * capacity of link 5_8 here, i.e. 0.5 veh per time step. */ Assert.assertEquals("Troughput on link 2_5 is wrong", 0.5, avgThroughputCongestedRestrictFlow.get(Id.createLinkId("2_5")), delta); Assert.assertEquals("Troughput on link 4_5 is wrong", 0.5, avgThroughputCongestedRestrictFlow.get(Id.createLinkId("4_5")), delta); Assert.assertEquals("Troughput on link 5_8 is wrong", 0.5, avgThroughputCongestedRestrictFlow.get(Id.createLinkId("5_8")), delta); } - + private static final class Fixture { - + static Scenario createMergeScenario() { MatsimRandom.reset(); Config config = ConfigUtils.createConfig(); @@ -644,10 +644,10 @@ static Scenario createMergeScenario() { config.controler().setLastIteration(0); config.qsim().setStuckTime(24*3600); config.qsim().setRemoveStuckVehicles(false); - PlanCalcScoreConfigGroup.ActivityParams dummyAct = new PlanCalcScoreConfigGroup.ActivityParams("dummy"); + ScoringConfigGroup.ActivityParams dummyAct = new ScoringConfigGroup.ActivityParams("dummy"); dummyAct.setTypicalDuration(12 * 3600); - config.planCalcScore().addActivityParams(dummyAct); - + config.planCalcScore().addActivityParams(dummyAct); + Scenario scenario = ScenarioUtils.createScenario(config); /* build network */ @@ -674,10 +674,10 @@ static Scenario createMergeScenario() { fillPopulationWithOneCommodity(scenario.getPopulation(), 1, 500, 0, link12.getId(), link89.getId()); fillPopulationWithOneCommodity(scenario.getPopulation(), 2, 500, 0, link34.getId(), link89.getId()); fillPopulationWithOneCommodity(scenario.getPopulation(), 2, 250, 250, link56.getId(), link89.getId()); - + return scenario; } - + static Scenario createBlockedNodeScenario() { MatsimRandom.reset(); Config config = ConfigUtils.createConfig(); @@ -685,10 +685,10 @@ static Scenario createBlockedNodeScenario() { config.controler().setLastIteration(0); config.qsim().setStuckTime(24*3600); config.qsim().setRemoveStuckVehicles(false); - PlanCalcScoreConfigGroup.ActivityParams dummyAct = new PlanCalcScoreConfigGroup.ActivityParams("dummy"); + ScoringConfigGroup.ActivityParams dummyAct = new ScoringConfigGroup.ActivityParams("dummy"); dummyAct.setTypicalDuration(12 * 3600); - config.planCalcScore().addActivityParams(dummyAct); - + config.planCalcScore().addActivityParams(dummyAct); + Scenario scenario = ScenarioUtils.createScenario(config); /* build network */ @@ -714,13 +714,13 @@ static Scenario createBlockedNodeScenario() { /* build plans */ fillPopulationWithOneCommodity(scenario.getPopulation(), 2, 500, 0, link12.getId(), link89.getId()); fillPopulationWithOneCommodity(scenario.getPopulation(), 1, 500, 0, link34.getId(), link67.getId()); - + return scenario; } - + private static void fillPopulationWithOneCommodity(Population population, double agentsPerSec, double simulationPeriod, double startTime, Id sourceLink, Id sinkLink) { - + for (int i=0; i< agentsPerSec * simulationPeriod; i++) { // create a person Person person = population.getFactory().createPerson(Id.createPersonId("agent-" + sourceLink + "-" + sinkLink + "-" + i)); @@ -743,21 +743,21 @@ private static void fillPopulationWithOneCommodity(Population population, double plan.addActivity(drainAct); } } - + } - + private final class ThroughputAnalyzer implements LinkLeaveEventHandler { private final List> linksOfInterest; private Map, Map> absoluteThroughputPerTimeStep_veh = new HashMap<>(); - + public ThroughputAnalyzer(List> linksOfInterest) { this.linksOfInterest = linksOfInterest; for (Id link : linksOfInterest) { absoluteThroughputPerTimeStep_veh.put(link, new TreeMap<>()); } } - + @Override public void reset(int iteration) { for (Id link : linksOfInterest) { @@ -777,13 +777,13 @@ public void handleEvent(LinkLeaveEvent event) { } } } - + public Map, Double> calculateAvgThroughputPerTimeStepOfTimeInterval(int startTime, int endTime, double timeStepSize) { Map, Double> avgThroughputPerLink = new HashMap<>(); for (Id link : linksOfInterest) { avgThroughputPerLink.put(link, 0.); } - + // sum up link leave events of this time interval for (double time = startTime; time < endTime; time += timeStepSize) { for (Id link : linksOfInterest) { @@ -796,10 +796,10 @@ public Map, Double> calculateAvgThroughputPerTimeStepOfTimeInterval(int for (Id link : linksOfInterest) { avgThroughputPerLink.put(link, avgThroughputPerLink.get(link) * timeStepSize / (endTime - startTime)); } - + return avgThroughputPerLink; } - + } - + } diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/TeleportationEngineWDistanceCheckTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/TeleportationEngineWDistanceCheckTest.java index 83375ff6dd3..4c6434b2295 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/TeleportationEngineWDistanceCheckTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/TeleportationEngineWDistanceCheckTest.java @@ -39,8 +39,8 @@ import org.matsim.api.core.v01.population.PopulationFactory; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup.ActivityParams; -import org.matsim.core.config.groups.StrategyConfigGroup.StrategySettings; +import org.matsim.core.config.groups.ScoringConfigGroup.ActivityParams; +import org.matsim.core.config.groups.ReplanningConfigGroup.StrategySettings; import org.matsim.core.controler.AbstractModule; import org.matsim.core.controler.Controler; import org.matsim.core.controler.OutputDirectoryHierarchy.OverwriteFileSetting; @@ -55,27 +55,27 @@ */ public class TeleportationEngineWDistanceCheckTest { private static final Logger log = LogManager.getLogger( TeleportationEngineWDistanceCheckTest.class ) ; - + @Rule public MatsimTestUtils utils = new MatsimTestUtils() ; - + @Test public final void test() { Config config = ConfigUtils.createConfig(); config.controler().setOutputDirectory( utils.getOutputDirectory() ); config.controler().setOverwriteFileSetting( OverwriteFileSetting.deleteDirectoryIfExists ); config.controler().setLastIteration(0); - + ActivityParams params = new ActivityParams("dummy" ) ; config.planCalcScore().addActivityParams(params); params.setScoringThisActivityAtAll(false); - + StrategySettings stratSets = new StrategySettings() ; stratSets.setStrategyName( DefaultSelector.ChangeExpBeta.toString() ); stratSets.setWeight(1.); config.strategy().addStrategySettings( stratSets ); - + Scenario scenario = ScenarioUtils.createScenario( config ) ; - + Network network = scenario.getNetwork() ; NetworkFactory nf = network.getFactory() ; @@ -93,13 +93,13 @@ public final void test() { Population population = scenario.getPopulation() ; PopulationFactory pf = population.getFactory() ; - + Person person = pf.createPerson( Id.createPersonId(0) ) ; population.addPerson( person ); - + Plan plan = pf.createPlan(); person.addPlan( plan ) ; - { + { Activity act = pf.createActivityFromCoord("dummy",new Coord(0.,-10000.) ) ; plan.addActivity(act); act.setEndTime(0.); @@ -108,11 +108,11 @@ public final void test() { Leg leg = pf.createLeg( TransportMode.car ) ; plan.addLeg( leg ); } - { + { Activity act = pf.createActivityFromCoord("dummy",new Coord(20000.,-1.) ) ; plan.addActivity(act); } - + Controler controler = new Controler( scenario ) ; controler.addOverridingModule( new AbstractModule(){ @Override public void install() { @@ -120,14 +120,14 @@ public final void test() { @Override public void reset(int iteration) { } @Override public void handleEvent(Event event) { - log.warn( event.toString() ) ; + log.warn( event.toString() ) ; } - + }); } - + }); - + controler.run(); } diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/VehicleSourceTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/VehicleSourceTest.java index 87fa01efee0..5dc91c9df76 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/VehicleSourceTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/VehicleSourceTest.java @@ -37,7 +37,7 @@ import org.matsim.api.core.v01.population.*; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup.ActivityParams; +import org.matsim.core.config.groups.ScoringConfigGroup.ActivityParams; import org.matsim.core.config.groups.QSimConfigGroup; import org.matsim.core.config.groups.QSimConfigGroup.VehiclesSource; import org.matsim.core.controler.AbstractModule; @@ -57,7 +57,7 @@ /** * A test to check the functionality of the VehicleSource. - * + * * @author amit */ @@ -184,7 +184,7 @@ public void install() { Map, Double> travelTime1 = vehicleLinkTravelTimes.get(Id.create("0_bike", Vehicle.class)); Map, Double> travelTime2 = vehicleLinkTravelTimes.get(carId); - int bikeTravelTime = travelTime1.get(Id.create("2", Link.class)).intValue(); + int bikeTravelTime = travelTime1.get(Id.create("2", Link.class)).intValue(); int carTravelTime = travelTime2.get(Id.create("2", Link.class)).intValue(); switch (this.vehiclesSource ) { diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/FlowEfficiencyCalculatorTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/FlowEfficiencyCalculatorTest.java index f4c7741a970..1a51f5b5df0 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/FlowEfficiencyCalculatorTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/FlowEfficiencyCalculatorTest.java @@ -37,7 +37,7 @@ import org.matsim.core.api.experimental.events.EventsManager; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup.ActivityParams; +import org.matsim.core.config.groups.ScoringConfigGroup.ActivityParams; import org.matsim.core.controler.AbstractModule; import org.matsim.core.controler.Controler; import org.matsim.core.controler.OutputDirectoryHierarchy.OverwriteFileSetting; diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/SimulatedLaneFlowCapacityTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/SimulatedLaneFlowCapacityTest.java index cbb4f9fcea2..4f76e86fd33 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/SimulatedLaneFlowCapacityTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/SimulatedLaneFlowCapacityTest.java @@ -48,7 +48,7 @@ import org.matsim.core.api.experimental.events.handler.LaneLeaveEventHandler; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup.ActivityParams; +import org.matsim.core.config.groups.ScoringConfigGroup.ActivityParams; import org.matsim.core.controler.PrepareForSimUtils; import org.matsim.core.events.EventsUtils; import org.matsim.core.mobsim.qsim.QSimBuilder; diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/VehicleHandlerTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/VehicleHandlerTest.java index dda8873ec28..1d6b9db0cb9 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/VehicleHandlerTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/VehicleHandlerTest.java @@ -44,7 +44,7 @@ import org.matsim.core.api.experimental.events.EventsManager; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup.ActivityParams; +import org.matsim.core.config.groups.ScoringConfigGroup.ActivityParams; import org.matsim.core.controler.AbstractModule; import org.matsim.core.controler.Controler; import org.matsim.core.controler.OutputDirectoryHierarchy.OverwriteFileSetting; diff --git a/matsim/src/test/java/org/matsim/core/population/routes/RouteFactoryIntegrationTest.java b/matsim/src/test/java/org/matsim/core/population/routes/RouteFactoryIntegrationTest.java index 9aa09ca65bb..4c9895183a2 100644 --- a/matsim/src/test/java/org/matsim/core/population/routes/RouteFactoryIntegrationTest.java +++ b/matsim/src/test/java/org/matsim/core/population/routes/RouteFactoryIntegrationTest.java @@ -26,7 +26,7 @@ import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.population.*; import org.matsim.core.config.Config; -import org.matsim.core.config.groups.StrategyConfigGroup.StrategySettings; +import org.matsim.core.config.groups.ReplanningConfigGroup.StrategySettings; import org.matsim.core.controler.Controler; import org.matsim.core.population.routes.heavycompressed.HeavyCompressedNetworkRoute; import org.matsim.core.population.routes.heavycompressed.HeavyCompressedNetworkRouteFactory; @@ -78,7 +78,7 @@ public void testRouteFactoryIntegration() { Leg leg = (Leg) pe; Route route = leg.getRoute(); Assert.assertTrue(route instanceof NetworkRoute || route instanceof GenericRouteImpl ); // that must be different from the class used below - // yy I added the "|| route instanceof GenericRouteImpl" to compensate for the added walk legs; a more precise + // yy I added the "|| route instanceof GenericRouteImpl" to compensate for the added walk legs; a more precise // test would be better. kai, feb'16 } } @@ -107,7 +107,7 @@ public void testRouteFactoryIntegration() { Route route = leg.getRoute(); Assert.assertTrue("person: " + person.getId() + "; plan: " + planCounter, route instanceof HeavyCompressedNetworkRoute || route instanceof GenericRouteImpl ); - // yy I added the "|| route instanceof GenericRouteImpl" to compensate for the added walk legs; a more precise + // yy I added the "|| route instanceof GenericRouteImpl" to compensate for the added walk legs; a more precise // test would be better. kai, feb'16 } } diff --git a/matsim/src/test/java/org/matsim/core/replanning/annealing/ReplanningAnnealerTest.java b/matsim/src/test/java/org/matsim/core/replanning/annealing/ReplanningAnnealerTest.java index 03c88662950..246bc407f50 100644 --- a/matsim/src/test/java/org/matsim/core/replanning/annealing/ReplanningAnnealerTest.java +++ b/matsim/src/test/java/org/matsim/core/replanning/annealing/ReplanningAnnealerTest.java @@ -10,7 +10,7 @@ import org.matsim.api.core.v01.Scenario; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.StrategyConfigGroup; +import org.matsim.core.config.groups.ReplanningConfigGroup; import org.matsim.core.controler.Controler; import org.matsim.core.replanning.StrategyManager; import org.matsim.core.scenario.ScenarioUtils; @@ -167,15 +167,15 @@ public void setup() { this.saConfigVar = new ReplanningAnnealerConfigGroup.AnnealingVariable(); this.saConfig.addAnnealingVariable(this.saConfigVar); - StrategyConfigGroup.StrategySettings s1 = new StrategyConfigGroup.StrategySettings(); + ReplanningConfigGroup.StrategySettings s1 = new ReplanningConfigGroup.StrategySettings(); s1.setStrategyName("ReRoute"); s1.setWeight(0.2); this.config.strategy().addStrategySettings(s1); - StrategyConfigGroup.StrategySettings s2 = new StrategyConfigGroup.StrategySettings(); + ReplanningConfigGroup.StrategySettings s2 = new ReplanningConfigGroup.StrategySettings(); s2.setStrategyName("SubtourModeChoice"); s2.setWeight(0.2); this.config.strategy().addStrategySettings(s2); - StrategyConfigGroup.StrategySettings s3 = new StrategyConfigGroup.StrategySettings(); + ReplanningConfigGroup.StrategySettings s3 = new ReplanningConfigGroup.StrategySettings(); s3.setStrategyName("ChangeExpBeta"); // shouldn't be affected s3.setWeight(0.5); this.config.strategy().addStrategySettings(s3); @@ -360,7 +360,7 @@ public void testSubpopulationAnneal() throws IOException { this.saConfigVar.setStartValue(0.5); this.saConfigVar.setDefaultSubpopulation(targetSubpop); this.config.strategy().getStrategySettings().forEach(s -> s.setSubpopulation(targetSubpop)); - StrategyConfigGroup.StrategySettings s = new StrategyConfigGroup.StrategySettings(); + ReplanningConfigGroup.StrategySettings s = new ReplanningConfigGroup.StrategySettings(); s.setStrategyName("TimeAllocationMutator"); s.setWeight(0.25); s.setSubpopulation("noAnneal"); diff --git a/matsim/src/test/java/org/matsim/core/replanning/strategies/InnovationSwitchOffTest.java b/matsim/src/test/java/org/matsim/core/replanning/strategies/InnovationSwitchOffTest.java index d96d29b24aa..2990671c8f6 100644 --- a/matsim/src/test/java/org/matsim/core/replanning/strategies/InnovationSwitchOffTest.java +++ b/matsim/src/test/java/org/matsim/core/replanning/strategies/InnovationSwitchOffTest.java @@ -18,7 +18,7 @@ * *********************************************************************** */ /** - * + * */ package org.matsim.core.replanning.strategies; @@ -31,8 +31,8 @@ import org.matsim.api.core.v01.Id; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup.ActivityParams; -import org.matsim.core.config.groups.StrategyConfigGroup.StrategySettings; +import org.matsim.core.config.groups.ScoringConfigGroup.ActivityParams; +import org.matsim.core.config.groups.ReplanningConfigGroup.StrategySettings; import org.matsim.core.controler.*; import org.matsim.core.controler.AbstractModule; import org.matsim.core.controler.Injector; diff --git a/matsim/src/test/java/org/matsim/core/router/AStarEuclideanTest.java b/matsim/src/test/java/org/matsim/core/router/AStarEuclideanTest.java index 1892e6324ba..7d005bcac3f 100644 --- a/matsim/src/test/java/org/matsim/core/router/AStarEuclideanTest.java +++ b/matsim/src/test/java/org/matsim/core/router/AStarEuclideanTest.java @@ -21,7 +21,7 @@ package org.matsim.core.router; import org.matsim.api.core.v01.network.Network; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; import org.matsim.core.router.costcalculators.FreespeedTravelTimeAndDisutility; import org.matsim.core.router.util.LeastCostPathCalculator; import org.matsim.core.router.util.PreProcessEuclidean; @@ -30,7 +30,7 @@ public class AStarEuclideanTest extends AbstractLeastCostPathCalculatorTest { @Override protected LeastCostPathCalculator getLeastCostPathCalculator(Network network) { - FreespeedTravelTimeAndDisutility travelTimeCostCalculator = new FreespeedTravelTimeAndDisutility(new PlanCalcScoreConfigGroup()); + FreespeedTravelTimeAndDisutility travelTimeCostCalculator = new FreespeedTravelTimeAndDisutility(new ScoringConfigGroup()); PreProcessEuclidean preProcessData = new PreProcessEuclidean(travelTimeCostCalculator); preProcessData.run(network); return new AStarEuclidean(network, preProcessData, travelTimeCostCalculator); diff --git a/matsim/src/test/java/org/matsim/core/router/AStarLandmarksTest.java b/matsim/src/test/java/org/matsim/core/router/AStarLandmarksTest.java index 80797fa250e..8a5b7f711f1 100644 --- a/matsim/src/test/java/org/matsim/core/router/AStarLandmarksTest.java +++ b/matsim/src/test/java/org/matsim/core/router/AStarLandmarksTest.java @@ -21,7 +21,7 @@ package org.matsim.core.router; import org.matsim.api.core.v01.network.Network; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; import org.matsim.core.router.costcalculators.FreespeedTravelTimeAndDisutility; import org.matsim.core.router.util.LeastCostPathCalculator; import org.matsim.core.router.util.PreProcessLandmarks; @@ -30,7 +30,7 @@ public class AStarLandmarksTest extends AbstractLeastCostPathCalculatorTest { @Override protected LeastCostPathCalculator getLeastCostPathCalculator(Network network) { - FreespeedTravelTimeAndDisutility travelTimeCostCalculator = new FreespeedTravelTimeAndDisutility(new PlanCalcScoreConfigGroup()); + FreespeedTravelTimeAndDisutility travelTimeCostCalculator = new FreespeedTravelTimeAndDisutility(new ScoringConfigGroup()); PreProcessLandmarks preProcessData = new PreProcessLandmarks(travelTimeCostCalculator); preProcessData.run(network); return new AStarLandmarks(network, preProcessData, travelTimeCostCalculator); diff --git a/matsim/src/test/java/org/matsim/core/router/DijkstraTest.java b/matsim/src/test/java/org/matsim/core/router/DijkstraTest.java index 8a1660e7360..99bd6b09de4 100644 --- a/matsim/src/test/java/org/matsim/core/router/DijkstraTest.java +++ b/matsim/src/test/java/org/matsim/core/router/DijkstraTest.java @@ -21,7 +21,7 @@ package org.matsim.core.router; import org.matsim.api.core.v01.network.Network; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; import org.matsim.core.router.costcalculators.FreespeedTravelTimeAndDisutility; import org.matsim.core.router.util.LeastCostPathCalculator; @@ -32,7 +32,7 @@ public class DijkstraTest extends AbstractLeastCostPathCalculatorTest { @Override protected LeastCostPathCalculator getLeastCostPathCalculator(final Network network) { - FreespeedTravelTimeAndDisutility travelTimeCostCalculator = new FreespeedTravelTimeAndDisutility(new PlanCalcScoreConfigGroup()); + FreespeedTravelTimeAndDisutility travelTimeCostCalculator = new FreespeedTravelTimeAndDisutility(new ScoringConfigGroup()); return new Dijkstra(network, travelTimeCostCalculator, travelTimeCostCalculator); } diff --git a/matsim/src/test/java/org/matsim/core/router/FallbackRoutingModuleTest.java b/matsim/src/test/java/org/matsim/core/router/FallbackRoutingModuleTest.java index 413a557987a..c0e333894a7 100644 --- a/matsim/src/test/java/org/matsim/core/router/FallbackRoutingModuleTest.java +++ b/matsim/src/test/java/org/matsim/core/router/FallbackRoutingModuleTest.java @@ -19,12 +19,11 @@ import org.matsim.api.core.v01.population.PopulationFactory; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.StrategyConfigGroup; +import org.matsim.core.config.groups.ReplanningConfigGroup; import org.matsim.core.controler.AbstractModule; import org.matsim.core.controler.Controler; import org.matsim.core.replanning.strategies.DefaultPlanStrategiesModule; import org.matsim.core.scenario.ScenarioUtils; -import org.matsim.facilities.Facility; import org.matsim.testcases.MatsimTestUtils; public class FallbackRoutingModuleTest{ @@ -37,7 +36,7 @@ public void calcRoute(){ config.controler().setOutputDirectory( utils.getOutputDirectory() ); config.controler().setLastIteration( 1 ); - StrategyConfigGroup.StrategySettings sets = new StrategyConfigGroup.StrategySettings(); + ReplanningConfigGroup.StrategySettings sets = new ReplanningConfigGroup.StrategySettings(); sets.setStrategyName( DefaultPlanStrategiesModule.DefaultStrategy.ReRoute ); sets.setWeight( 1. ); config.strategy().addStrategySettings( sets ); diff --git a/matsim/src/test/java/org/matsim/core/router/NetworkRoutingInclAccessEgressModuleTest.java b/matsim/src/test/java/org/matsim/core/router/NetworkRoutingInclAccessEgressModuleTest.java index 61c3b7c51c3..690cb4fed27 100644 --- a/matsim/src/test/java/org/matsim/core/router/NetworkRoutingInclAccessEgressModuleTest.java +++ b/matsim/src/test/java/org/matsim/core/router/NetworkRoutingInclAccessEgressModuleTest.java @@ -16,11 +16,11 @@ import org.matsim.api.core.v01.population.*; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; -import org.matsim.core.config.groups.PlansCalcRouteConfigGroup; -import org.matsim.core.config.groups.PlansCalcRouteConfigGroup.AccessEgressType; +import org.matsim.core.config.groups.ReplanningConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; +import org.matsim.core.config.groups.RoutingConfigGroup; +import org.matsim.core.config.groups.RoutingConfigGroup.AccessEgressType; import org.matsim.core.config.groups.QSimConfigGroup; -import org.matsim.core.config.groups.StrategyConfigGroup; import org.matsim.core.controler.AbstractModule; import org.matsim.core.controler.Controler; import org.matsim.core.controler.OutputDirectoryHierarchy; @@ -107,17 +107,17 @@ private Config createConfig() { config.controler().setLastIteration(0); config.controler().setOutputDirectory(utils.getOutputDirectory()); config.controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles); - config.plansCalcRoute().setAccessEgressType(PlansCalcRouteConfigGroup.AccessEgressType.accessEgressModeToLink); + config.plansCalcRoute().setAccessEgressType(RoutingConfigGroup.AccessEgressType.accessEgressModeToLink); - final PlanCalcScoreConfigGroup.ActivityParams homeParams = new PlanCalcScoreConfigGroup.ActivityParams("home"); + final ScoringConfigGroup.ActivityParams homeParams = new ScoringConfigGroup.ActivityParams("home"); homeParams.setTypicalDuration(1); config.planCalcScore().addActivityParams(homeParams); - final PlanCalcScoreConfigGroup.ActivityParams workParams = new PlanCalcScoreConfigGroup.ActivityParams("work"); + final ScoringConfigGroup.ActivityParams workParams = new ScoringConfigGroup.ActivityParams("work"); workParams.setTypicalDuration(1); config.planCalcScore().addActivityParams(workParams); - StrategyConfigGroup.StrategySettings replanning = new StrategyConfigGroup.StrategySettings(); + ReplanningConfigGroup.StrategySettings replanning = new ReplanningConfigGroup.StrategySettings(); replanning.setStrategyName("ReRoute"); replanning.setWeight(1.0); config.strategy().addStrategySettings(replanning); @@ -188,13 +188,13 @@ public void calcRoute_modeVehiclesFromVehiclesData_differentTypesTakeDifferentRo config.qsim().setVehiclesSource(QSimConfigGroup.VehiclesSource.modeVehicleTypesFromVehiclesData); config.qsim().setMainModes(modes); config.plansCalcRoute().setNetworkModes(modes); - PlanCalcScoreConfigGroup scoring = config.planCalcScore(); + ScoringConfigGroup scoring = config.planCalcScore(); - PlanCalcScoreConfigGroup.ModeParams slowParams = new PlanCalcScoreConfigGroup.ModeParams(SLOW_MODE); + ScoringConfigGroup.ModeParams slowParams = new ScoringConfigGroup.ModeParams(SLOW_MODE); slowParams.setMarginalUtilityOfTraveling(-1); scoring.addModeParams(slowParams); - PlanCalcScoreConfigGroup.ModeParams fastParams = new PlanCalcScoreConfigGroup.ModeParams(FAST_MODE); + ScoringConfigGroup.ModeParams fastParams = new ScoringConfigGroup.ModeParams(FAST_MODE); fastParams.setMarginalUtilityOfTraveling(-1); scoring.addModeParams(fastParams); @@ -263,7 +263,7 @@ public void useAccessEgressTimeFromLinkAttributes() { Config config = createConfig(); config.qsim().setVehiclesSource(QSimConfigGroup.VehiclesSource.defaultVehicle); - config.plansCalcRoute().setAccessEgressType(PlansCalcRouteConfigGroup.AccessEgressType.walkConstantTimeToLink); + config.plansCalcRoute().setAccessEgressType(RoutingConfigGroup.AccessEgressType.walkConstantTimeToLink); Scenario scenario = createScenario(config); NetworkUtils.setLinkAccessTime(scenario.getNetwork().getLinks().get(Id.createLinkId(START_LINK)),TransportMode.car,75); NetworkUtils.setLinkEgressTime(scenario.getNetwork().getLinks().get(Id.createLinkId(END_LINK)),TransportMode.car,180); @@ -284,7 +284,7 @@ public void useAccessEgressTimeFromConstantAndWalkTime() { Config config = createConfig(); config.qsim().setVehiclesSource(QSimConfigGroup.VehiclesSource.defaultVehicle); - config.plansCalcRoute().setAccessEgressType(PlansCalcRouteConfigGroup.AccessEgressType.accessEgressModeToLinkPlusTimeConstant); + config.plansCalcRoute().setAccessEgressType(RoutingConfigGroup.AccessEgressType.accessEgressModeToLinkPlusTimeConstant); Scenario scenario = createScenario(config); NetworkUtils.setLinkAccessTime(scenario.getNetwork().getLinks().get(Id.createLinkId(START_LINK)),TransportMode.car,75); NetworkUtils.setLinkEgressTime(scenario.getNetwork().getLinks().get(Id.createLinkId(END_LINK)),TransportMode.car,180); @@ -301,13 +301,13 @@ public void useAccessEgressTimeFromConstantAndWalkTime() { Assert.equals(90.0,legs.get(0).getTravelTime().seconds()); Assert.equals(180.0,legs.get(2).getTravelTime().seconds()); } - + @Test public void routingModeInEvents() { Config config = createConfig(); config.qsim().setVehiclesSource(QSimConfigGroup.VehiclesSource.defaultVehicle); - config.plansCalcRoute().setAccessEgressType(PlansCalcRouteConfigGroup.AccessEgressType.accessEgressModeToLinkPlusTimeConstant); + config.plansCalcRoute().setAccessEgressType(RoutingConfigGroup.AccessEgressType.accessEgressModeToLinkPlusTimeConstant); Scenario scenario = createScenario(config); NetworkUtils.setLinkAccessTime(scenario.getNetwork().getLinks().get(Id.createLinkId(START_LINK)),TransportMode.car,75); NetworkUtils.setLinkEgressTime(scenario.getNetwork().getLinks().get(Id.createLinkId(END_LINK)),TransportMode.car,180); @@ -318,10 +318,10 @@ public void routingModeInEvents() { scenario.getPopulation().addPerson(person); Controler controler = createControler(scenario); - + Set legModes = new HashSet<>(); Set routingModes = new HashSet<>(); - + controler.addOverridingModule(new AbstractModule() { @Override public void install() { @@ -334,9 +334,9 @@ public void handleEvent(PersonDepartureEvent event) { }); } }); - + controler.run(); - + Assert.equals(2, legModes.size()); Assert.equals(1, routingModes.size()); Assert.isTrue(legModes.contains("walk")); @@ -349,7 +349,7 @@ public void failifNoAccessTimeSet() { Config config = createConfig(); config.qsim().setVehiclesSource(QSimConfigGroup.VehiclesSource.defaultVehicle); - config.plansCalcRoute().setAccessEgressType(PlansCalcRouteConfigGroup.AccessEgressType.walkConstantTimeToLink); + config.plansCalcRoute().setAccessEgressType(RoutingConfigGroup.AccessEgressType.walkConstantTimeToLink); Scenario scenario = createScenario(config); NetworkUtils.setLinkAccessTime(scenario.getNetwork().getLinks().get(Id.createLinkId(START_LINK)),TransportMode.car,75); Person person = createPerson("slow-person", TransportMode.car, scenario.getPopulation().getFactory()); @@ -378,7 +378,7 @@ public void calcAccessTimeFromDistanceToLink() { Config config = createConfig(); config.qsim().setVehiclesSource(QSimConfigGroup.VehiclesSource.defaultVehicle); - config.plansCalcRoute().setAccessEgressType(PlansCalcRouteConfigGroup.AccessEgressType.accessEgressModeToLink); + config.plansCalcRoute().setAccessEgressType(RoutingConfigGroup.AccessEgressType.accessEgressModeToLink); Scenario scenario = createScenario(config); NetworkUtils.setLinkAccessTime(scenario.getNetwork().getLinks().get(Id.createLinkId(START_LINK)),TransportMode.car,75); NetworkUtils.setLinkAccessTime(scenario.getNetwork().getLinks().get(Id.createLinkId(END_LINK)),TransportMode.car,180); diff --git a/matsim/src/test/java/org/matsim/core/router/PseudoTransitRoutingModuleTest.java b/matsim/src/test/java/org/matsim/core/router/PseudoTransitRoutingModuleTest.java index a7a9630d4d9..4ebffe620d6 100644 --- a/matsim/src/test/java/org/matsim/core/router/PseudoTransitRoutingModuleTest.java +++ b/matsim/src/test/java/org/matsim/core/router/PseudoTransitRoutingModuleTest.java @@ -37,7 +37,7 @@ import org.matsim.api.core.v01.population.Person; import org.matsim.api.core.v01.population.PlanElement; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.PlansCalcRouteConfigGroup.TeleportedModeParams; +import org.matsim.core.config.groups.RoutingConfigGroup.TeleportedModeParams; import org.matsim.core.controler.AbstractModule; import org.matsim.core.controler.ControlerDefaultsModule; import org.matsim.core.controler.Injector; @@ -65,7 +65,7 @@ public void testRouteLeg() { final Fixture f = new Fixture(); FreespeedTravelTimeAndDisutility freespeed = new FreespeedTravelTimeAndDisutility(-6.0/3600, +6.0/3600, 0.0); LeastCostPathCalculator routeAlgo = new Dijkstra(f.s.getNetwork(), freespeed, freespeed); - + Person person = PopulationUtils.getFactory().createPerson(Id.create(1, Person.class)); Leg leg = PopulationUtils.createLeg(TransportMode.pt); Activity fromAct = PopulationUtils.createActivityFromCoord("h", new Coord(0, 0)); @@ -98,14 +98,14 @@ public void testRouteLeg() { // the following test is newer than the ones above. I wanted to test the freespeed limit. But could not do it in the same way // above since it is not in FreespeedTravelTimeAndDisutility. Could have modified that disutility. But preferred to test in context. // Thus the more complicated injector thing. kai, nov'16 - + TeleportedModeParams params = new TeleportedModeParams("mode") ; params.setTeleportedModeFreespeedFactor(2.); params.setBeelineDistanceFactor(1.); params.setTeleportedModeFreespeedLimit(5.); f.s.getConfig().plansCalcRoute().addModeRoutingParams(params); f.s.getConfig().controler().setOutputDirectory(utils.getOutputDirectory()); - + com.google.inject.Injector injector = Injector.createInjector(f.s.getConfig(), new AbstractModule() { @Override public void install() { install(new NewControlerModule()); @@ -114,12 +114,12 @@ public void testRouteLeg() { install(new ScenarioByInstanceModule(f.s)); } }); - + TripRouter tripRouter = injector.getInstance(TripRouter.class) ; - + Facility fromFacility = FacilitiesUtils.toFacility(fromAct, f.s.getActivityFacilities() ) ; Facility toFacility = FacilitiesUtils.toFacility(toAct, f.s.getActivityFacilities() ); - + List result = tripRouter.calcRoute("mode", fromFacility, toFacility, 7.0*3600., person, new AttributesImpl()) ; Gbl.assertIf( result.size()==1); Leg newLeg = (Leg) result.get(0) ; @@ -139,7 +139,7 @@ public Fixture() { walk.setBeelineDistanceFactor(1.3); walk.setTeleportedModeSpeed(3.0 / 3.6); s.getConfig().plansCalcRoute().addModeRoutingParams(walk); - + Network net = this.s.getNetwork(); NetworkFactory nf = net.getFactory(); Node n1 = nf.createNode(Id.create("1", Node.class), new Coord(0, 0)); diff --git a/matsim/src/test/java/org/matsim/core/router/TripRouterFactoryImplTest.java b/matsim/src/test/java/org/matsim/core/router/TripRouterFactoryImplTest.java index 43e9fb87900..5e9d9853808 100644 --- a/matsim/src/test/java/org/matsim/core/router/TripRouterFactoryImplTest.java +++ b/matsim/src/test/java/org/matsim/core/router/TripRouterFactoryImplTest.java @@ -33,7 +33,7 @@ import org.matsim.api.core.v01.population.PlanElement; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.PlansCalcRouteConfigGroup; +import org.matsim.core.config.groups.RoutingConfigGroup; import org.matsim.core.controler.AbstractModule; import org.matsim.core.controler.Injector; import org.matsim.core.population.PopulationUtils; @@ -44,7 +44,6 @@ import org.matsim.core.scenario.ScenarioUtils; import org.matsim.core.utils.timing.TimeInterpretationModule; import org.matsim.facilities.Facility; -import org.matsim.utils.objectattributes.attributable.Attributes; import org.matsim.utils.objectattributes.attributable.AttributesImpl; import jakarta.inject.Provider; @@ -131,7 +130,7 @@ public void install() { PopulationUtils.getFactory().createPerson(Id.create("toto", Person.class)), new AttributesImpl()); Leg l = (Leg) trip.get( 0 ); - if ( !scenario.getConfig().plansCalcRoute().getAccessEgressType().equals(PlansCalcRouteConfigGroup.AccessEgressType.none) ) { + if ( !scenario.getConfig().plansCalcRoute().getAccessEgressType().equals(RoutingConfigGroup.AccessEgressType.none) ) { l = (Leg) trip.get(2) ; } @@ -207,7 +206,7 @@ public void install() { PopulationUtils.getFactory().createPerson(Id.create("toto", Person.class)), new AttributesImpl()); Leg l = (Leg) trip.get( 0 ); - if ( !scenario.getConfig().plansCalcRoute().getAccessEgressType().equals(PlansCalcRouteConfigGroup.AccessEgressType.none) ) { + if ( !scenario.getConfig().plansCalcRoute().getAccessEgressType().equals(RoutingConfigGroup.AccessEgressType.none) ) { l = (Leg) trip.get(2) ; } diff --git a/matsim/src/test/java/org/matsim/core/router/TripRouterModuleTest.java b/matsim/src/test/java/org/matsim/core/router/TripRouterModuleTest.java index 0515a70156a..f84b849fac4 100644 --- a/matsim/src/test/java/org/matsim/core/router/TripRouterModuleTest.java +++ b/matsim/src/test/java/org/matsim/core/router/TripRouterModuleTest.java @@ -28,7 +28,7 @@ import org.matsim.api.core.v01.Scenario; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.ControlerConfigGroup; +import org.matsim.core.config.groups.ControllerConfigGroup; import org.matsim.core.controler.ControlerDefaults; import org.matsim.core.router.util.LeastCostPathCalculator; import org.matsim.core.router.util.LeastCostPathCalculatorFactory; @@ -43,7 +43,7 @@ public class TripRouterModuleTest { @Test public void testRouterCreation() { - for (ControlerConfigGroup.RoutingAlgorithmType routingAlgorithmType : ControlerConfigGroup.RoutingAlgorithmType.values()) { + for (ControllerConfigGroup.RoutingAlgorithmType routingAlgorithmType : ControllerConfigGroup.RoutingAlgorithmType.values()) { Config config = ConfigUtils.createConfig(); config.controler().setRoutingAlgorithmType(routingAlgorithmType); Scenario scenario = ScenarioUtils.createScenario(config); diff --git a/matsim/src/test/java/org/matsim/core/router/costcalculators/RandomizingTimeDistanceTravelDisutilityTest.java b/matsim/src/test/java/org/matsim/core/router/costcalculators/RandomizingTimeDistanceTravelDisutilityTest.java index cd4e2a72f30..cb5e6bbfbb6 100644 --- a/matsim/src/test/java/org/matsim/core/router/costcalculators/RandomizingTimeDistanceTravelDisutilityTest.java +++ b/matsim/src/test/java/org/matsim/core/router/costcalculators/RandomizingTimeDistanceTravelDisutilityTest.java @@ -39,8 +39,8 @@ import org.matsim.api.core.v01.population.PlanElement; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup.ModeParams; +import org.matsim.core.config.groups.ScoringConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup.ModeParams; import org.matsim.core.population.PopulationUtils; import org.matsim.core.population.routes.NetworkRoute; import org.matsim.core.router.DefaultRoutingRequest; @@ -58,46 +58,46 @@ public class RandomizingTimeDistanceTravelDisutilityTest { @Test public void testRoutesForDifferentSigmas() { - + { Set routes = new HashSet<>(); for (int i = 0; i<=5; i++) { NetworkRoute route = computeRoute(0.); - routes.add(route.getLinkIds().toString()); + routes.add(route.getLinkIds().toString()); } System.out.println("Route (sigma = 0.0): " + routes.toString()); Assert.assertEquals("There should only be a single route in the sigma = 0 case.", 1, routes.size()); } - + { Set routes = new HashSet<>(); for (int i = 0; i<=5; i++) { NetworkRoute route = computeRoute(3.); - routes.add(route.getLinkIds().toString()); + routes.add(route.getLinkIds().toString()); } System.out.println("Route (sigma = 3.0): " + routes.toString()); Assert.assertEquals("There should be two routes in the sigma = 3 case.", 2, routes.size()); } } - + public NetworkRoute computeRoute(double sigma) { Fixture f = new Fixture(); // PlanCalcScoreConfigGroup planCalcScoreCfg = new PlanCalcScoreConfigGroup(); Config config = ConfigUtils.createConfig(); - PlanCalcScoreConfigGroup planCalcScoreCfg = config.planCalcScore(); + ScoringConfigGroup planCalcScoreCfg = config.planCalcScore(); ModeParams modeParams = new ModeParams(TransportMode.car); modeParams.setMonetaryDistanceRate(-0.1); planCalcScoreCfg.addModeParams(modeParams); config.plansCalcRoute().setRoutingRandomness( sigma ); - + RandomizingTimeDistanceTravelDisutilityFactory factory = new RandomizingTimeDistanceTravelDisutilityFactory(TransportMode.car, config); TravelTimeCalculator.Builder builder = new TravelTimeCalculator.Builder(f.s.getNetwork()); - TravelTimeCalculator calculator = builder.build(); - + TravelTimeCalculator calculator = builder.build(); + TravelTime travelTime = calculator.getLinkTravelTimes(); TravelDisutility disutility = factory.createTravelDisutility(travelTime); LeastCostPathCalculator router = TripRouterFactoryBuilderWithDefaults.createDefaultLeastCostPathCalculatorFactory(f.s).createPathCalculator(f.s.getNetwork(), disutility, travelTime); - + Person person = PopulationUtils.getFactory().createPerson(Id.create(1, Person.class)); Activity fromAct = PopulationUtils.createActivityFromCoord("h", new Coord(0, 0)); fromAct.setLinkId(Id.create("1", Link.class)); @@ -113,7 +113,7 @@ public NetworkRoute computeRoute(double sigma) { Facility toFacility = FacilitiesUtils.toFacility( toAct, f.s.getActivityFacilities() ); List result = routingModule.calcRoute(DefaultRoutingRequest.withoutAttributes(fromFacility, toFacility, 7.0*3600, person)) ; Assert.assertEquals(1, result.size() ); - Leg leg = (Leg) result.get(0) ; + Leg leg = (Leg) result.get(0) ; return (NetworkRoute) leg.getRoute(); } diff --git a/matsim/src/test/java/org/matsim/core/router/old/PlanRouterTest.java b/matsim/src/test/java/org/matsim/core/router/old/PlanRouterTest.java index 3437b92c3cd..8663820a80c 100644 --- a/matsim/src/test/java/org/matsim/core/router/old/PlanRouterTest.java +++ b/matsim/src/test/java/org/matsim/core/router/old/PlanRouterTest.java @@ -32,7 +32,7 @@ import org.matsim.api.core.v01.population.PlanElement; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.PlansCalcRouteConfigGroup; +import org.matsim.core.config.groups.RoutingConfigGroup; import org.matsim.core.controler.AbstractModule; import org.matsim.core.controler.Injector; import org.matsim.core.population.routes.NetworkRoute; @@ -80,7 +80,7 @@ public void install() { ((NetworkRoute) TripStructureUtils.getLegs(plan).get(0).getRoute()).setVehicleId(vehicleId); testee.run(plan); - if ( config.plansCalcRoute().getAccessEgressType().equals(PlansCalcRouteConfigGroup.AccessEgressType.none) ) { + if ( config.plansCalcRoute().getAccessEgressType().equals(RoutingConfigGroup.AccessEgressType.none) ) { Assert.assertEquals("Vehicle Id transferred to new Plan", vehicleId, ((NetworkRoute) TripStructureUtils.getLegs(plan).get(0).getRoute()).getVehicleId()); } else { Assert.assertEquals("Vehicle Id transferred to new Plan", vehicleId, ((NetworkRoute) TripStructureUtils.getLegs(plan).get(1).getRoute()).getVehicleId()); @@ -110,7 +110,7 @@ public List calcRoute(RoutingRequest request) { final Facility toFacility = request.getToFacility(); final double departureTime = request.getDepartureTime(); final Person person = request.getPerson(); - + List trip = DefaultRoutingModules.createPureNetworkRouter("car", scenario.getPopulation().getFactory(), scenario.getNetwork(), leastCostAlgoFactory.createPathCalculator(scenario.getNetwork(), disutilityFactory.createTravelDisutility(travelTime), travelTime) @@ -138,7 +138,7 @@ public void install() { PlanRouter testee = new PlanRouter(tripRouter, TimeInterpretation.create(config)); testee.run(plan); - if ( config.plansCalcRoute().getAccessEgressType().equals(PlansCalcRouteConfigGroup.AccessEgressType.none) ) { + if ( config.plansCalcRoute().getAccessEgressType().equals(RoutingConfigGroup.AccessEgressType.none) ) { Assert.assertEquals("Vehicle Id from TripRouter used", newVehicleId, ((NetworkRoute) TripStructureUtils.getLegs(plan).get(0).getRoute()).getVehicleId()); } else { Assert.assertEquals("Vehicle Id from TripRouter used", newVehicleId, ((NetworkRoute) TripStructureUtils.getLegs(plan).get(1).getRoute()).getVehicleId()); @@ -147,4 +147,4 @@ public void install() { } -} \ No newline at end of file +} diff --git a/matsim/src/test/java/org/matsim/core/router/speedy/SpeedyALTTest.java b/matsim/src/test/java/org/matsim/core/router/speedy/SpeedyALTTest.java index 5539c340c8f..959d902b321 100644 --- a/matsim/src/test/java/org/matsim/core/router/speedy/SpeedyALTTest.java +++ b/matsim/src/test/java/org/matsim/core/router/speedy/SpeedyALTTest.java @@ -21,7 +21,7 @@ package org.matsim.core.router.speedy; import org.matsim.api.core.v01.network.Network; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; import org.matsim.core.router.AbstractLeastCostPathCalculatorTest; import org.matsim.core.router.costcalculators.FreespeedTravelTimeAndDisutility; import org.matsim.core.router.util.LeastCostPathCalculator; @@ -33,7 +33,7 @@ public class SpeedyALTTest extends AbstractLeastCostPathCalculatorTest { @Override protected LeastCostPathCalculator getLeastCostPathCalculator(final Network network) { - FreespeedTravelTimeAndDisutility travelTimeCostCalculator = new FreespeedTravelTimeAndDisutility(new PlanCalcScoreConfigGroup()); + FreespeedTravelTimeAndDisutility travelTimeCostCalculator = new FreespeedTravelTimeAndDisutility(new ScoringConfigGroup()); SpeedyGraph g = new SpeedyGraph(network); SpeedyALTData altData = new SpeedyALTData(g, 16, travelTimeCostCalculator); return new SpeedyALT(altData, travelTimeCostCalculator, travelTimeCostCalculator); diff --git a/matsim/src/test/java/org/matsim/core/router/speedy/SpeedyDijkstraTest.java b/matsim/src/test/java/org/matsim/core/router/speedy/SpeedyDijkstraTest.java index 5e389c1c2e0..a27c16c2ec9 100644 --- a/matsim/src/test/java/org/matsim/core/router/speedy/SpeedyDijkstraTest.java +++ b/matsim/src/test/java/org/matsim/core/router/speedy/SpeedyDijkstraTest.java @@ -21,7 +21,7 @@ package org.matsim.core.router.speedy; import org.matsim.api.core.v01.network.Network; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; import org.matsim.core.router.AbstractLeastCostPathCalculatorTest; import org.matsim.core.router.costcalculators.FreespeedTravelTimeAndDisutility; import org.matsim.core.router.util.LeastCostPathCalculator; @@ -33,7 +33,7 @@ public class SpeedyDijkstraTest extends AbstractLeastCostPathCalculatorTest { @Override protected LeastCostPathCalculator getLeastCostPathCalculator(final Network network) { - FreespeedTravelTimeAndDisutility travelTimeCostCalculator = new FreespeedTravelTimeAndDisutility(new PlanCalcScoreConfigGroup()); + FreespeedTravelTimeAndDisutility travelTimeCostCalculator = new FreespeedTravelTimeAndDisutility(new ScoringConfigGroup()); SpeedyGraph g = new SpeedyGraph(network); return new SpeedyDijkstra(g, travelTimeCostCalculator, travelTimeCostCalculator); } diff --git a/matsim/src/test/java/org/matsim/core/scoring/ScoringFunctionsForPopulationStressIT.java b/matsim/src/test/java/org/matsim/core/scoring/ScoringFunctionsForPopulationStressIT.java index 4da0fd39424..5732d92827e 100644 --- a/matsim/src/test/java/org/matsim/core/scoring/ScoringFunctionsForPopulationStressIT.java +++ b/matsim/src/test/java/org/matsim/core/scoring/ScoringFunctionsForPopulationStressIT.java @@ -36,7 +36,7 @@ import org.matsim.core.api.experimental.events.EventsManager; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; import org.matsim.core.controler.ControlerListenerManagerImpl; import org.matsim.core.events.EventsUtils; import org.matsim.core.gbl.MatsimRandom; @@ -95,12 +95,12 @@ public void handleLeg(Leg leg) { public void agentStuck(double time) { throw new RuntimeException(); } - + @Override public void handleTrip( final TripStructureUtils.Trip trip ) { throw new RuntimeException(); } - + @Override public void addMoney(double amount) { throw new RuntimeException(); @@ -144,10 +144,10 @@ public void workWithOldEventsManager() { } private void work(Config config) { - PlanCalcScoreConfigGroup.ActivityParams work = new PlanCalcScoreConfigGroup.ActivityParams("work"); + ScoringConfigGroup.ActivityParams work = new ScoringConfigGroup.ActivityParams("work"); work.setTypicalDuration(100.0); config.planCalcScore().addActivityParams(work); - PlanCalcScoreConfigGroup.ModeParams car = new PlanCalcScoreConfigGroup.ModeParams("car"); + ScoringConfigGroup.ModeParams car = new ScoringConfigGroup.ModeParams("car"); car.setMarginalUtilityOfTraveling(0.0); car.setMarginalUtilityOfDistance(0.0); car.setConstant(-1.0); @@ -177,12 +177,12 @@ public void handleLeg(Leg leg) { public void agentStuck(double time) { delegateFunction.agentStuck(time); } - + @Override public void handleTrip( final TripStructureUtils.Trip trip ) { delegateFunction.handleTrip(trip); } - + @Override public void addMoney(double amount) { delegateFunction.addMoney(amount); @@ -233,10 +233,10 @@ public void handleEvent(Event event) { } events.finishProcessing(); scoringFunctionsForPopulation.finishScoringFunctions(); - + //assert when TypicalDurationScoreComputation.uniform // assertEquals(60.0 * MAX, scoringFunctionsForPopulation.getScoringFunctionForAgent(personId).getScore(), 1.0); - + //assert when TypicalDurationScoreComputation.relative assertEquals(1.0/6.0 * MAX, scoringFunctionsForPopulation.getScoringFunctionForAgent(personId).getScore(), 1.0); } @@ -254,10 +254,10 @@ public void unlikelyTimingOfScoringFunctionStillWorks() { config.parallelEventHandling().setNumberOfThreads(8); config.parallelEventHandling().setOneThreadPerHandler(true); config.parallelEventHandling().setSynchronizeOnSimSteps(false); - PlanCalcScoreConfigGroup.ActivityParams work = new PlanCalcScoreConfigGroup.ActivityParams("work"); + ScoringConfigGroup.ActivityParams work = new ScoringConfigGroup.ActivityParams("work"); work.setTypicalDuration(100.0); config.planCalcScore().addActivityParams(work); - PlanCalcScoreConfigGroup.ModeParams car = new PlanCalcScoreConfigGroup.ModeParams("car"); + ScoringConfigGroup.ModeParams car = new ScoringConfigGroup.ModeParams("car"); car.setMarginalUtilityOfTraveling(0.0); car.setMarginalUtilityOfDistance(0.0); car.setConstant(-1.0); @@ -302,7 +302,7 @@ public void agentStuck(double time) { } delegateFunction.agentStuck(time); } - + @Override public void handleTrip( final TripStructureUtils.Trip trip ) { try { @@ -312,7 +312,7 @@ public void handleTrip( final TripStructureUtils.Trip trip ) { } delegateFunction.handleTrip(trip); } - + @Override public void addMoney(double amount) { try { @@ -382,10 +382,10 @@ public void handleEvent(Event event) { } events.finishProcessing(); scoringFunctionsForPopulation.finishScoringFunctions(); - + //assert when TypicalDurationScoreComputation.uniform // assertEquals(60.0 * MAX, scoringFunctionsForPopulation.getScoringFunctionForAgent(personId).getScore(), 1.0); - + //assert when TypicalDurationScoreComputation.relative assertEquals(1.0/6.0 * MAX, scoringFunctionsForPopulation.getScoringFunctionForAgent(personId).getScore(), 1.0); } diff --git a/matsim/src/test/java/org/matsim/core/scoring/functions/CharyparNagelLegScoringDailyConstantsTest.java b/matsim/src/test/java/org/matsim/core/scoring/functions/CharyparNagelLegScoringDailyConstantsTest.java index 19ab9c2e7a7..5b143bd9623 100644 --- a/matsim/src/test/java/org/matsim/core/scoring/functions/CharyparNagelLegScoringDailyConstantsTest.java +++ b/matsim/src/test/java/org/matsim/core/scoring/functions/CharyparNagelLegScoringDailyConstantsTest.java @@ -36,7 +36,7 @@ import org.matsim.api.core.v01.population.Leg; import org.matsim.api.core.v01.population.Person; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; import org.matsim.core.config.groups.ScenarioConfigGroup; import org.matsim.core.population.PopulationUtils; import org.matsim.core.scenario.ScenarioUtils; @@ -94,11 +94,11 @@ public void test1() throws Exception { scoring1.handleLeg(leg); scoring1.finish(); - + scoring2.handleLeg(leg); scoring2.finish(); } - + { final Leg leg = PopulationUtils.createLeg(TransportMode.car); leg.setDepartureTime( 0 ); @@ -131,11 +131,11 @@ public void test1() throws Exception { scoring1.handleLeg(leg); scoring1.finish(); - + scoring2.handleLeg(leg); scoring2.finish(); } - + { final Leg leg = PopulationUtils.createLeg(TransportMode.bike); leg.setDepartureTime( 0 ); @@ -168,7 +168,7 @@ public void test1() throws Exception { scoring1.handleLeg(leg); scoring1.finish(); - + scoring2.handleLeg(leg); scoring2.finish(); } @@ -178,9 +178,9 @@ public void test1() throws Exception { -12345.678, scoring1.getScore(), MatsimTestUtils.EPSILON ); - - double defaultScore = (legTravelTime1 + legTravelTime2) * new PlanCalcScoreConfigGroup().getModes().get(TransportMode.car).getMarginalUtilityOfTraveling() / 3600. - + legTravelTime3 * new PlanCalcScoreConfigGroup().getModes().get(TransportMode.bike).getMarginalUtilityOfTraveling() / 3600.; + + double defaultScore = (legTravelTime1 + legTravelTime2) * new ScoringConfigGroup().getModes().get(TransportMode.car).getMarginalUtilityOfTraveling() / 3600. + + legTravelTime3 * new ScoringConfigGroup().getModes().get(TransportMode.bike).getMarginalUtilityOfTraveling() / 3600.; Assert.assertEquals( "wrong score; daily constants are not accounted for in the scoring.", -12345.678 + defaultScore, @@ -189,15 +189,15 @@ public void test1() throws Exception { } private CharyparNagelLegScoring createDefaultPlusConstants(Network network) { - - final PlanCalcScoreConfigGroup conf = new PlanCalcScoreConfigGroup(); - + + final ScoringConfigGroup conf = new ScoringConfigGroup(); + conf.getModes().get(TransportMode.car).setDailyUtilityConstant(-10000.); conf.getModes().get(TransportMode.car).setDailyMonetaryConstant(-2345.); conf.getModes().get(TransportMode.bike).setDailyUtilityConstant(-.078); conf.getModes().get(TransportMode.bike).setDailyMonetaryConstant(-0.6); - + final ScenarioConfigGroup scenarioConfig = new ScenarioConfigGroup(); return new CharyparNagelLegScoring( @@ -207,12 +207,12 @@ private CharyparNagelLegScoring createDefaultPlusConstants(Network network) { private static CharyparNagelLegScoring createScoringOnlyConstants(final Network network) { - final PlanCalcScoreConfigGroup conf = new PlanCalcScoreConfigGroup(); - + final ScoringConfigGroup conf = new ScoringConfigGroup(); + conf.getModes().get(TransportMode.car).setMarginalUtilityOfTraveling(0.); conf.getModes().get(TransportMode.car).setDailyUtilityConstant(-10000.); conf.getModes().get(TransportMode.car).setDailyMonetaryConstant(-2345.); - + conf.getModes().get(TransportMode.bike).setMarginalUtilityOfTraveling(0.); conf.getModes().get(TransportMode.bike).setDailyUtilityConstant(-.078); conf.getModes().get(TransportMode.bike).setDailyMonetaryConstant(-0.6); diff --git a/matsim/src/test/java/org/matsim/core/scoring/functions/CharyparNagelLegScoringPtChangeTest.java b/matsim/src/test/java/org/matsim/core/scoring/functions/CharyparNagelLegScoringPtChangeTest.java index 870a563370d..6271fd0934c 100644 --- a/matsim/src/test/java/org/matsim/core/scoring/functions/CharyparNagelLegScoringPtChangeTest.java +++ b/matsim/src/test/java/org/matsim/core/scoring/functions/CharyparNagelLegScoringPtChangeTest.java @@ -39,7 +39,7 @@ import org.matsim.api.core.v01.population.Person; import org.matsim.core.api.experimental.events.EventsManager; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; import org.matsim.core.config.groups.ScenarioConfigGroup; import org.matsim.core.events.EventsUtils; import org.matsim.core.population.PopulationUtils; @@ -117,7 +117,7 @@ private static CharyparNagelLegScoring createScoring( final Network network) { final Random random = new Random( seed ); - final PlanCalcScoreConfigGroup conf = new PlanCalcScoreConfigGroup(); + final ScoringConfigGroup conf = new ScoringConfigGroup(); conf.setMarginalUtlOfWaitingPt_utils_hr( random.nextDouble() * 1000 ); conf.getModes().get(TransportMode.pt).setMonetaryDistanceRate(random.nextDouble() * 1000); conf.getModes().get(TransportMode.pt).setMarginalUtilityOfTraveling(random.nextDouble() * 1000); diff --git a/matsim/src/test/java/org/matsim/core/scoring/functions/CharyparNagelScoringFunctionTest.java b/matsim/src/test/java/org/matsim/core/scoring/functions/CharyparNagelScoringFunctionTest.java index a9640ce12b6..346efae54ec 100644 --- a/matsim/src/test/java/org/matsim/core/scoring/functions/CharyparNagelScoringFunctionTest.java +++ b/matsim/src/test/java/org/matsim/core/scoring/functions/CharyparNagelScoringFunctionTest.java @@ -46,9 +46,9 @@ import org.matsim.api.core.v01.population.Route; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup.ActivityParams; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup.TypicalDurationScoreComputation; +import org.matsim.core.config.groups.ScoringConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup.ActivityParams; +import org.matsim.core.config.groups.ScoringConfigGroup.TypicalDurationScoreComputation; import org.matsim.core.network.NetworkUtils; import org.matsim.core.population.PersonUtils; import org.matsim.core.population.PopulationUtils; @@ -77,16 +77,16 @@ public class CharyparNagelScoringFunctionTest { private static final double EPSILON =1e-9; - + @Parameter public TypicalDurationScoreComputation typicalDurationComputation; - + @Parameterized.Parameters public static Object[] testParameters() { return new Object[] {TypicalDurationScoreComputation.relative,TypicalDurationScoreComputation.uniform}; } - - + + private ScoringFunction getScoringFunctionInstance(final Fixture f, final Person person) { CharyparNagelScoringFunctionFactory charyparNagelScoringFunctionFactory = new CharyparNagelScoringFunctionFactory( f.scenario ); @@ -102,9 +102,9 @@ private double calcScore(final Fixture f) { if (planElement instanceof Activity) { testee.handleActivity((Activity) planElement); } else if (planElement instanceof Leg) { - testee.handleLeg((Leg) planElement); + testee.handleLeg((Leg) planElement); } - } + } testee.finish(); return testee.getScore(); } @@ -119,7 +119,7 @@ private double calcScore(final Fixture f) { */ private double getZeroUtilDuration_hrs(final double typicalDuration_hrs, final double priority) { // yy could/should use static function from CharyparNagelScoringUtils. kai, nov'13 - + if(typicalDurationComputation.equals(TypicalDurationScoreComputation.uniform)){ return typicalDuration_hrs * Math.exp(-10.0 / typicalDuration_hrs / priority); } else { @@ -138,18 +138,18 @@ public void testZeroUtilityDuration() { ZeroUtilityComputation computation; if(this.typicalDurationComputation.equals(TypicalDurationScoreComputation.uniform)){ - computation = new ActivityUtilityParameters.SameAbsoluteScore(); + computation = new ActivityUtilityParameters.SameAbsoluteScore(); } else { computation = new ActivityUtilityParameters.SameRelativeScore(); } - - + + { ActivityUtilityParameters.Builder factory = new ActivityUtilityParameters.Builder(); factory.setType("w"); factory.setPriority(1.0); factory.setTypicalDuration_s(8.0 * 3600); - factory.setZeroUtilityComputation(computation); + factory.setZeroUtilityComputation(computation); ActivityUtilityParameters params = factory.build(); assertEquals(zeroUtilDurW, params.getZeroUtilityDuration_h(), EPSILON); @@ -242,13 +242,13 @@ public void testPerforming() { double zeroUtilDurH = getZeroUtilDuration_hrs(15.0, 1.0); f.config.planCalcScore().setPerforming_utils_hr(perf); - + if(typicalDurationComputation.equals(TypicalDurationScoreComputation.uniform)){ for(ActivityParams p : f.config.planCalcScore().getActivityParams()){ p.setTypicalDurationScoreComputation(TypicalDurationScoreComputation.uniform); } - } - + } + assertEquals(perf * 3.0 * Math.log(2.5 / zeroUtilDurW) + perf * 3.0 * Math.log(2.75/zeroUtilDurW) + perf * 3.0 * Math.log(2.5/zeroUtilDurW) @@ -306,13 +306,13 @@ public void testOpeningClosingTime() { Fixture f = new Fixture(); double perf_hrs = +6.0; f.config.planCalcScore().setPerforming_utils_hr(perf_hrs); - + if(typicalDurationComputation.equals(TypicalDurationScoreComputation.uniform)){ for(ActivityParams p : f.config.planCalcScore().getActivityParams()){ p.setTypicalDurationScoreComputation(TypicalDurationScoreComputation.uniform); } - } - + } + double initialScore = calcScore(f); // test1: agents has to wait before and after @@ -515,18 +515,18 @@ public void testDifferentFirstLastAct() { // change the last act to something different than the first act ((Activity) f.plan.getPlanElements().get(8)).setType("h2"); - PlanCalcScoreConfigGroup.ActivityParams params = new PlanCalcScoreConfigGroup.ActivityParams("h2"); + ScoringConfigGroup.ActivityParams params = new ScoringConfigGroup.ActivityParams("h2"); params.setTypicalDuration(8*3600); - + f.config.planCalcScore().addActivityParams(params); f.config.planCalcScore().getActivityParams("h").setTypicalDuration(6.0 * 3600); - + if(typicalDurationComputation.equals(TypicalDurationScoreComputation.uniform)){ for(ActivityParams p : f.config.planCalcScore().getActivityParams()){ p.setTypicalDurationScoreComputation(TypicalDurationScoreComputation.uniform); } - } - + } + double perf = +6.0; f.config.planCalcScore().setPerforming_utils_hr(perf); double zeroUtilDurW = getZeroUtilDuration_hrs(3.0, 1.0); @@ -565,8 +565,8 @@ public void testNoNightActivity() { for(ActivityParams p : f.config.planCalcScore().getActivityParams()){ p.setTypicalDurationScoreComputation(TypicalDurationScoreComputation.uniform); } - } - + } + ScoringFunction testee = getScoringFunctionInstance(f, f.person); testee.handleActivity((Activity) f.plan.getPlanElements().get(0)); testee.handleLeg((Leg) f.plan.getPlanElements().get(1)); @@ -575,7 +575,7 @@ public void testNoNightActivity() { assertEquals( perf * 3.0 * Math.log(2.5 / zeroUtilDurW) + - perf * 7.0 * Math.log(7.0 / zeroUtilDurH), + perf * 7.0 * Math.log(7.0 / zeroUtilDurH), testee.getScore(), EPSILON); } @@ -717,7 +717,7 @@ public Fixture() { // home 15:15 to ... this.config = ConfigUtils.createConfig(); - PlanCalcScoreConfigGroup scoring = this.config.planCalcScore(); + ScoringConfigGroup scoring = this.config.planCalcScore(); scoring.setBrainExpBeta(2.0); scoring.getModes().get(TransportMode.car).setConstant(0.0); @@ -740,12 +740,12 @@ public Fixture() { // setup activity types h and w for scoring - PlanCalcScoreConfigGroup.ActivityParams params = new PlanCalcScoreConfigGroup.ActivityParams("h"); + ScoringConfigGroup.ActivityParams params = new ScoringConfigGroup.ActivityParams("h"); params.setTypicalDuration(15*3600); scoring.addActivityParams(params); - params = new PlanCalcScoreConfigGroup.ActivityParams("w"); + params = new ScoringConfigGroup.ActivityParams("w"); params.setTypicalDuration(3*3600); scoring.addActivityParams(params); @@ -842,6 +842,6 @@ public Fixture() { Activity fifthActivity = PopulationUtils.createAndAddActivityFromLinkId(this.plan, "h", link9.getId()); fifthActivity.setStartTime(fourthLegStartTime + fourthLegTravelTime); this.scenario.getPopulation().addPerson(this.person); - } + } } } diff --git a/matsim/src/test/java/org/matsim/core/scoring/functions/CharyparNagelWithSubpopulationsTest.java b/matsim/src/test/java/org/matsim/core/scoring/functions/CharyparNagelWithSubpopulationsTest.java index 23b1cfa276a..5001fcb2bd1 100644 --- a/matsim/src/test/java/org/matsim/core/scoring/functions/CharyparNagelWithSubpopulationsTest.java +++ b/matsim/src/test/java/org/matsim/core/scoring/functions/CharyparNagelWithSubpopulationsTest.java @@ -28,16 +28,14 @@ import org.matsim.api.core.v01.population.Route; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup.ActivityParams; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup.ModeParams; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup.ScoringParameterSet; +import org.matsim.core.config.groups.ScoringConfigGroup.ActivityParams; +import org.matsim.core.config.groups.ScoringConfigGroup.ModeParams; +import org.matsim.core.config.groups.ScoringConfigGroup.ScoringParameterSet; import org.matsim.core.population.PopulationUtils; import org.matsim.core.population.routes.RouteUtils; import org.matsim.core.scenario.ScenarioUtils; import org.matsim.core.scoring.ScoringFunction; -import java.util.Random; - /** * @author thibautd */ diff --git a/matsim/src/test/java/org/matsim/core/utils/timing/TimeInterpretationTest.java b/matsim/src/test/java/org/matsim/core/utils/timing/TimeInterpretationTest.java index 8f2d3624feb..5f30bb5b933 100644 --- a/matsim/src/test/java/org/matsim/core/utils/timing/TimeInterpretationTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/timing/TimeInterpretationTest.java @@ -39,7 +39,7 @@ import org.matsim.api.core.v01.population.PopulationFactory; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup.ActivityParams; +import org.matsim.core.config.groups.ScoringConfigGroup.ActivityParams; import org.matsim.core.config.groups.PlansConfigGroup.TripDurationHandling; import org.matsim.core.controler.Controler; import org.matsim.core.controler.OutputDirectoryHierarchy; diff --git a/matsim/src/test/java/org/matsim/examples/simple/PtScoringTest.java b/matsim/src/test/java/org/matsim/examples/simple/PtScoringTest.java index b7a7551dfbd..912ee2e118b 100644 --- a/matsim/src/test/java/org/matsim/examples/simple/PtScoringTest.java +++ b/matsim/src/test/java/org/matsim/examples/simple/PtScoringTest.java @@ -18,7 +18,7 @@ * *********************************************************************** */ /** - * + * */ package org.matsim.examples.simple; @@ -36,9 +36,9 @@ import org.matsim.api.core.v01.population.Person; import org.matsim.api.core.v01.population.Population; import org.matsim.core.config.Config; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup.ActivityParams; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup.TypicalDurationScoreComputation; +import org.matsim.core.config.groups.ScoringConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup.ActivityParams; +import org.matsim.core.config.groups.ScoringConfigGroup.TypicalDurationScoreComputation; import org.matsim.core.controler.Controler; import org.matsim.core.controler.OutputDirectoryHierarchy; import org.matsim.core.scoring.functions.ActivityUtilityParameters; @@ -58,26 +58,26 @@ public class PtScoringTest { @Parameter public TypicalDurationScoreComputation typicalDurationScoreComputation; - + @Parameterized.Parameters public static Object[] testParameters() { return new Object[] {TypicalDurationScoreComputation.relative,TypicalDurationScoreComputation.uniform}; } - + @Rule public MatsimTestUtils utils = new MatsimTestUtils(); @Test public void test_PtScoringLineswitch() { Config config = this.utils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("pt-simple-lineswitch"), "config.xml")); config.transit().setRoutingAlgorithmType(TransitRoutingAlgorithmType.DijkstraBased); - PlanCalcScoreConfigGroup pcs = config.planCalcScore() ; + ScoringConfigGroup pcs = config.planCalcScore() ; if(this.typicalDurationScoreComputation.equals(TypicalDurationScoreComputation.uniform)){ for(ActivityParams params : pcs.getActivityParams()){ params.setTypicalDurationScoreComputation(typicalDurationScoreComputation); } } - + pcs.setWriteExperiencedPlans(true); Controler controler = new Controler(config); @@ -99,7 +99,7 @@ public void test_PtScoringLineswitch() { double typicalDuration_s = pcs.getActivityParams("home").getTypicalDuration().seconds(); double priority = 1. ; - + // double zeroUtilityDurationHome_s = CharyparNagelScoringUtils.computeZeroUtilityDuration_s(priority, typicalDuration_s); ActivityUtilityParameters.Builder builder = new ActivityUtilityParameters.Builder( pcs.getActivityParams("home") ) ; ActivityUtilityParameters params = builder.build() ; @@ -130,7 +130,7 @@ public void test_PtScoringLineswitch() { double score = pcs.getModes().get(TransportMode.walk).getMarginalUtilityOfTraveling() * (stop1Arr-homeAct1End)/3600. ; System.out.println("score after walk: " + score ) ; - // (pt interaction activity) + // (pt interaction activity) System.out.println("score after pt interact: " + score ) ; // yyyy wait is not separately scored!! @@ -141,14 +141,14 @@ public void test_PtScoringLineswitch() { score += pcs.getModes().get(TransportMode.pt).getMarginalUtilityOfTraveling() * (leaveVeh-enterVeh)/3600. ; System.out.println("score after travel pt: " + score ) ; - // (pt interaction activity) + // (pt interaction activity) System.out.println("score after pt interact: " + score ) ; score += pcs.getModes().get(TransportMode.walk).getMarginalUtilityOfTraveling() * (home2Arr-ptIA2ActEnd)/3600. ; System.out.println("score after walk: " + score ) ; final double duration = homeAct2End-home2Arr; - double tmpScore = (pcs.getPerforming_utils_hr()/3600.) * typicalDuration_s + double tmpScore = (pcs.getPerforming_utils_hr()/3600.) * typicalDuration_s * Math.log(duration/zeroUtilityDurationHome_s) ; if ( tmpScore < 0 ) { System.out.println("home2score< 0; replacing ... ") ; @@ -163,7 +163,7 @@ public void test_PtScoringLineswitch() { score += pcs.getModes().get(TransportMode.walk).getMarginalUtilityOfTraveling() * (stop2Arr-homeAct2End)/3600. ; System.out.println("score after walk: " + score ) ; - // (pt interaction activity) + // (pt interaction activity) System.out.println("score after pt int act: " + score ) ; score += pcs.getModes().get(TransportMode.pt).getMarginalUtilityOfTraveling() * (enterVeh2-ptIA3ActEnd)/3600. ; @@ -172,7 +172,7 @@ public void test_PtScoringLineswitch() { score += pcs.getModes().get(TransportMode.pt).getMarginalUtilityOfTraveling() * (leaveVeh2-enterVeh2)/3600. ; System.out.println("score after travel pt: " + score ) ; - // (pt interaction activity) + // (pt interaction activity) System.out.println("score after pt int act: " + score ) ; score += pcs.getModes().get(TransportMode.walk).getMarginalUtilityOfTraveling() * (stop3Arr-ptIA4ActEnd)/3600. ; @@ -183,7 +183,7 @@ public void test_PtScoringLineswitch() { // ------ - // (pt interaction activity) + // (pt interaction activity) System.out.println("score after pt int act: " + score ) ; score += pcs.getModes().get(TransportMode.pt).getMarginalUtilityOfTraveling() * (enterVeh3-ptIA5ActEnd)/3600. ; @@ -192,13 +192,13 @@ public void test_PtScoringLineswitch() { score += pcs.getModes().get(TransportMode.pt).getMarginalUtilityOfTraveling() * (leaveVeh3-enterVeh3)/3600. ; System.out.println("score after travel pt: " + score ) ; - // (pt interaction activity) + // (pt interaction activity) System.out.println("score after pt int act: " + score ) ; score += pcs.getModes().get(TransportMode.walk).getMarginalUtilityOfTraveling() * (home3Arr-ptIA6ActEnd)/3600. ; System.out.println("score after walk: " + score ) ; - score += (pcs.getPerforming_utils_hr()/3600.) * typicalDuration_s + score += (pcs.getPerforming_utils_hr()/3600.) * typicalDuration_s * Math.log((homeAct1End-home3Arr+24.*3600)/zeroUtilityDurationHome_s) ; System.out.println("score after home act: " + score ) ; @@ -208,14 +208,14 @@ public void test_PtScoringLineswitch() { // (there is only one person, but we need to get it) System.out.println(" score: " + pp.getSelectedPlan().getScore() ) ; - + if(this.typicalDurationScoreComputation.equals(TypicalDurationScoreComputation.uniform)){ Assert.assertEquals(-21.28929580072052, pp.getSelectedPlan().getScore(), MatsimTestUtils.EPSILON ) ; } else{ Assert.assertEquals(27.46011565686209, pp.getSelectedPlan().getScore(),MatsimTestUtils.EPSILON ) ; } - + } } @@ -223,13 +223,13 @@ public void test_PtScoringLineswitch() { public void test_PtScoringLineswitchAndPtConstant() { Config config = this.utils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("pt-simple-lineswitch"), "config.xml")); config.transit().setRoutingAlgorithmType(TransitRoutingAlgorithmType.DijkstraBased); - PlanCalcScoreConfigGroup pcs = config.planCalcScore() ; + ScoringConfigGroup pcs = config.planCalcScore() ; if(this.typicalDurationScoreComputation.equals(TypicalDurationScoreComputation.uniform)) for(ActivityParams params : pcs.getActivityParams()){ params.setTypicalDurationScoreComputation(typicalDurationScoreComputation); } - + pcs.setWriteExperiencedPlans(true); pcs.getModes().get(TransportMode.pt).setConstant(1.); @@ -247,7 +247,7 @@ public void test_PtScoringLineswitchAndPtConstant() { for (Event event : allEvents) { System.out.println(event.toString()); } - + double typicalDuration_s = pcs.getActivityParams("home").getTypicalDuration().seconds(); double priority = 1. ; @@ -280,7 +280,7 @@ public void test_PtScoringLineswitchAndPtConstant() { double score = pcs.getModes().get(TransportMode.walk).getMarginalUtilityOfTraveling() * (stop1Arr-homeAct1End)/3600. ; System.out.println("score after walk: " + score ) ; - // (pt interaction activity) + // (pt interaction activity) System.out.println("score after pt interact: " + score ) ; score += pcs.getModes().get(TransportMode.pt).getConstant(); @@ -294,13 +294,13 @@ public void test_PtScoringLineswitchAndPtConstant() { score += pcs.getModes().get(TransportMode.pt).getMarginalUtilityOfTraveling() * (leaveVeh-enterVeh)/3600. ; System.out.println("score after travel pt: " + score ) ; - // (pt interaction activity) + // (pt interaction activity) System.out.println("score after pt interact: " + score ) ; score += pcs.getModes().get(TransportMode.walk).getMarginalUtilityOfTraveling() * (home2Arr-ptIA2ActEnd)/3600. ; System.out.println("score after walk: " + score ) ; - double tmpScore = (pcs.getPerforming_utils_hr()/3600.) * typicalDuration_s + double tmpScore = (pcs.getPerforming_utils_hr()/3600.) * typicalDuration_s * Math.log((homeAct2End-home2Arr)/zeroUtilityDurationHome_s) ; if ( tmpScore < 0 ) { System.out.println("home2score< 0; replacing ... ") ; @@ -315,7 +315,7 @@ public void test_PtScoringLineswitchAndPtConstant() { score += pcs.getModes().get(TransportMode.walk).getMarginalUtilityOfTraveling() * (stop2Arr-homeAct2End)/3600. ; System.out.println("score after walk: " + score ) ; - // (pt interaction activity) + // (pt interaction activity) System.out.println("score after pt int act: " + score ) ; score += pcs.getModes().get(TransportMode.pt).getConstant(); @@ -327,7 +327,7 @@ public void test_PtScoringLineswitchAndPtConstant() { score += pcs.getModes().get(TransportMode.pt).getMarginalUtilityOfTraveling() * (leaveVeh2-enterVeh2)/3600. ; System.out.println("score after travel pt: " + score ) ; - // (pt interaction activity) + // (pt interaction activity) System.out.println("score after pt int act: " + score ) ; score += pcs.getModes().get(TransportMode.walk).getMarginalUtilityOfTraveling() * (stop3Arr-ptIA4ActEnd)/3600. ; @@ -338,7 +338,7 @@ public void test_PtScoringLineswitchAndPtConstant() { // ------ - // (pt interaction activity) + // (pt interaction activity) System.out.println("score after pt int act: " + score ) ; score += pcs.getModes().get(TransportMode.pt).getMarginalUtilityOfTraveling() * (enterVeh3-ptIA5ActEnd)/3600. ; @@ -347,13 +347,13 @@ public void test_PtScoringLineswitchAndPtConstant() { score += pcs.getModes().get(TransportMode.pt).getMarginalUtilityOfTraveling() * (leaveVeh3-enterVeh3)/3600. ; System.out.println("score after travel pt: " + score ) ; - // (pt interaction activity) + // (pt interaction activity) System.out.println("score after pt int act: " + score ) ; score += pcs.getModes().get(TransportMode.walk).getMarginalUtilityOfTraveling() * (home3Arr-ptIA6ActEnd)/3600. ; System.out.println("score after walk: " + score ) ; - score += (pcs.getPerforming_utils_hr()/3600.) * typicalDuration_s + score += (pcs.getPerforming_utils_hr()/3600.) * typicalDuration_s * Math.log((homeAct1End-home3Arr+24.*3600)/zeroUtilityDurationHome_s) ; System.out.println("score after home act: " + score ) ; @@ -363,7 +363,7 @@ public void test_PtScoringLineswitchAndPtConstant() { // (there is only one person, but we need to get it) System.out.println(" score: " + pp.getSelectedPlan().getScore() ) ; - + if(this.typicalDurationScoreComputation.equals(TypicalDurationScoreComputation.uniform)){ // Assert.assertEquals(89.14608279715044, pp.getSelectedPlan().getScore(),MatsimTestUtils.EPSILON ) ; Assert.assertEquals(-19.28929580072052, pp.getSelectedPlan().getScore(), MatsimTestUtils.EPSILON ) ; @@ -371,7 +371,7 @@ public void test_PtScoringLineswitchAndPtConstant() { else{ Assert.assertEquals(29.46011565686209, pp.getSelectedPlan().getScore(),MatsimTestUtils.EPSILON ) ; } - + } } @@ -379,17 +379,17 @@ public void test_PtScoringLineswitchAndPtConstant() { public void test_PtScoring_Wait() { Config config = this.utils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("pt-simple"), "config.xml")); config.transit().setRoutingAlgorithmType(TransitRoutingAlgorithmType.DijkstraBased); - PlanCalcScoreConfigGroup pcs = config.planCalcScore() ; - + ScoringConfigGroup pcs = config.planCalcScore() ; + if(this.typicalDurationScoreComputation.equals(TypicalDurationScoreComputation.uniform)){ for(ActivityParams params : pcs.getActivityParams()){ params.setTypicalDurationScoreComputation(typicalDurationScoreComputation); } } - + pcs.setWriteExperiencedPlans(true); pcs.setMarginalUtlOfWaitingPt_utils_hr(-18.0) ; - + Controler controler = new Controler(config); controler.getConfig().controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles); controler.getConfig().controler().setCreateGraphs(false); @@ -404,7 +404,7 @@ public void test_PtScoring_Wait() { for (Event event : allEvents) { System.out.println(event.toString()); } - + double typicalDuration_s = pcs.getActivityParams("home").getTypicalDuration().seconds(); double priority = 1. ; @@ -423,7 +423,7 @@ public void test_PtScoring_Wait() { double score = pcs.getModes().get(TransportMode.walk).getMarginalUtilityOfTraveling() * (timeTransitWalk/3600.) ; System.out.println("score: " + score ) ; - // (pt interaction activity) + // (pt interaction activity) System.out.println("score: " + score ) ; System.out.println("marginalUtlOfWaitPt: " + pcs.getMarginalUtlOfWaitingPt_utils_hr() ) ; @@ -436,7 +436,7 @@ public void test_PtScoring_Wait() { score += pcs.getModes().get(TransportMode.pt).getMarginalUtilityOfTraveling() * timeTransitInVeh/3600. ; System.out.println("score: " + score ) ; - // (pt interaction activity) + // (pt interaction activity) System.out.println("score: " + score ) ; score += pcs.getModes().get(TransportMode.walk).getMarginalUtilityOfTraveling() * timeTransitWalk2/3600. ; @@ -451,7 +451,7 @@ public void test_PtScoring_Wait() { // (there is only one person, but we need to get it) System.out.println("agent score: " + pp.getSelectedPlan().getScore() ) ; - + if(this.typicalDurationScoreComputation.equals(TypicalDurationScoreComputation.uniform)){ Assert.assertEquals(89.14608279715044, pp.getSelectedPlan().getScore(),MatsimTestUtils.EPSILON ) ; } @@ -466,13 +466,13 @@ public void test_PtScoring_Wait() { public void test_PtScoring() { Config config = this.utils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("pt-simple"), "config.xml")); config.transit().setRoutingAlgorithmType(TransitRoutingAlgorithmType.DijkstraBased); - PlanCalcScoreConfigGroup pcs = config.planCalcScore() ; + ScoringConfigGroup pcs = config.planCalcScore() ; if(this.typicalDurationScoreComputation.equals(TypicalDurationScoreComputation.uniform)) for(ActivityParams params : pcs.getActivityParams()){ params.setTypicalDurationScoreComputation(typicalDurationScoreComputation); } - + pcs.setWriteExperiencedPlans(true); Controler controler = new Controler(config); @@ -508,7 +508,7 @@ public void test_PtScoring() { double score = pcs.getModes().get(TransportMode.walk).getMarginalUtilityOfTraveling() * (timeTransitWalk/3600.) ; System.out.println("score: " + score ) ; - // (pt interaction activity) + // (pt interaction activity) System.out.println("score: " + score ) ; // score += pcs.getMarginalUtlOfWaitingPt_utils_hr() * timeTransitWait/3600. ; @@ -519,7 +519,7 @@ public void test_PtScoring() { score += pcs.getModes().get(TransportMode.pt).getMarginalUtilityOfTraveling() * timeTransitInVeh/3600. ; System.out.println("score: " + score ) ; - // (pt interaction activity) + // (pt interaction activity) System.out.println("score: " + score ) ; score += pcs.getModes().get(TransportMode.walk).getMarginalUtilityOfTraveling() * timeTransitWalk2/3600. ; @@ -534,15 +534,15 @@ public void test_PtScoring() { // (there is only one person, but we need to get it) System.out.println(" score: " + pp.getSelectedPlan().getScore() ) ; - + if(this.typicalDurationScoreComputation.equals(TypicalDurationScoreComputation.uniform)){ Assert.assertEquals(89.85608279715044, pp.getSelectedPlan().getScore(),MatsimTestUtils.EPSILON ) ; } else{ Assert.assertEquals(137.85608279715044, pp.getSelectedPlan().getScore(),MatsimTestUtils.EPSILON ) ; } - - + + } } diff --git a/matsim/src/test/java/org/matsim/facilities/FacilitiesFromPopulationTest.java b/matsim/src/test/java/org/matsim/facilities/FacilitiesFromPopulationTest.java index 5f19f968480..fa503cb96f4 100644 --- a/matsim/src/test/java/org/matsim/facilities/FacilitiesFromPopulationTest.java +++ b/matsim/src/test/java/org/matsim/facilities/FacilitiesFromPopulationTest.java @@ -37,8 +37,8 @@ import org.matsim.api.core.v01.population.Population; import org.matsim.api.core.v01.population.PopulationFactory; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup.ActivityParams; +import org.matsim.core.config.groups.ScoringConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup.ActivityParams; import org.matsim.core.scenario.ScenarioUtils; /** @@ -54,13 +54,13 @@ public void testRun_onePerLink_assignLinks() { generator.setOneFacilityPerLink(true); generator.setAssignLinksToFacilitiesIfMissing( f.scenario.getNetwork() ); generator.run(f.scenario.getPopulation()); - + Assert.assertEquals(3, f.scenario.getActivityFacilities().getFacilities().size()); - + Assert.assertEquals("bc", f.scenario.getActivityFacilities().getFacilities().get(Id.create("bc", ActivityFacility.class)).getLinkId().toString()); Assert.assertEquals("ca", f.scenario.getActivityFacilities().getFacilities().get(Id.create("ca", ActivityFacility.class)).getLinkId().toString()); Assert.assertEquals("ab", f.scenario.getActivityFacilities().getFacilities().get(Id.create("ab", ActivityFacility.class)).getLinkId().toString()); - + assertPlan(f.scenario.getPopulation().getPersons().get(Id.create("1", Person.class)).getSelectedPlan(), "ab", "bc", true); assertPlan(f.scenario.getPopulation().getPersons().get(Id.create("2", Person.class)).getSelectedPlan(), "ab", "bc", true); assertPlan(f.scenario.getPopulation().getPersons().get(Id.create("3", Person.class)).getSelectedPlan(), "ab", "bc", true); @@ -76,12 +76,12 @@ public void testRun_onePerLink_assignLinks() { @Test public void testRun_onePerLink_assignLinks_openingTimes() { Fixture f = new Fixture(); - + FacilitiesFromPopulation generator = new FacilitiesFromPopulation(f.scenario.getActivityFacilities()); generator.setOneFacilityPerLink(true); generator.setAddEmptyActivityOptions(true); generator.setAssignLinksToFacilitiesIfMissing( f.scenario.getNetwork() ); - PlanCalcScoreConfigGroup config = new PlanCalcScoreConfigGroup(); + ScoringConfigGroup config = new ScoringConfigGroup(); ActivityParams homeParams = new ActivityParams("home"); ActivityParams workParams = new ActivityParams("work"); workParams.setOpeningTime(7*3600); @@ -90,13 +90,13 @@ public void testRun_onePerLink_assignLinks_openingTimes() { config.addActivityParams(workParams); generator.assignOpeningTimes( config ); generator.run(f.scenario.getPopulation()); - + Assert.assertEquals(3, f.scenario.getActivityFacilities().getFacilities().size()); - + Map, ? extends ActivityFacility> ffs = f.scenario.getActivityFacilities().getFacilities(); Assert.assertEquals(7*3600, ffs.get(Id.create("ab", ActivityFacility.class)).getActivityOptions().get("work").getOpeningTimes().first().getStartTime(), 1e-7); Assert.assertEquals(19*3600, ffs.get(Id.create("ab", ActivityFacility.class)).getActivityOptions().get("work").getOpeningTimes().first().getEndTime(), 1e-7); - + assertPlan(f.scenario.getPopulation().getPersons().get(Id.create("1", Person.class)).getSelectedPlan(), "ab", "bc", true); assertPlan(f.scenario.getPopulation().getPersons().get(Id.create("2", Person.class)).getSelectedPlan(), "ab", "bc", true); assertPlan(f.scenario.getPopulation().getPersons().get(Id.create("3", Person.class)).getSelectedPlan(), "ab", "bc", true); @@ -112,16 +112,16 @@ public void testRun_onePerLink_assignLinks_openingTimes() { @Test public void testRun_multiple_assignLinks() { Fixture f = new Fixture(); - + FacilitiesFromPopulation generator = new FacilitiesFromPopulation(f.scenario.getActivityFacilities()); generator.setOneFacilityPerLink(false); generator.setAssignLinksToFacilitiesIfMissing( f.scenario.getNetwork() ); generator.run(f.scenario.getPopulation()); - + // for (ActivityFacility af : f.scenario.getActivityFacilities().getFacilities().values()) { // System.out.println(af.getId() + "\t" + af.getLinkId() + "\t" + af.getCoord().getX() + "\t" + af.getCoord().getY()); // } - + Assert.assertEquals(13, f.scenario.getActivityFacilities().getFacilities().size()); Map, ? extends ActivityFacility> ffs = f.scenario.getActivityFacilities().getFacilities(); @@ -138,7 +138,7 @@ public void testRun_multiple_assignLinks() { Assert.assertEquals("ab", ffs.get(Id.create("10", ActivityFacility.class)).getLinkId().toString()); // work of agent 8-10 Assert.assertEquals("ca", ffs.get(Id.create("11", ActivityFacility.class)).getLinkId().toString()); // home of agent 9 Assert.assertEquals("ca", ffs.get(Id.create("12", ActivityFacility.class)).getLinkId().toString()); // home of agent 10 - + assertPlan(f.scenario.getPopulation().getPersons().get(Id.create("1", Person.class)).getSelectedPlan(), "0", "1", true); assertPlan(f.scenario.getPopulation().getPersons().get(Id.create("2", Person.class)).getSelectedPlan(), "2", "1", true); assertPlan(f.scenario.getPopulation().getPersons().get(Id.create("3", Person.class)).getSelectedPlan(), "3", "1", true); @@ -150,16 +150,16 @@ public void testRun_multiple_assignLinks() { assertPlan(f.scenario.getPopulation().getPersons().get(Id.create("9", Person.class)).getSelectedPlan(), "11", "10", true); assertPlan(f.scenario.getPopulation().getPersons().get(Id.create("0", Person.class)).getSelectedPlan(), "12", "10", true); } - + private void assertPlan(Plan plan, String homeFacilityId, String workFacilityId, boolean linkCoordMustBeNull) { Activity home1 = (Activity) plan.getPlanElements().get(0); Activity work = (Activity) plan.getPlanElements().get(2); Activity home2 = (Activity) plan.getPlanElements().get(4); - + Assert.assertEquals(homeFacilityId, home1.getFacilityId().toString()); Assert.assertEquals(workFacilityId, work.getFacilityId().toString()); Assert.assertEquals(homeFacilityId, home2.getFacilityId().toString()); - + if (linkCoordMustBeNull) { Assert.assertNull(home1.getLinkId()); Assert.assertNull(home1.getCoord()); @@ -169,11 +169,11 @@ private void assertPlan(Plan plan, String homeFacilityId, String workFacilityId, Assert.assertNull(home2.getCoord()); } } - + /** * Creates a simple scenario with a network with 3 links and * 10 agents. - * + * *
             (C)
     	 *               / \
     	 *            8 /   \
    @@ -189,17 +189,17 @@ private void assertPlan(Plan plan, String homeFacilityId, String workFacilityId,
     	 *    (A)-------------------(B)
     	 *                  2
     	 * 
    - * + * * @author mrieser / Senozon AG */ private static class Fixture { Scenario scenario = ScenarioUtils.createScenario(ConfigUtils.createConfig()); - + public Fixture() { createNetwork(); createPopulation(); } - + private void createNetwork() { Network network = this.scenario.getNetwork(); NetworkFactory factory = network.getFactory(); @@ -207,15 +207,15 @@ private void createNetwork() { Node a = factory.createNode(Id.create("A", Node.class), new Coord((double) 0, (double) 0)); Node b = factory.createNode(Id.create("B", Node.class), new Coord((double) 1000, (double) 0)); Node c = factory.createNode(Id.create("C", Node.class), new Coord((double) 500, (double) 600)); - + network.addNode(a); network.addNode(b); network.addNode(c); - + Link ab = factory.createLink(Id.create("ab", Link.class), a, b); Link bc = factory.createLink(Id.create("bc", Link.class), b, c); Link ca = factory.createLink(Id.create("ca", Link.class), c, a); - + Set modes = new HashSet<>(); modes.add("car"); for (Link l : new Link[] {ab, bc, ca}) { @@ -224,15 +224,15 @@ private void createNetwork() { l.setNumberOfLanes(1); l.setFreespeed(10.0); l.setAllowedModes(modes); - + network.addLink(l); } } - + private void createPopulation() { Population pop = scenario.getPopulation(); PopulationFactory factory = pop.getFactory(); - + pop.addPerson(createPersonWithPlan(factory, "1", 200, 10, 800, 300)); pop.addPerson(createPersonWithPlan(factory, "2", 500, -10, 800, 300)); pop.addPerson(createPersonWithPlan(factory, "3", 600, 20, 800, 300)); @@ -244,7 +244,7 @@ private void createPopulation() { pop.addPerson(createPersonWithPlan(factory, "9", 250, 250, 300, 100)); pop.addPerson(createPersonWithPlan(factory, "0", 0, 100, 300, 100)); } - + private Person createPersonWithPlan(PopulationFactory factory, String id, double homeX, double homeY, double workX, double workY) { Person person = factory.createPerson(Id.create(id, Person.class)); Plan plan = factory.createPlan(); @@ -254,15 +254,15 @@ private Person createPersonWithPlan(PopulationFactory factory, String id, double Activity work = factory.createActivityFromCoord("work", new Coord(workX, workY)); work.setEndTime(17*3600); Activity home2 = factory.createActivityFromCoord("home", new Coord(homeX, homeY)); - + plan.addActivity(home1); plan.addLeg(factory.createLeg("car")); plan.addActivity(work); plan.addLeg(factory.createLeg("car")); plan.addActivity(home2); - + return person; } - + } } diff --git a/matsim/src/test/java/org/matsim/integration/EquilTwoAgentsTest.java b/matsim/src/test/java/org/matsim/integration/EquilTwoAgentsTest.java index c8b707958e0..583d36fa620 100644 --- a/matsim/src/test/java/org/matsim/integration/EquilTwoAgentsTest.java +++ b/matsim/src/test/java/org/matsim/integration/EquilTwoAgentsTest.java @@ -37,8 +37,8 @@ import org.matsim.core.api.experimental.events.EventsManager; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup.ActivityParams; +import org.matsim.core.config.groups.ScoringConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup.ActivityParams; import org.matsim.core.controler.AbstractModule; import org.matsim.core.controler.Controler; import org.matsim.core.controler.OutputDirectoryHierarchy; @@ -93,7 +93,7 @@ public void testSingleIterationPlansV4() { ConfigUtils.loadConfig(config, IOUtils.extendUrl(utils.classInputResourcePath(), "config.xml")); config.plans().setInputFile(IOUtils.extendUrl(utils.classInputResourcePath(), "plans2.xml").toString()); - PlanCalcScoreConfigGroup pcsConfig = config.planCalcScore() ; + ScoringConfigGroup pcsConfig = config.planCalcScore() ; ActivityParams params = new ActivityParams("h") ; params.setTypicalDuration(123456789.0) ; // probably dummy params.setScoringThisActivityAtAll(false); diff --git a/matsim/src/test/java/org/matsim/integration/SimulateAndScoreTest.java b/matsim/src/test/java/org/matsim/integration/SimulateAndScoreTest.java index e9ce57fff72..d57ff6a25d9 100644 --- a/matsim/src/test/java/org/matsim/integration/SimulateAndScoreTest.java +++ b/matsim/src/test/java/org/matsim/integration/SimulateAndScoreTest.java @@ -43,7 +43,7 @@ import org.matsim.core.api.experimental.events.EventsManager; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; import org.matsim.core.controler.AbstractModule; import org.matsim.core.controler.Injector; import org.matsim.core.controler.PrepareForSimUtils; @@ -90,11 +90,11 @@ public class SimulateAndScoreTest { final Config config = ConfigUtils.createConfig(); config.transit().setUseTransit(true); - PlanCalcScoreConfigGroup.ActivityParams h = new PlanCalcScoreConfigGroup.ActivityParams("h"); + ScoringConfigGroup.ActivityParams h = new ScoringConfigGroup.ActivityParams("h"); h.setTypicalDuration(16 * 3600); - PlanCalcScoreConfigGroup.ActivityParams w = new PlanCalcScoreConfigGroup.ActivityParams("w"); + ScoringConfigGroup.ActivityParams w = new ScoringConfigGroup.ActivityParams("w"); w.setTypicalDuration(8 * 3600); - PlanCalcScoreConfigGroup.ActivityParams transitActivityParams = new PlanCalcScoreConfigGroup.ActivityParams(PtConstants.TRANSIT_ACTIVITY_TYPE); + ScoringConfigGroup.ActivityParams transitActivityParams = new ScoringConfigGroup.ActivityParams(PtConstants.TRANSIT_ACTIVITY_TYPE); transitActivityParams.setTypicalDuration(120.0); config.planCalcScore().setPerforming_utils_hr(0); @@ -278,9 +278,9 @@ public void install() { Netsim sim = new QSimBuilder(scenario.getConfig()) // .useDefaults() // .build(scenario, events); - PlanCalcScoreConfigGroup.ActivityParams h = new PlanCalcScoreConfigGroup.ActivityParams("h"); + ScoringConfigGroup.ActivityParams h = new ScoringConfigGroup.ActivityParams("h"); h.setTypicalDuration(16 * 3600); - PlanCalcScoreConfigGroup.ActivityParams w = new PlanCalcScoreConfigGroup.ActivityParams("w"); + ScoringConfigGroup.ActivityParams w = new ScoringConfigGroup.ActivityParams("w"); w.setTypicalDuration(8 * 3600); scenario.getConfig().planCalcScore().setPerforming_utils_hr(0); final double travelingPt = -1.00; diff --git a/matsim/src/test/java/org/matsim/integration/events/PersonScoreEventTest.java b/matsim/src/test/java/org/matsim/integration/events/PersonScoreEventTest.java index a5fc87a32ab..501d668165c 100644 --- a/matsim/src/test/java/org/matsim/integration/events/PersonScoreEventTest.java +++ b/matsim/src/test/java/org/matsim/integration/events/PersonScoreEventTest.java @@ -29,7 +29,7 @@ import org.matsim.api.core.v01.events.PersonScoreEvent; import org.matsim.api.core.v01.population.Person; import org.matsim.core.api.experimental.events.EventsManager; -import org.matsim.core.config.groups.ControlerConfigGroup.EventsFileFormat; +import org.matsim.core.config.groups.ControllerConfigGroup.EventsFileFormat; import org.matsim.core.events.EventsUtils; import org.matsim.core.events.MatsimEventsReader; import org.matsim.core.events.algorithms.EventWriterJson; diff --git a/matsim/src/test/java/org/matsim/integration/invertednetworks/InvertedNetworkRoutingTestFixture.java b/matsim/src/test/java/org/matsim/integration/invertednetworks/InvertedNetworkRoutingTestFixture.java index 153a5b95ebd..fcbcc11a78b 100644 --- a/matsim/src/test/java/org/matsim/integration/invertednetworks/InvertedNetworkRoutingTestFixture.java +++ b/matsim/src/test/java/org/matsim/integration/invertednetworks/InvertedNetworkRoutingTestFixture.java @@ -38,8 +38,8 @@ import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; import org.matsim.core.config.groups.QSimConfigGroup; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup.ActivityParams; -import org.matsim.core.config.groups.StrategyConfigGroup.StrategySettings; +import org.matsim.core.config.groups.ScoringConfigGroup.ActivityParams; +import org.matsim.core.config.groups.ReplanningConfigGroup.StrategySettings; import org.matsim.core.replanning.strategies.DefaultPlanStrategiesModule; import org.matsim.core.scenario.MutableScenario; import org.matsim.core.scenario.ScenarioUtils; @@ -196,7 +196,7 @@ private void createNetwork() { l.setCapacity(3600.0); network.addLink(l); } - + private void createPopulation() { Population pop = this.scenario.getPopulation(); PopulationFactory f = pop.getFactory(); diff --git a/matsim/src/test/java/org/matsim/integration/invertednetworks/LanesIT.java b/matsim/src/test/java/org/matsim/integration/invertednetworks/LanesIT.java index 5e5f2285367..caa73ab9468 100644 --- a/matsim/src/test/java/org/matsim/integration/invertednetworks/LanesIT.java +++ b/matsim/src/test/java/org/matsim/integration/invertednetworks/LanesIT.java @@ -33,7 +33,7 @@ import org.matsim.core.api.experimental.events.EventsManager; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.ControlerConfigGroup; +import org.matsim.core.config.groups.ControllerConfigGroup; import org.matsim.core.controler.AbstractModule; import org.matsim.core.controler.Controler; import org.matsim.core.controler.events.IterationEndsEvent; @@ -66,7 +66,7 @@ public void testLanes(){ config.network().setInputFile("network.xml"); config.network().setLaneDefinitionsFile("testLaneDefinitions_v2.0.xml"); config.plans().setInputFile("population.xml"); - config.controler().setRoutingAlgorithmType(ControlerConfigGroup.RoutingAlgorithmType.Dijkstra); + config.controler().setRoutingAlgorithmType(ControllerConfigGroup.RoutingAlgorithmType.Dijkstra); config.controler().setOutputDirectory(testUtils.getOutputDirectory() + "output"); final int lastIteration = 50; config.controler().setLastIteration(lastIteration); diff --git a/matsim/src/test/java/org/matsim/integration/pt/TransitIntegrationTest.java b/matsim/src/test/java/org/matsim/integration/pt/TransitIntegrationTest.java index 2936b6a464d..a83be7eadd9 100644 --- a/matsim/src/test/java/org/matsim/integration/pt/TransitIntegrationTest.java +++ b/matsim/src/test/java/org/matsim/integration/pt/TransitIntegrationTest.java @@ -23,8 +23,8 @@ import org.junit.Test; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup.ScoringParameterSet; +import org.matsim.core.config.groups.ScoringConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup.ScoringParameterSet; import org.matsim.core.controler.Controler; import org.matsim.pt.PtConstants; import org.matsim.testcases.MatsimTestUtils; @@ -37,7 +37,7 @@ public class TransitIntegrationTest { public void testPtInteractionParams() { Config config = ConfigUtils.createConfig(); config.controler().setOutputDirectory(utils.getOutputDirectory()); - PlanCalcScoreConfigGroup.ActivityParams params = new PlanCalcScoreConfigGroup.ActivityParams(PtConstants.TRANSIT_ACTIVITY_TYPE); + ScoringConfigGroup.ActivityParams params = new ScoringConfigGroup.ActivityParams(PtConstants.TRANSIT_ACTIVITY_TYPE); params.setScoringThisActivityAtAll(true); params.setTypicalDuration(60.0); config.planCalcScore().addActivityParams(params); @@ -47,13 +47,13 @@ public void testPtInteractionParams() { Controler controler = new Controler(config); controler.run(); } - - + + @Test(expected = RuntimeException.class) public void testSubpopulationParams() { Config config = ConfigUtils.createConfig(); config.controler().setOutputDirectory(utils.getOutputDirectory()); - PlanCalcScoreConfigGroup.ActivityParams params = new PlanCalcScoreConfigGroup.ActivityParams("home"); + ScoringConfigGroup.ActivityParams params = new ScoringConfigGroup.ActivityParams("home"); params.setScoringThisActivityAtAll(true); params.setTypicalDuration(60.0); ScoringParameterSet sps = config.planCalcScore().getOrCreateScoringParameters("one"); @@ -63,7 +63,7 @@ public void testSubpopulationParams() { // --- config.controler().setLastIteration(0); // in case the exception is _not_ thrown, we don't need 100 iterations to find that out ... config.checkConsistency(); - + Controler controler = new Controler(config); controler.run(); } diff --git a/matsim/src/test/java/org/matsim/integration/replanning/ChangeTripModeIntegrationTest.java b/matsim/src/test/java/org/matsim/integration/replanning/ChangeTripModeIntegrationTest.java index f7576dc5d95..fa69f0182e1 100644 --- a/matsim/src/test/java/org/matsim/integration/replanning/ChangeTripModeIntegrationTest.java +++ b/matsim/src/test/java/org/matsim/integration/replanning/ChangeTripModeIntegrationTest.java @@ -37,7 +37,7 @@ import org.matsim.api.core.v01.population.Plan; import org.matsim.api.core.v01.population.Population; import org.matsim.core.config.Config; -import org.matsim.core.config.groups.StrategyConfigGroup.StrategySettings; +import org.matsim.core.config.groups.ReplanningConfigGroup.StrategySettings; import org.matsim.core.controler.AbstractModule; import org.matsim.core.controler.Injector; import org.matsim.core.controler.NewControlerModule; diff --git a/matsim/src/test/java/org/matsim/integration/replanning/ReRoutingIT.java b/matsim/src/test/java/org/matsim/integration/replanning/ReRoutingIT.java index 585af080862..608381cdd4e 100644 --- a/matsim/src/test/java/org/matsim/integration/replanning/ReRoutingIT.java +++ b/matsim/src/test/java/org/matsim/integration/replanning/ReRoutingIT.java @@ -32,8 +32,8 @@ import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.population.PopulationWriter; import org.matsim.core.config.Config; -import org.matsim.core.config.groups.ControlerConfigGroup.EventsFileFormat; -import org.matsim.core.config.groups.ControlerConfigGroup.RoutingAlgorithmType; +import org.matsim.core.config.groups.ControllerConfigGroup.EventsFileFormat; +import org.matsim.core.config.groups.ControllerConfigGroup.RoutingAlgorithmType; import org.matsim.core.controler.Controler; import org.matsim.core.gbl.Gbl; import org.matsim.core.population.PopulationUtils; diff --git a/matsim/src/test/java/org/matsim/modules/ScoreStatsModuleTest.java b/matsim/src/test/java/org/matsim/modules/ScoreStatsModuleTest.java index 97d7c60b958..5c8ed368e94 100644 --- a/matsim/src/test/java/org/matsim/modules/ScoreStatsModuleTest.java +++ b/matsim/src/test/java/org/matsim/modules/ScoreStatsModuleTest.java @@ -37,7 +37,7 @@ import org.matsim.analysis.ScoreStats; import org.matsim.analysis.ScoreStatsControlerListener.ScoreItem; import org.matsim.core.config.Config; -import org.matsim.core.config.groups.PlansCalcRouteConfigGroup.AccessEgressType; +import org.matsim.core.config.groups.RoutingConfigGroup.AccessEgressType; import org.matsim.core.controler.AbstractModule; import org.matsim.core.controler.Controler; import org.matsim.core.controler.events.ShutdownEvent; diff --git a/matsim/src/test/java/org/matsim/pt/router/TransitRouterConfigTest.java b/matsim/src/test/java/org/matsim/pt/router/TransitRouterConfigTest.java index b77f034999d..a7a3f3cad17 100644 --- a/matsim/src/test/java/org/matsim/pt/router/TransitRouterConfigTest.java +++ b/matsim/src/test/java/org/matsim/pt/router/TransitRouterConfigTest.java @@ -23,8 +23,8 @@ import org.junit.Test; import org.matsim.api.core.v01.TransportMode; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup; -import org.matsim.core.config.groups.PlansCalcRouteConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup; +import org.matsim.core.config.groups.RoutingConfigGroup; import org.matsim.core.config.groups.VspExperimentalConfigGroup; import org.matsim.pt.config.TransitRouterConfigGroup; @@ -32,11 +32,11 @@ * @author mrieser */ public class TransitRouterConfigTest { - + @Test public void testConstructor() { - PlanCalcScoreConfigGroup planScoring = new PlanCalcScoreConfigGroup(); - PlansCalcRouteConfigGroup planRouting = new PlansCalcRouteConfigGroup(); + ScoringConfigGroup planScoring = new ScoringConfigGroup(); + RoutingConfigGroup planRouting = new RoutingConfigGroup(); TransitRouterConfigGroup transitRouting = new TransitRouterConfigGroup(); VspExperimentalConfigGroup vspConfig = new VspExperimentalConfigGroup() ; @@ -50,26 +50,26 @@ public void testConstructor() { // naturally, this failed after the functionality was moved to a separate planCalcScore parameter. kai, oct'12 planScoring.setPerforming_utils_hr(+6.0); - + planScoring.setUtilityOfLineSwitch(-2.34); - + planRouting.setTeleportedModeSpeed(TransportMode.walk, 1.37 ); // (this will clear all defaults!) planRouting.setBeelineDistanceFactor(1.2); - + transitRouting.setAdditionalTransferTime(128.0); transitRouting.setSearchRadius(987.6); transitRouting.setExtensionRadius(123.4); transitRouting.setMaxBeelineWalkConnectionDistance(23.4); - + // test without marginal utl of time: { TransitRouterConfig config = new TransitRouterConfig(planScoring, planRouting, transitRouting, vspConfig ); - + // Assert.assertEquals(-9.0/3600, config.getMarginalUtilityOfTravelTimePt_utl_s(), 1e-8); // Assert.assertEquals(-11.0/3600, config.getMarginalUtilityOfTravelTimeWalk_utl_s(), 1e-8); // Assert.assertEquals(-13.0/3600, config.getMarginalUtiltityOfWaiting_utl_s(), 1e-8); - // a number of changes related to the fact that the opportunity cost of time is now + // a number of changes related to the fact that the opportunity cost of time is now // included in the pt routing. Either the test here or some scoring // test needs to be adapted; this seems the better place. kai/benjamin, oct'12 Assert.assertEquals(-15.0/3600, config.getMarginalUtilityOfTravelTimePt_utl_s(), 1e-8); @@ -78,23 +78,23 @@ public void testConstructor() { Assert.assertEquals(-2.34, config.getUtilityOfLineSwitch_utl(), 1e-8); Assert.assertEquals(1.37 / 1.2, config.getBeelineWalkSpeed(), 1e-8); - + Assert.assertEquals(128.0, config.getAdditionalTransferTime(), 1e-8); Assert.assertEquals(987.6, config.getSearchRadius(), 1e-8); Assert.assertEquals(123.4, config.getExtensionRadius(), 1e-8); Assert.assertEquals(23.4, config.getBeelineWalkConnectionDistance(), 1e-8); } - + // test with marginal utl of time: { TransitRouterConfig config = new TransitRouterConfig(planScoring, planRouting, transitRouting, vspConfig ); - + Assert.assertEquals(-15.0/3600, config.getMarginalUtilityOfTravelTimePt_utl_s(), 1e-8); Assert.assertEquals(-17.0/3600, config.getMarginalUtilityOfTravelTimeWalk_utl_s(), 1e-8); Assert.assertEquals(-19.0/3600, config.getMarginalUtilityOfWaitingPt_utl_s(), 1e-8); Assert.assertEquals(-2.34, config.getUtilityOfLineSwitch_utl(), 1e-8); Assert.assertEquals(1.37 / 1.2, config.getBeelineWalkSpeed(), 1e-8); - + Assert.assertEquals(128.0, config.getAdditionalTransferTime(), 1e-8); Assert.assertEquals(987.6, config.getSearchRadius(), 1e-8); Assert.assertEquals(123.4, config.getExtensionRadius(), 1e-8); diff --git a/matsim/src/test/java/org/matsim/withinday/controller/ExampleWithinDayControllerTest.java b/matsim/src/test/java/org/matsim/withinday/controller/ExampleWithinDayControllerTest.java index 29b62c7ad50..f9af7981774 100644 --- a/matsim/src/test/java/org/matsim/withinday/controller/ExampleWithinDayControllerTest.java +++ b/matsim/src/test/java/org/matsim/withinday/controller/ExampleWithinDayControllerTest.java @@ -27,13 +27,12 @@ import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.population.Leg; import org.matsim.core.config.Config; -import org.matsim.core.config.groups.ControlerConfigGroup; +import org.matsim.core.config.groups.ControllerConfigGroup; import org.matsim.core.controler.Controler; import org.matsim.core.population.algorithms.PersonPrepareForSim; import org.matsim.core.population.algorithms.PlanAlgorithm; import org.matsim.core.router.PlanRouter; import org.matsim.core.router.TripRouterFactoryBuilderWithDefaults; -import org.matsim.core.router.costcalculators.FreespeedTravelTimeAndDisutility; import org.matsim.core.scenario.ScenarioUtils; import org.matsim.core.utils.timing.TimeInterpretation; import org.matsim.testcases.MatsimTestUtils; @@ -47,7 +46,7 @@ public class ExampleWithinDayControllerTest { public void testRun() { Config config = utils.loadConfig("test/scenarios/equil/config.xml"); config.controler().setLastIteration(1); - config.controler().setRoutingAlgorithmType(ControlerConfigGroup.RoutingAlgorithmType.Dijkstra); + config.controler().setRoutingAlgorithmType(ControllerConfigGroup.RoutingAlgorithmType.Dijkstra); Scenario scenario = ScenarioUtils.loadScenario(config); preparePlans(scenario); final Controler controler = new Controler(scenario); diff --git a/matsim/src/test/java/org/matsim/withinday/controller/ExperiencedPlansWriterTest.java b/matsim/src/test/java/org/matsim/withinday/controller/ExperiencedPlansWriterTest.java index 53e09f74ef5..dcd8b5444cb 100644 --- a/matsim/src/test/java/org/matsim/withinday/controller/ExperiencedPlansWriterTest.java +++ b/matsim/src/test/java/org/matsim/withinday/controller/ExperiencedPlansWriterTest.java @@ -37,8 +37,8 @@ import org.matsim.api.core.v01.population.*; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.ControlerConfigGroup; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup.ActivityParams; +import org.matsim.core.config.groups.ControllerConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup.ActivityParams; import org.matsim.core.controler.AbstractModule; import org.matsim.core.controler.Controler; import org.matsim.core.controler.OutputDirectoryHierarchy; @@ -86,7 +86,7 @@ public void testWriteFile() { config.qsim().setEndTime(24 * 3600); config.controler().setLastIteration(0); - config.controler().setRoutingAlgorithmType( ControlerConfigGroup.RoutingAlgorithmType.Dijkstra ); + config.controler().setRoutingAlgorithmType( ControllerConfigGroup.RoutingAlgorithmType.Dijkstra ); ActivityParams homeParams = new ActivityParams("home"); homeParams.setTypicalDuration(16*3600); diff --git a/matsim/src/test/java/org/matsim/withinday/replanning/identifiers/tools/ActivityReplanningMapTest.java b/matsim/src/test/java/org/matsim/withinday/replanning/identifiers/tools/ActivityReplanningMapTest.java index 2c0bcdcbc0f..4a96f92bd06 100644 --- a/matsim/src/test/java/org/matsim/withinday/replanning/identifiers/tools/ActivityReplanningMapTest.java +++ b/matsim/src/test/java/org/matsim/withinday/replanning/identifiers/tools/ActivityReplanningMapTest.java @@ -33,7 +33,7 @@ import org.matsim.api.core.v01.population.Activity; import org.matsim.api.core.v01.population.Person; import org.matsim.core.config.Config; -import org.matsim.core.config.groups.ControlerConfigGroup; +import org.matsim.core.config.groups.ControllerConfigGroup; import org.matsim.core.config.groups.QSimConfigGroup; import org.matsim.core.controler.AbstractModule; import org.matsim.core.controler.Controler; @@ -107,7 +107,7 @@ public class ActivityReplanningMapTest { config.controler().setLastIteration(0); config.qsim().setStartTime(0.0); config.qsim().setSimStarttimeInterpretation(QSimConfigGroup.StarttimeInterpretation.onlyUseStarttime); - config.controler().setRoutingAlgorithmType( ControlerConfigGroup.RoutingAlgorithmType.Dijkstra ); + config.controler().setRoutingAlgorithmType( ControllerConfigGroup.RoutingAlgorithmType.Dijkstra ); Controler controler = new Controler(config); controler.addOverridingModule(new WithinDayModule()); diff --git a/matsim/src/test/java/org/matsim/withinday/replanning/identifiers/tools/LinkReplanningMapTest.java b/matsim/src/test/java/org/matsim/withinday/replanning/identifiers/tools/LinkReplanningMapTest.java index 3d5c5a1a42c..36f262d4058 100644 --- a/matsim/src/test/java/org/matsim/withinday/replanning/identifiers/tools/LinkReplanningMapTest.java +++ b/matsim/src/test/java/org/matsim/withinday/replanning/identifiers/tools/LinkReplanningMapTest.java @@ -27,7 +27,7 @@ import org.junit.Rule; import org.junit.Test; import org.matsim.core.config.Config; -import org.matsim.core.config.groups.ControlerConfigGroup; +import org.matsim.core.config.groups.ControllerConfigGroup; import org.matsim.core.config.groups.QSimConfigGroup; import org.matsim.core.controler.AbstractModule; import org.matsim.core.controler.Controler; @@ -60,7 +60,7 @@ public class LinkReplanningMapTest { qSimConfig.setStorageCapFactor(100.0); // ensure that agents don't have to wait at an intersection config.controler().setMobsim("qsim"); config.controler().setLastIteration(0); - config.controler().setRoutingAlgorithmType( ControlerConfigGroup.RoutingAlgorithmType.Dijkstra ); + config.controler().setRoutingAlgorithmType( ControllerConfigGroup.RoutingAlgorithmType.Dijkstra ); Controler controler = new Controler(config); controler.addOverridingModule(new WithinDayModule()); diff --git a/matsim/src/test/java/org/matsim/withinday/trafficmonitoring/WithinDayTravelTimeTest.java b/matsim/src/test/java/org/matsim/withinday/trafficmonitoring/WithinDayTravelTimeTest.java index 90017100395..db4366a64a5 100644 --- a/matsim/src/test/java/org/matsim/withinday/trafficmonitoring/WithinDayTravelTimeTest.java +++ b/matsim/src/test/java/org/matsim/withinday/trafficmonitoring/WithinDayTravelTimeTest.java @@ -30,7 +30,7 @@ import org.matsim.api.core.v01.network.Network; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.ControlerConfigGroup; +import org.matsim.core.config.groups.ControllerConfigGroup; import org.matsim.core.config.groups.QSimConfigGroup; import org.matsim.core.controler.AbstractModule; import org.matsim.core.controler.Controler; @@ -38,7 +38,6 @@ import org.matsim.core.controler.events.StartupEvent; import org.matsim.core.controler.listener.StartupListener; import org.matsim.core.gbl.Gbl; -import org.matsim.core.gbl.MatsimRandom; import org.matsim.core.mobsim.framework.events.MobsimAfterSimStepEvent; import org.matsim.core.mobsim.framework.events.MobsimBeforeSimStepEvent; import org.matsim.core.mobsim.framework.events.MobsimInitializedEvent; @@ -90,7 +89,7 @@ private void testGetLinkTravelTime(boolean isUsingFastCapacityUpdate) { config.controler().setWritePlansInterval(0); config.controler().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); - config.controler().setRoutingAlgorithmType( ControlerConfigGroup.RoutingAlgorithmType.Dijkstra ); + config.controler().setRoutingAlgorithmType( ControllerConfigGroup.RoutingAlgorithmType.Dijkstra ); config.network().setTimeVariantNetwork(true); diff --git a/matsim/src/test/java/org/matsim/withinday/trafficmonitoring/WithinDayTravelTimeWithNetworkChangeEventsTest.java b/matsim/src/test/java/org/matsim/withinday/trafficmonitoring/WithinDayTravelTimeWithNetworkChangeEventsTest.java index a3a5c4070a1..0de7387c904 100644 --- a/matsim/src/test/java/org/matsim/withinday/trafficmonitoring/WithinDayTravelTimeWithNetworkChangeEventsTest.java +++ b/matsim/src/test/java/org/matsim/withinday/trafficmonitoring/WithinDayTravelTimeWithNetworkChangeEventsTest.java @@ -42,8 +42,8 @@ import org.matsim.api.core.v01.population.PopulationFactory; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.ControlerConfigGroup; -import org.matsim.core.config.groups.PlanCalcScoreConfigGroup.ActivityParams; +import org.matsim.core.config.groups.ControllerConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup.ActivityParams; import org.matsim.core.controler.AbstractModule; import org.matsim.core.controler.Controler; import org.matsim.core.controler.OutputDirectoryHierarchy.OverwriteFileSetting; @@ -58,9 +58,9 @@ /** * Tests if network change events are considered by {@link WithinDayTravelTime}. -* +* * @author ikaddoura -* +* */ public class WithinDayTravelTimeWithNetworkChangeEventsTest { @@ -70,84 +70,84 @@ public class WithinDayTravelTimeWithNetworkChangeEventsTest { private Id link01 = Id.createLinkId("link_0_1"); private Id link12 = Id.createLinkId("link_1_2"); private Id link23 = Id.createLinkId("link_2_3"); - + @Test public final void testTTviaMobSimAfterSimStepListener() { - + String outputDirectory = testUtils.getOutputDirectory() + "output_TTviaMobsimAfterSimStepListener/"; - + final Config config = ConfigUtils.createConfig(); - + config.controler().setFirstIteration(0); config.controler().setLastIteration(0); config.controler().setOutputDirectory(outputDirectory); - config.controler().setRoutingAlgorithmType( ControlerConfigGroup.RoutingAlgorithmType.Dijkstra ); + config.controler().setRoutingAlgorithmType( ControllerConfigGroup.RoutingAlgorithmType.Dijkstra ); config.qsim().setStartTime(6. * 3600.); config.qsim().setEndTime(11 * 3600.); - + ActivityParams paramsA = new ActivityParams(); paramsA.setActivityType("home"); paramsA.setTypicalDuration(1234.); config.planCalcScore().addActivityParams(paramsA); - + ActivityParams paramsB = new ActivityParams(); paramsB.setActivityType("work"); paramsB.setTypicalDuration(1234.); config.planCalcScore().addActivityParams(paramsB); - + config.network().setTimeVariantNetwork(true); - + final Scenario scenario = ScenarioUtils.createScenario(config); createNetwork(scenario); createPopulation(scenario); - + NetworkChangeEvent nce = new NetworkChangeEvent(10. * 3600.); nce.addLink(scenario.getNetwork().getLinks().get(link12)); nce.setFreespeedChange(new ChangeValue(NetworkChangeEvent.ChangeType.ABSOLUTE_IN_SI_UNITS, 1.)); NetworkUtils.addNetworkChangeEvent(scenario.getNetwork(), nce); - + final Controler controler = new Controler(scenario); controler.getConfig().controler().setOverwriteFileSetting(OverwriteFileSetting.overwriteExistingFiles); Set analyzedModes = new HashSet<>(); analyzedModes.add(TransportMode.car); final WithinDayTravelTime travelTime = new WithinDayTravelTime(controler.getScenario(), analyzedModes); - + final TtmobsimListener ttmobsimListener = new TtmobsimListener(nce); controler.addOverridingModule( new AbstractModule() { @Override public void install() { - + this.bind(TravelTime.class).toInstance(travelTime); this.addEventHandlerBinding().toInstance(travelTime); this.addMobsimListenerBinding().toInstance(travelTime); - + this.addMobsimListenerBinding().toInstance(ttmobsimListener); } }) ; - + controler.run(); - + Assert.assertEquals(true, ttmobsimListener.isCase1()); Assert.assertEquals(true, ttmobsimListener.isCase2()); - + } private void createPopulation(Scenario scenario) { Population population = scenario.getPopulation(); PopulationFactory popFactory = scenario.getPopulation().getFactory(); LinkNetworkRouteFactory routeFactory = new LinkNetworkRouteFactory(); - + Leg leg = popFactory.createLeg("car"); List> linkIds = new ArrayList>(); linkIds.add(link12); - + NetworkRoute route = (NetworkRoute) routeFactory.createRoute(link01, link23); route.setLinkIds(link01, linkIds, link23); leg.setRoute(route); - + Person person0 = popFactory.createPerson(Id.createPersonId("person0")); { Plan plan0 = popFactory.createPlan(); @@ -159,8 +159,8 @@ private void createPopulation(Scenario scenario) { plan0.addActivity(workAct0); person0.addPlan(plan0); } - - + + Person person1 = popFactory.createPerson(Id.createPersonId("person1")); { Plan plan1 = popFactory.createPlan(); @@ -172,13 +172,13 @@ private void createPopulation(Scenario scenario) { plan1.addActivity(workAct1); person1.addPlan(plan1); } - + population.addPerson(person0); population.addPerson(person1); } private void createNetwork(Scenario scenario) { - + Network network = scenario.getNetwork(); network.setEffectiveCellSize(7.5); network.setCapacityPeriod(3600.); @@ -187,32 +187,32 @@ private void createNetwork(Scenario scenario) { Node node1 = network.getFactory().createNode(Id.create("1", Node.class), new Coord(1000., 0.)); Node node2 = network.getFactory().createNode(Id.create("2", Node.class), new Coord(2000., 0.)); Node node3 = network.getFactory().createNode(Id.create("3", Node.class), new Coord(3000., 0.)); - + Link link1 = network.getFactory().createLink(link01 , node0, node1); Link link2 = network.getFactory().createLink(link12, node1, node2); Link link3 = network.getFactory().createLink(link23, node2, node3); - + Set modes = new HashSet(); modes.add("car"); - + link1.setAllowedModes(modes); link1.setCapacity(7200); link1.setFreespeed(10.123); link1.setNumberOfLanes(2); link1.setLength(1000); - + link2.setAllowedModes(modes); link2.setCapacity(7200); link2.setFreespeed(10.123); link2.setNumberOfLanes(2); link2.setLength(1000); - + link3.setAllowedModes(modes); link3.setCapacity(7200); link3.setFreespeed(10.123); link3.setNumberOfLanes(2); link3.setLength(1000); - + network.addNode(node0); network.addNode(node1); network.addNode(node2); diff --git a/matsim/src/test/java/org/matsim/withinday/utils/EditRoutesTest.java b/matsim/src/test/java/org/matsim/withinday/utils/EditRoutesTest.java index e26e178fb84..c441971cfc6 100644 --- a/matsim/src/test/java/org/matsim/withinday/utils/EditRoutesTest.java +++ b/matsim/src/test/java/org/matsim/withinday/utils/EditRoutesTest.java @@ -43,8 +43,8 @@ import org.matsim.api.core.v01.population.Person; import org.matsim.api.core.v01.population.Plan; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.PlansCalcRouteConfigGroup; -import org.matsim.core.config.groups.PlansCalcRouteConfigGroup.AccessEgressType; +import org.matsim.core.config.groups.RoutingConfigGroup; +import org.matsim.core.config.groups.RoutingConfigGroup.AccessEgressType; import org.matsim.core.controler.AbstractModule; import org.matsim.core.controler.Injector; import org.matsim.core.population.PopulationUtils; @@ -155,7 +155,7 @@ public class EditRoutesTest { int scndAct = 2 ; int scndCarLeg = 3 ; // 3-->9 int thrdAct = 4 ; - if ( !scenario.getConfig().plansCalcRoute().getAccessEgressType().equals(PlansCalcRouteConfigGroup.AccessEgressType.none) ) { + if ( !scenario.getConfig().plansCalcRoute().getAccessEgressType().equals(RoutingConfigGroup.AccessEgressType.none) ) { firstCarLeg = 3 ; // 1-->3 scndAct = 6 ; scndCarLeg = 9 ; // 3-->9 @@ -232,7 +232,7 @@ public class EditRoutesTest { createScenario(); int firstCarLeg = 1 ; // 1-->3 int scndCarLeg = 3 ; // 3-->9 - if ( !scenario.getConfig().plansCalcRoute().getAccessEgressType().equals(PlansCalcRouteConfigGroup.AccessEgressType.none) ) { + if ( !scenario.getConfig().plansCalcRoute().getAccessEgressType().equals(RoutingConfigGroup.AccessEgressType.none) ) { firstCarLeg = 3 ; // 1-->3 scndCarLeg = 9 ; // 3-->9 } @@ -304,7 +304,7 @@ public class EditRoutesTest { int firstCarLeg = 1 ; // 1-->3 int scndCarLeg = 3 ; // 3-->9 - if ( !scenario.getConfig().plansCalcRoute().getAccessEgressType().equals(PlansCalcRouteConfigGroup.AccessEgressType.none) ) { + if ( !scenario.getConfig().plansCalcRoute().getAccessEgressType().equals(RoutingConfigGroup.AccessEgressType.none) ) { firstCarLeg = 3 ; // 1-->3 scndCarLeg = 9 ; // 3-->9 } @@ -345,7 +345,7 @@ public class EditRoutesTest { int firstCarLeg = 1 ; // 1-->3 int scndCarLeg = 3 ; // 3-->9 - if ( !scenario.getConfig().plansCalcRoute().getAccessEgressType().equals(PlansCalcRouteConfigGroup.AccessEgressType.none) ) { + if ( !scenario.getConfig().plansCalcRoute().getAccessEgressType().equals(RoutingConfigGroup.AccessEgressType.none) ) { firstCarLeg = 3 ; // 1-->3 scndCarLeg = 9 ; // 3-->9 } @@ -364,7 +364,7 @@ public class EditRoutesTest { int firstCarLeg = 1 ; // 1-->3 int scndCarLeg = 3 ; // 3-->9 - if ( !scenario.getConfig().plansCalcRoute().getAccessEgressType().equals(PlansCalcRouteConfigGroup.AccessEgressType.none) ) { + if ( !scenario.getConfig().plansCalcRoute().getAccessEgressType().equals(RoutingConfigGroup.AccessEgressType.none) ) { firstCarLeg = 3 ; // 1-->3 scndCarLeg = 9 ; // 3-->9 } @@ -402,7 +402,7 @@ public class EditRoutesTest { int firstCarLeg = 1 ; // 1-->3 int scndCarLeg = 3 ; // 3-->9 - if ( !scenario.getConfig().plansCalcRoute().getAccessEgressType().equals(PlansCalcRouteConfigGroup.AccessEgressType.none) ) { + if ( !scenario.getConfig().plansCalcRoute().getAccessEgressType().equals(RoutingConfigGroup.AccessEgressType.none) ) { firstCarLeg = 3 ; // 1-->3 scndCarLeg = 9 ; // 3-->9 } @@ -442,7 +442,7 @@ public class EditRoutesTest { int firstCarLeg = 1 ; // 1-->3 int scndCarLeg = 3 ; // 3-->9 - if ( !scenario.getConfig().plansCalcRoute().getAccessEgressType().equals(PlansCalcRouteConfigGroup.AccessEgressType.none) ) { + if ( !scenario.getConfig().plansCalcRoute().getAccessEgressType().equals(RoutingConfigGroup.AccessEgressType.none) ) { firstCarLeg = 3 ; // 1-->3 scndCarLeg = 9 ; // 3-->9 } From a751511ddc13008596dae6c21345cb18a62232b8 Mon Sep 17 00:00:00 2001 From: Marcel Rieser Date: Wed, 11 Oct 2023 16:43:42 +0200 Subject: [PATCH 11/25] additional test for renaming config modules and params --- .../core/config/ConfigReaderMatsimV2Test.java | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/matsim/src/test/java/org/matsim/core/config/ConfigReaderMatsimV2Test.java b/matsim/src/test/java/org/matsim/core/config/ConfigReaderMatsimV2Test.java index 5acc3a3d142..8d30795c5a1 100644 --- a/matsim/src/test/java/org/matsim/core/config/ConfigReaderMatsimV2Test.java +++ b/matsim/src/test/java/org/matsim/core/config/ConfigReaderMatsimV2Test.java @@ -81,6 +81,39 @@ public void testModuleAndParamNameAlias() { Assert.assertEquals(23, config.controler().getLastIteration()); } + /** + * Test that a parameter can be renamed inside a renamed module. + */ + @Test + public void testConditionalParamNameAliasWithModuleRenaming() { + Config config = ConfigUtils.createConfig(); + ConfigReaderMatsimV2 r2 = new ConfigReaderMatsimV2(config); + + String xml = """ + + + + + + + + + + + """; + ByteArrayInputStream bais = new ByteArrayInputStream(xml.getBytes(StandardCharsets.UTF_8)); + + r2.addAlias("the_network", "network"); + r2.addAlias("the_plans", "plans"); + // for the path, the new name needs to be used: + r2.addAlias("input", "inputNetworkFile", "network"); + r2.addAlias("input", "inputPlansFile", "plans"); + r2.readStream(bais); + + Assert.assertEquals("my_network.xml.gz", config.network().getInputFile()); + Assert.assertEquals("my_plans.xml.gz", config.plans().getInputFile()); + } + /** * Test that 2 aliases for the same parameter name resolve to * different parameter names depending on in which module they are in. From 7c88f6d21e6bca63f50b7a297747f959d27f0ae9 Mon Sep 17 00:00:00 2001 From: Marcel Rieser Date: Wed, 11 Oct 2023 16:48:16 +0200 Subject: [PATCH 12/25] adapt to parameter names in ScoringConfigGroup to new naming convention --- .../java/org/matsim/core/config/ConfigReaderMatsimV2.java | 3 +++ .../org/matsim/core/config/groups/ScoringConfigGroup.java | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/matsim/src/main/java/org/matsim/core/config/ConfigReaderMatsimV2.java b/matsim/src/main/java/org/matsim/core/config/ConfigReaderMatsimV2.java index 246bc1a9609..efa7632a2b9 100644 --- a/matsim/src/main/java/org/matsim/core/config/ConfigReaderMatsimV2.java +++ b/matsim/src/main/java/org/matsim/core/config/ConfigReaderMatsimV2.java @@ -70,6 +70,9 @@ public void addDefaultAliases() { this.addAlias("planscalcroute", "routing"); this.addAlias("strategy", "replanning"); this.addAlias("parallelEventHandling", "eventsManager"); + + this.addAlias("BrainExpBeta", "brainExpBeta", "scoring"); + this.addAlias("PathSizeLogitBeta", "pathSizeLogitBeta", "scoring"); } public void addAlias(String oldName, String newName, String... path) { diff --git a/matsim/src/main/java/org/matsim/core/config/groups/ScoringConfigGroup.java b/matsim/src/main/java/org/matsim/core/config/groups/ScoringConfigGroup.java index effe07e8059..d2d926805d6 100644 --- a/matsim/src/main/java/org/matsim/core/config/groups/ScoringConfigGroup.java +++ b/matsim/src/main/java/org/matsim/core/config/groups/ScoringConfigGroup.java @@ -63,8 +63,8 @@ public final class ScoringConfigGroup extends ConfigGroup { public static final String GROUP_NAME = "scoring"; private static final String LEARNING_RATE = "learningRate"; - private static final String BRAIN_EXP_BETA = "BrainExpBeta"; - private static final String PATH_SIZE_LOGIT_BETA = "PathSizeLogitBeta"; + private static final String BRAIN_EXP_BETA = "brainExpBeta"; + private static final String PATH_SIZE_LOGIT_BETA = "pathSizeLogitBeta"; private static final String LATE_ARRIVAL = "lateArrival"; private static final String EARLY_DEPARTURE = "earlyDeparture"; private static final String PERFORMING = "performing"; From 27ffbf51b03a678b2a3cb8c8cdfe8c33438dcb40 Mon Sep 17 00:00:00 2001 From: u229187 Date: Wed, 11 Oct 2023 17:21:59 +0200 Subject: [PATCH 13/25] also add setters for Access / Egresstimes --- .../pt/transitSchedule/TransitScheduleUtils.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/matsim/src/main/java/org/matsim/pt/transitSchedule/TransitScheduleUtils.java b/matsim/src/main/java/org/matsim/pt/transitSchedule/TransitScheduleUtils.java index daa09376a11..e06377d0351 100644 --- a/matsim/src/main/java/org/matsim/pt/transitSchedule/TransitScheduleUtils.java +++ b/matsim/src/main/java/org/matsim/pt/transitSchedule/TransitScheduleUtils.java @@ -45,10 +45,22 @@ public static double getStopAccessTime(TransitStopFacility stopFacility){ return accessTime!=null?(double) accessTime:0.0; } + public static void setStopAccessTime(TransitStopFacility stopFacility, double stopAccessTime){ + stopFacility.getAttributes().putAttribute(ACCESSTIME_ATTRIBUTE,stopAccessTime); + } + public static double getStopEgressTime(TransitStopFacility stopFacility){ Object egressTime = stopFacility.getAttributes().getAttribute(EGRESSTIME_ATTRIBUTE); return egressTime!=null?(double) egressTime:0.0; } + public static void setStopEgressTime(TransitStopFacility stopFacility, double stopEgressTime){ + stopFacility.getAttributes().putAttribute(EGRESSTIME_ATTRIBUTE,stopEgressTime); + } + + public static void setSymmetricStopAccessEgressTime(TransitStopFacility stopFacility, double stopAccessEgressTime){ + setStopAccessTime(stopFacility,stopAccessEgressTime); + setStopEgressTime(stopFacility,stopAccessEgressTime); + } public static QuadTree createQuadTreeOfTransitStopFacilities(TransitSchedule transitSchedule) { return createQuadTreeOfTransitStopFacilities(transitSchedule.getFacilities().values()); From 2b5455302828dd8f1274ced630ef73f1b187561f Mon Sep 17 00:00:00 2001 From: u229187 Date: Wed, 11 Oct 2023 17:22:37 +0200 Subject: [PATCH 14/25] add constant access and egresstimes for stations to DefaultRaptorStopFinder --- .../pt/raptor/DefaultRaptorStopFinder.java | 34 +++++----- .../raptor/SwissRailRaptorIntermodalTest.java | 65 +++++++++++++++++++ .../pt/raptor/SwissRailRaptorTest.java | 23 +++++++ 3 files changed, 105 insertions(+), 17 deletions(-) diff --git a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/DefaultRaptorStopFinder.java b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/DefaultRaptorStopFinder.java index 073d6955b91..6636713979c 100644 --- a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/DefaultRaptorStopFinder.java +++ b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/DefaultRaptorStopFinder.java @@ -207,24 +207,24 @@ private void addInitialStopsForParamSet(Facility fromFacility, Facility toFacili // the router for the access/egress mode could not find a route, skip that access/egress mode continue; } - if (stopFacility != stop) { - if (direction == Direction.ACCESS) { - Leg transferLeg = PopulationUtils.createLeg(TransportMode.walk); - Route transferRoute = RouteUtils.createGenericRouteImpl(stopFacility.getLinkId(), stop.getLinkId()); - double accessTime = TransitScheduleUtils.getStopAccessTime(stop); - transferRoute.setTravelTime(accessTime); - transferRoute.setDistance(0); - transferLeg.setRoute(transferRoute); - transferLeg.setTravelTime(accessTime); + double accessTime = TransitScheduleUtils.getStopAccessTime(stop); + double egressTime = TransitScheduleUtils.getStopEgressTime(stop); + if ((stopFacility != stop) || accessTime>0.0 || egressTime>0.0) { + if (direction == Direction.ACCESS) { + Leg transferLeg = PopulationUtils.createLeg(TransportMode.walk); + Route transferRoute = RouteUtils.createGenericRouteImpl(stopFacility.getLinkId(), stop.getLinkId()); + transferRoute.setTravelTime(accessTime); + transferRoute.setDistance(0); + transferLeg.setRoute(transferRoute); + transferLeg.setTravelTime(accessTime); - List tmp = new ArrayList<>(routeParts.size() + 1); - tmp.addAll(routeParts); - tmp.add(transferLeg); - routeParts = tmp; - } else { - Leg transferLeg = PopulationUtils.createLeg(TransportMode.walk); - Route transferRoute = RouteUtils.createGenericRouteImpl(stop.getLinkId(), stopFacility.getLinkId()); - double egressTime = TransitScheduleUtils.getStopEgressTime(stop); + List tmp = new ArrayList<>(routeParts.size() + 1); + tmp.addAll(routeParts); + tmp.add(transferLeg); + routeParts = tmp; + } else { + Leg transferLeg = PopulationUtils.createLeg(TransportMode.walk); + Route transferRoute = RouteUtils.createGenericRouteImpl(stop.getLinkId(), stopFacility.getLinkId()); transferRoute.setTravelTime(egressTime); transferRoute.setDistance(0); transferLeg.setRoute(transferRoute); diff --git a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorIntermodalTest.java b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorIntermodalTest.java index 7ec0a2f552c..15fcc06606c 100644 --- a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorIntermodalTest.java +++ b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorIntermodalTest.java @@ -32,6 +32,7 @@ import org.matsim.core.utils.geometry.CoordUtils; import org.matsim.facilities.Facility; import org.matsim.pt.PtConstants; +import org.matsim.pt.transitSchedule.TransitScheduleUtils; import org.matsim.pt.transitSchedule.api.Departure; import org.matsim.pt.transitSchedule.api.TransitLine; import org.matsim.pt.transitSchedule.api.TransitRoute; @@ -39,6 +40,7 @@ import org.matsim.pt.transitSchedule.api.TransitSchedule; import org.matsim.pt.transitSchedule.api.TransitScheduleFactory; import org.matsim.pt.transitSchedule.api.TransitStopFacility; +import org.matsim.testcases.MatsimTestUtils; import org.matsim.utils.objectattributes.attributable.AttributesImpl; import java.util.ArrayList; @@ -1220,6 +1222,69 @@ public List calcRoute(RoutingRequest request) { Assert.assertEquals(Id.create("to", Link.class), leg.getRoute().getEndLinkId()); } + @Test + public void testIntermodalTripWithAccessAndEgressTimesAtStops() { + IntermodalFixture f = new IntermodalFixture(); + f.scenario.getTransitSchedule().getFacilities().values() + .forEach(stopFacility -> TransitScheduleUtils.setSymmetricStopAccessEgressTime(stopFacility,120.0)); + PlanCalcScoreConfigGroup.ModeParams walk = new PlanCalcScoreConfigGroup.ModeParams(TransportMode.walk); + walk.setMarginalUtilityOfTraveling(0.0); + f.config.planCalcScore().addModeParams(walk); + + Map routingModules = new HashMap<>(); + routingModules.put(TransportMode.walk, + new TeleportationRoutingModule(TransportMode.walk, f.scenario, 1.1, 1.3)); + routingModules.put(TransportMode.bike, + new TeleportationRoutingModule(TransportMode.bike, f.scenario, 3, 1.4)); + + f.srrConfig.setUseIntermodalAccessEgress(true); + IntermodalAccessEgressParameterSet walkAccess = new IntermodalAccessEgressParameterSet(); + walkAccess.setMode(TransportMode.walk); + walkAccess.setMaxRadius(1000); + walkAccess.setInitialSearchRadius(1000); + f.srrConfig.addIntermodalAccessEgress(walkAccess); + IntermodalAccessEgressParameterSet bikeAccess = new IntermodalAccessEgressParameterSet(); + bikeAccess.setMode(TransportMode.bike); + bikeAccess.setMaxRadius(1500); + bikeAccess.setInitialSearchRadius(1500); + bikeAccess.setStopFilterAttribute("bikeAccessible"); + bikeAccess.setLinkIdAttribute("accessLinkId_bike"); + bikeAccess.setStopFilterValue("true"); + f.srrConfig.addIntermodalAccessEgress(bikeAccess); + + SwissRailRaptorData data = SwissRailRaptorData.create(f.scenario.getTransitSchedule(), null, RaptorUtils.createStaticConfig(f.config), f.scenario.getNetwork(), null); + DefaultRaptorStopFinder stopFinder = new DefaultRaptorStopFinder(new DefaultRaptorIntermodalAccessEgress(), routingModules); + SwissRailRaptor raptor = new SwissRailRaptor.Builder(data, f.scenario.getConfig()).with(stopFinder).build(); + + Facility fromFac = new FakeFacility(new Coord(10000, 10500), Id.create("from", Link.class)); + Facility toFac = new FakeFacility(new Coord(50000, 10500), Id.create("to", Link.class)); + + List legs = raptor.calcRoute(DefaultRoutingRequest.withoutAttributes(fromFac, toFac, 7*3600, f.dummyPerson)); + for (PlanElement leg : legs) { + System.out.println(leg); + } + + Assert.assertEquals("wrong number of legs.", 5, legs.size()); + Leg leg = (Leg) legs.get(1); + Assert.assertEquals(TransportMode.walk, leg.getMode()); + Assert.assertEquals(Id.create("pt_2", Link.class), leg.getRoute().getStartLinkId()); + Assert.assertEquals(Id.create("pt_2", Link.class), leg.getRoute().getEndLinkId()); + Assert.assertEquals(120.0,leg.getTravelTime().seconds(), MatsimTestUtils.EPSILON); + leg = (Leg) legs.get(2); + Assert.assertEquals(TransportMode.pt, leg.getMode()); + Assert.assertEquals(Id.create("pt_2", Link.class), leg.getRoute().getStartLinkId()); + Assert.assertEquals(Id.create("pt_5", Link.class), leg.getRoute().getEndLinkId()); + leg = (Leg) legs.get(3); + Assert.assertEquals(TransportMode.walk, leg.getMode()); + Assert.assertEquals(Id.create("pt_5", Link.class), leg.getRoute().getStartLinkId()); + Assert.assertEquals(Id.create("bike_5", Link.class), leg.getRoute().getEndLinkId()); + Assert.assertEquals(120.0,leg.getTravelTime().seconds(), MatsimTestUtils.EPSILON); + leg = (Leg) legs.get(4); + Assert.assertEquals(TransportMode.bike, leg.getMode()); + Assert.assertEquals(Id.create("bike_5", Link.class), leg.getRoute().getStartLinkId()); + Assert.assertEquals(Id.create("to", Link.class), leg.getRoute().getEndLinkId()); + } + /* for test of intermodal routing requiring transfers at the beginning or end of the pt trip, diff --git a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorTest.java b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorTest.java index 4eb2d0f01c5..6c728fe3d47 100644 --- a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorTest.java +++ b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorTest.java @@ -37,6 +37,7 @@ import org.matsim.facilities.ActivityFacility; import org.matsim.pt.router.TransitRouter; import org.matsim.pt.routes.TransitPassengerRoute; +import org.matsim.pt.transitSchedule.TransitScheduleUtils; import org.matsim.pt.transitSchedule.api.Departure; import org.matsim.pt.transitSchedule.api.TransitLine; import org.matsim.pt.transitSchedule.api.TransitRoute; @@ -153,6 +154,28 @@ public void testWalkDurations() { assertEquals(Math.ceil(expectedEgressWalkTime), ((Leg)legs.get(2)).getTravelTime().seconds(), MatsimTestUtils.EPSILON); } + + @Test + public void testStationAccessEgressTimes() { + Fixture f = new Fixture(); + f.init(); + RaptorParameters raptorParams = RaptorUtils.createParameters(f.config); + f.schedule.getFacilities().values().forEach(facility-> TransitScheduleUtils.setSymmetricStopAccessEgressTime(facility,120.0)); + TransitRouter router = createTransitRouter(f.schedule, f.config, f.network); + Coord fromCoord = new Coord(3800, 5100); + Coord toCoord = new Coord(16100, 5050); + List legs = router.calcRoute(DefaultRoutingRequest.withoutAttributes(new FakeFacility(fromCoord), new FakeFacility(toCoord), 5.0*3600, null)); + assertEquals(3, legs.size()); + assertEquals(TransportMode.walk, ((Leg)legs.get(0)).getMode()); + assertEquals(TransportMode.pt, ((Leg)legs.get(1)).getMode()); + assertEquals(TransportMode.walk, ((Leg)legs.get(2)).getMode()); + + double expectedAccessWalkTime = 120.0 + CoordUtils.calcEuclideanDistance(f.schedule.getFacilities().get(Id.create("0", TransitStopFacility.class)).getCoord(), fromCoord) / raptorParams.getBeelineWalkSpeed(); + assertEquals(Math.ceil(expectedAccessWalkTime), ((Leg)legs.get(0)).getTravelTime().seconds(), MatsimTestUtils.EPSILON); + double expectedEgressWalkTime = 120.0 + CoordUtils.calcEuclideanDistance(f.schedule.getFacilities().get(Id.create("6", TransitStopFacility.class)).getCoord(), toCoord) / raptorParams.getBeelineWalkSpeed(); + assertEquals(Math.ceil(expectedEgressWalkTime), ((Leg)legs.get(2)).getTravelTime().seconds(), MatsimTestUtils.EPSILON); + } + @Test public void testWalkDurations_range() { Fixture f = new Fixture(); From 9dee6fae9d24798dcc83466c895880c1dc2ba386 Mon Sep 17 00:00:00 2001 From: Marcel Rieser Date: Wed, 11 Oct 2023 17:51:19 +0200 Subject: [PATCH 15/25] extract config-aliases to separate class it is easier to reuse it when it's not inside ConfigReaderMatsimV2 --- .../org/matsim/core/config/ConfigAliases.java | 85 +++++++++++++++++ .../core/config/ConfigReaderMatsimV2.java | 95 ++++--------------- .../core/config/ConfigReaderMatsimV2Test.java | 37 ++++---- 3 files changed, 124 insertions(+), 93 deletions(-) create mode 100644 matsim/src/main/java/org/matsim/core/config/ConfigAliases.java diff --git a/matsim/src/main/java/org/matsim/core/config/ConfigAliases.java b/matsim/src/main/java/org/matsim/core/config/ConfigAliases.java new file mode 100644 index 00000000000..cf5e449e302 --- /dev/null +++ b/matsim/src/main/java/org/matsim/core/config/ConfigAliases.java @@ -0,0 +1,85 @@ +package org.matsim.core.config; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import java.util.ArrayList; +import java.util.Deque; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Stack; +import java.util.stream.Collectors; + +public final class ConfigAliases { + + private final static Logger LOG = LogManager.getLogger(ConfigAliases.class); + + private final Map> aliases = new HashMap<>(); + + public ConfigAliases() { + this.addDefaultAliases(); + } + + public void addDefaultAliases() { + this.addAlias("ReplanningAnnealer", "replanningAnnealer"); + this.addAlias("TimeAllocationMutator", "timeAllocationMutator"); + this.addAlias("JDEQSim", "jdeqsim"); + this.addAlias("controler", "controller"); + this.addAlias("planCalcScore", "scoring"); + this.addAlias("planscalcroute", "routing"); + this.addAlias("strategy", "replanning"); + this.addAlias("parallelEventHandling", "eventsManager"); + + this.addAlias("BrainExpBeta", "brainExpBeta", "scoring"); + this.addAlias("PathSizeLogitBeta", "pathSizeLogitBeta", "scoring"); + } + + public void addAlias(String oldName, String newName, String... path) { + this.aliases.computeIfAbsent(oldName, k -> new ArrayList<>(2)).add(new ConfigAlias(oldName, newName, path)); + } + + public void clearAliases() { + this.aliases.clear(); + } + + public String resolveAlias(String oldName, Deque pathStack) { + List definedAliases = this.aliases.get(oldName); + if (definedAliases == null || definedAliases.isEmpty()) { + return oldName; + } + for (ConfigAlias alias: definedAliases) { + boolean matches = true; + + if (alias.path.length > pathStack.size()) { + matches = false; + } else { + Iterator iter = pathStack.iterator(); + for (int i = alias.path.length - 1; i >= 0; i--) { + if (iter.hasNext()) { + String name = iter.next(); + if (!name.equals(alias.path[i])) { + matches = false; + break; + } + } else { + matches = false; + break; + } + } + } + + if (matches) { + String stack = pathStack.stream().collect(Collectors.joining(" < ", oldName + " < ", " /")); + LOG.warn("Config name '{}' is deprecated, please use '{}' instead. Config path: {}", oldName, alias.newName, stack); + return alias.newName; + } + } + return oldName; + } + + public record ConfigAlias(String oldName, String newName, String[] path) { + } + +} diff --git a/matsim/src/main/java/org/matsim/core/config/ConfigReaderMatsimV2.java b/matsim/src/main/java/org/matsim/core/config/ConfigReaderMatsimV2.java index efa7632a2b9..706e9d5cbd0 100644 --- a/matsim/src/main/java/org/matsim/core/config/ConfigReaderMatsimV2.java +++ b/matsim/src/main/java/org/matsim/core/config/ConfigReaderMatsimV2.java @@ -50,72 +50,17 @@ class ConfigReaderMatsimV2 extends MatsimXmlParser { private final Config config; - private final Map> aliases = new HashMap<>(); + private final ConfigAliases aliases = new ConfigAliases(); private final Deque moduleStack = new ArrayDeque<>(); + private final Deque pathStack = new ArrayDeque<>(); ConfigReaderMatsimV2(final Config config) { super(ValidationType.DTD_ONLY); this.config = config; - this.addDefaultAliases(); } - public void addDefaultAliases() { - // when renaming config modules and parameter names, add them here as aliases: - - this.addAlias("ReplanningAnnealer", "replanningAnnealer"); - this.addAlias("TimeAllocationMutator", "timeAllocationMutator"); - this.addAlias("JDEQSim", "jdeqsim"); - this.addAlias("controler", "controller"); - this.addAlias("planCalcScore", "scoring"); - this.addAlias("planscalcroute", "routing"); - this.addAlias("strategy", "replanning"); - this.addAlias("parallelEventHandling", "eventsManager"); - - this.addAlias("BrainExpBeta", "brainExpBeta", "scoring"); - this.addAlias("PathSizeLogitBeta", "pathSizeLogitBeta", "scoring"); - } - - public void addAlias(String oldName, String newName, String... path) { - this.aliases.computeIfAbsent(oldName, k -> new ArrayList<>(2)).add(new ConfigAlias(oldName, newName, path)); - } - - public void clearAliases() { - this.aliases.clear(); - } - - private String resolveAlias(String oldName) { - List definedAliases = this.aliases.get(oldName); - if (definedAliases == null || definedAliases.isEmpty()) { - return oldName; - } - for (ConfigAlias alias: definedAliases) { - boolean matches = true; - - if (alias.path.length > this.moduleStack.size()) { - matches = false; - } else { - Iterator iter = this.moduleStack.iterator(); - for (int i = alias.path.length - 1; i >= 0; i--) { - if (iter.hasNext()) { - String name = iter.next().getName(); - if (!name.equals(alias.path[i])) { - matches = false; - break; - } - } else { - matches = false; - break; - } - } - } - - if (matches) { - String stack = this.moduleStack.stream().map(c -> c.getName()).collect(Collectors.joining(" < ", oldName + " < ", " /")); - LOG.warn("Config name '{}' is deprecated, please use '{}' instead. Config path: {}", oldName, alias.newName, stack); - return alias.newName; - } - } - return oldName; + public ConfigAliases getConfigAliases() { + return this.aliases; } @Override @@ -141,25 +86,27 @@ else if ( !name.equals( "config" ) ) { } private void startParameter(final Attributes atts) { - String name = resolveAlias(atts.getValue(NAME)); - moduleStack.getFirst().addParam( + String name = this.aliases.resolveAlias(atts.getValue(NAME), this.pathStack); + this.moduleStack.getFirst().addParam( name, atts.getValue( VALUE ) ); } private void startParameterSet(final Attributes atts) { - String type = resolveAlias(atts.getValue(TYPE)); - final ConfigGroup m = moduleStack.getFirst().createParameterSet( type ); - moduleStack.addFirst( m ); + String type = this.aliases.resolveAlias(atts.getValue(TYPE), this.pathStack); + final ConfigGroup m = this.moduleStack.getFirst().createParameterSet( type ); + this.moduleStack.addFirst(m); + this.pathStack.addFirst(m.getName()); } private void startModule(final Attributes atts) { - String name = resolveAlias(atts.getValue(NAME)); - final ConfigGroup m = config.getModule(name); - moduleStack.addFirst( - m == null ? - config.createModule(name) : - m ); + String name = this.aliases.resolveAlias(atts.getValue(NAME), this.pathStack); + ConfigGroup m = this.config.getModule(name); + if (m == null) { + m = this.config.createModule(name); + } + this.moduleStack.addFirst(m); + this.pathStack.addFirst(m.getName()); } @Override @@ -168,14 +115,12 @@ public void endTag( final String content, final Stack context) { if ( name.equals( MODULE ) || name.equals( PARAMETER_SET ) ) { - final ConfigGroup head = moduleStack.removeFirst(); + final ConfigGroup head = this.moduleStack.removeFirst(); + this.pathStack.removeFirst(); - if ( !moduleStack.isEmpty() ) moduleStack.getFirst().addParameterSet( head ); + if ( !this.moduleStack.isEmpty() ) this.moduleStack.getFirst().addParameterSet( head ); } } - public record ConfigAlias(String oldName, String newName, String[] path) { - } - } diff --git a/matsim/src/test/java/org/matsim/core/config/ConfigReaderMatsimV2Test.java b/matsim/src/test/java/org/matsim/core/config/ConfigReaderMatsimV2Test.java index 8d30795c5a1..2930c9770f9 100644 --- a/matsim/src/test/java/org/matsim/core/config/ConfigReaderMatsimV2Test.java +++ b/matsim/src/test/java/org/matsim/core/config/ConfigReaderMatsimV2Test.java @@ -30,7 +30,7 @@ public void testModuleNameAlias() { """; ByteArrayInputStream bais = new ByteArrayInputStream(xml.getBytes(StandardCharsets.UTF_8)); - r2.addAlias("theController", ControllerConfigGroup.GROUP_NAME); + r2.getConfigAliases().addAlias("theController", ControllerConfigGroup.GROUP_NAME); r2.readStream(bais); Assert.assertEquals(27, config.controler().getLastIteration()); @@ -52,7 +52,7 @@ public void testParamNameAlias() { """; ByteArrayInputStream bais = new ByteArrayInputStream(xml.getBytes(StandardCharsets.UTF_8)); - r2.addAlias("theLastIteration", "lastIteration"); + r2.getConfigAliases().addAlias("theLastIteration", "lastIteration"); r2.readStream(bais); Assert.assertEquals(23, config.controler().getLastIteration()); @@ -74,8 +74,8 @@ public void testModuleAndParamNameAlias() { """; ByteArrayInputStream bais = new ByteArrayInputStream(xml.getBytes(StandardCharsets.UTF_8)); - r2.addAlias("theController", ControllerConfigGroup.GROUP_NAME); - r2.addAlias("theLastIteration", "lastIteration"); + r2.getConfigAliases().addAlias("theController", ControllerConfigGroup.GROUP_NAME); + r2.getConfigAliases().addAlias("theLastIteration", "lastIteration"); r2.readStream(bais); Assert.assertEquals(23, config.controler().getLastIteration()); @@ -103,11 +103,11 @@ public void testConditionalParamNameAliasWithModuleRenaming() { """; ByteArrayInputStream bais = new ByteArrayInputStream(xml.getBytes(StandardCharsets.UTF_8)); - r2.addAlias("the_network", "network"); - r2.addAlias("the_plans", "plans"); + r2.getConfigAliases().addAlias("the_network", "network"); + r2.getConfigAliases().addAlias("the_plans", "plans"); // for the path, the new name needs to be used: - r2.addAlias("input", "inputNetworkFile", "network"); - r2.addAlias("input", "inputPlansFile", "plans"); + r2.getConfigAliases().addAlias("input", "inputNetworkFile", "network"); + r2.getConfigAliases().addAlias("input", "inputPlansFile", "plans"); r2.readStream(bais); Assert.assertEquals("my_network.xml.gz", config.network().getInputFile()); @@ -137,8 +137,8 @@ public void testConditionalParamNameAlias() { """; ByteArrayInputStream bais = new ByteArrayInputStream(xml.getBytes(StandardCharsets.UTF_8)); - r2.addAlias("input", "inputNetworkFile", "network"); - r2.addAlias("input", "inputPlansFile", "plans"); + r2.getConfigAliases().addAlias("input", "inputNetworkFile", "network"); + r2.getConfigAliases().addAlias("input", "inputPlansFile", "plans"); r2.readStream(bais); Assert.assertEquals("my_network.xml.gz", config.network().getInputFile()); @@ -167,7 +167,7 @@ public void testConditionalParamNameAlias2() { """; ByteArrayInputStream bais = new ByteArrayInputStream(xml.getBytes(StandardCharsets.UTF_8)); - r2.addAlias("inputNetworkFile", "inputPlansFile", "plans"); + r2.getConfigAliases().addAlias("inputNetworkFile", "inputPlansFile", "plans"); r2.readStream(bais); Assert.assertEquals("my_network.xml.gz", config.network().getInputFile()); @@ -193,7 +193,7 @@ public void testConditionalParamNameAlias3() { """; ByteArrayInputStream bais = new ByteArrayInputStream(xml.getBytes(StandardCharsets.UTF_8)); - r2.addAlias("inputPlansFile", "input", "inexistant"); + r2.getConfigAliases().addAlias("inputPlansFile", "input", "inexistant"); r2.readStream(bais); // if the alias were matched, it should produce an exception, as "input" is not known Assert.assertEquals("my_plans.xml.gz", config.plans().getInputFile()); @@ -218,7 +218,7 @@ public void testConditionalParamNameAlias4() { """; ByteArrayInputStream bais = new ByteArrayInputStream(xml.getBytes(StandardCharsets.UTF_8)); - r2.addAlias("inputPlansFile", "input", "plans", "inexistant"); + r2.getConfigAliases().addAlias("inputPlansFile", "input", "plans", "inexistant"); r2.readStream(bais); // if the alias were matched, it should produce an exception, as "input" is not known Assert.assertEquals("my_plans.xml.gz", config.plans().getInputFile()); @@ -237,9 +237,9 @@ public void testAliasWithParamSets() { - + - + @@ -261,9 +261,10 @@ public void testAliasWithParamSets() { """; ByteArrayInputStream bais = new ByteArrayInputStream(xml.getBytes(StandardCharsets.UTF_8)); - r2.addAlias("scoring", "planCalcScore"); - r2.addAlias("theLateArrival", "lateArrival", "planCalcScore", "scoringParameters"); - r2.addAlias("theMode", "mode", "planCalcScore", "scoringParameters", "modeParams"); + r2.getConfigAliases().clearAliases(); + r2.getConfigAliases().addAlias("planCalcScore", "scoring"); + r2.getConfigAliases().addAlias("theLateArrival", "lateArrival", "scoring", "scoringParameters"); + r2.getConfigAliases().addAlias("theMode", "mode", "scoring", "scoringParameters", "modeParams"); r2.readStream(bais); Assert.assertEquals(-5.6, config.planCalcScore().getModes().get("car").getMarginalUtilityOfTraveling(), 1e-7); From e4dca0030a5344567c1f739cf4ac2f38edff3be1 Mon Sep 17 00:00:00 2001 From: Marcel Rieser Date: Thu, 12 Oct 2023 10:46:24 +0200 Subject: [PATCH 16/25] delete contrib eventsBasedPTRouter Closes #2838 --- .github/workflows/verify-push.yaml | 1 - contribs/eventsBasedPTRouter/pom.xml | 11 - .../MultiDestinationDijkstra.java | 547 ------------------ .../MultiNodeDijkstra.java | 72 --- .../SerializableLinkTravelTimes.java | 49 -- .../TransitRouterEventsWLFactory.java | 61 -- .../TransitRouterEventsWSFactory.java | 71 --- .../TransitRouterEventsWSVFactory.java | 63 -- ...outerNetworkTravelTimeAndDisutilityWS.java | 144 ----- ...uterNetworkTravelTimeAndDisutilityWSV.java | 146 ----- ...outerNetworkTravelTimeAndDisutilityWW.java | 144 ----- .../TransitRouterNetworkWW.java | 479 --------------- .../TransitRouterVariableImpl.java | 243 -------- .../controler/RunControlerWS.java | 66 --- .../controler/RunControlerWSV.java | 77 --- .../controler/RunControlerWW.java | 56 -- .../stopStopTimes/StopStopTime.java | 14 - .../stopStopTimes/StopStopTimeCalculator.java | 20 - .../StopStopTimeCalculatorImpl.java | 153 ----- .../StopStopTimeCalculatorSerializable.java | 192 ------ .../StopStopTimeCalculatorTuple.java | 134 ----- .../stopStopTimes/StopStopTimeData.java | 13 - .../stopStopTimes/StopStopTimeDataArray.java | 49 -- .../StopStopTimePreCalcSerializable.java | 273 --------- .../vehicleOccupancy/VehicleOccupancy.java | 13 - .../VehicleOccupancyCalculator.java | 106 ---- .../VehicleOccupancyData.java | 9 - .../VehicleOccupancyDataArray.java | 42 -- .../waitTimes/WaitTime.java | 41 -- .../waitTimes/WaitTimeCalculator.java | 17 - .../waitTimes/WaitTimeCalculatorImpl.java | 181 ------ .../WaitTimeCalculatorSerializable.java | 216 ------- .../waitTimes/WaitTimeData.java | 39 -- .../waitTimes/WaitTimeDataArray.java | 67 --- .../waitTimes/WaitTimeStuckCalculator.java | 222 ------- .../MultiNodeDijkstraTest.java | 495 ---------------- contribs/pom.xml | 1 - 37 files changed, 4527 deletions(-) delete mode 100644 contribs/eventsBasedPTRouter/pom.xml delete mode 100644 contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/MultiDestinationDijkstra.java delete mode 100644 contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/MultiNodeDijkstra.java delete mode 100644 contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/SerializableLinkTravelTimes.java delete mode 100644 contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/TransitRouterEventsWLFactory.java delete mode 100644 contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/TransitRouterEventsWSFactory.java delete mode 100644 contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/TransitRouterEventsWSVFactory.java delete mode 100644 contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/TransitRouterNetworkTravelTimeAndDisutilityWS.java delete mode 100644 contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/TransitRouterNetworkTravelTimeAndDisutilityWSV.java delete mode 100644 contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/TransitRouterNetworkTravelTimeAndDisutilityWW.java delete mode 100644 contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/TransitRouterNetworkWW.java delete mode 100644 contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/TransitRouterVariableImpl.java delete mode 100644 contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/controler/RunControlerWS.java delete mode 100644 contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/controler/RunControlerWSV.java delete mode 100644 contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/controler/RunControlerWW.java delete mode 100644 contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/stopStopTimes/StopStopTime.java delete mode 100644 contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/stopStopTimes/StopStopTimeCalculator.java delete mode 100644 contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/stopStopTimes/StopStopTimeCalculatorImpl.java delete mode 100644 contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/stopStopTimes/StopStopTimeCalculatorSerializable.java delete mode 100644 contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/stopStopTimes/StopStopTimeCalculatorTuple.java delete mode 100644 contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/stopStopTimes/StopStopTimeData.java delete mode 100644 contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/stopStopTimes/StopStopTimeDataArray.java delete mode 100644 contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/stopStopTimes/StopStopTimePreCalcSerializable.java delete mode 100644 contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/vehicleOccupancy/VehicleOccupancy.java delete mode 100644 contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/vehicleOccupancy/VehicleOccupancyCalculator.java delete mode 100644 contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/vehicleOccupancy/VehicleOccupancyData.java delete mode 100644 contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/vehicleOccupancy/VehicleOccupancyDataArray.java delete mode 100644 contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/waitTimes/WaitTime.java delete mode 100644 contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/waitTimes/WaitTimeCalculator.java delete mode 100644 contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/waitTimes/WaitTimeCalculatorImpl.java delete mode 100644 contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/waitTimes/WaitTimeCalculatorSerializable.java delete mode 100644 contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/waitTimes/WaitTimeData.java delete mode 100644 contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/waitTimes/WaitTimeDataArray.java delete mode 100644 contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/waitTimes/WaitTimeStuckCalculator.java delete mode 100644 contribs/eventsBasedPTRouter/src/test/java/org/matsim/contrib/eventsBasedPTRouter/MultiNodeDijkstraTest.java diff --git a/.github/workflows/verify-push.yaml b/.github/workflows/verify-push.yaml index 6c98df57073..f2a5b59d8ee 100644 --- a/.github/workflows/verify-push.yaml +++ b/.github/workflows/verify-push.yaml @@ -58,7 +58,6 @@ jobs: - contribs/railsim - contribs/roadpricing - contribs/analysis - - contribs/eventsBasedPTRouter - contribs/hybridsim - contribs/informed-mode-choice - contribs/otfvis diff --git a/contribs/eventsBasedPTRouter/pom.xml b/contribs/eventsBasedPTRouter/pom.xml deleted file mode 100644 index 6544fa91056..00000000000 --- a/contribs/eventsBasedPTRouter/pom.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - org.matsim - contrib - 16.0-SNAPSHOT - - 4.0.0 - org.matsim.contrib - events-based-pt-router - eventsBasedPTRouter - diff --git a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/MultiDestinationDijkstra.java b/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/MultiDestinationDijkstra.java deleted file mode 100644 index 686ce4cebab..00000000000 --- a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/MultiDestinationDijkstra.java +++ /dev/null @@ -1,547 +0,0 @@ -/* *********************************************************************** * - * project: org.matsim.* - * Dijkstra.java - * * - * *********************************************************************** * - * * - * copyright : (C) 2007 by the members listed in the COPYING, * - * LICENSE and WARRANTY file. * - * email : info at matsim dot org * - * * - * *********************************************************************** * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * See also COPYING, LICENSE and WARRANTY file * - * * - * *********************************************************************** */ - -package org.matsim.contrib.eventsBasedPTRouter; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -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.network.Link; -import org.matsim.api.core.v01.network.Network; -import org.matsim.api.core.v01.network.Node; -import org.matsim.api.core.v01.population.Person; -import org.matsim.core.router.util.DijkstraNodeData; -import org.matsim.core.router.util.LeastCostPathCalculator.Path; -import org.matsim.core.router.util.PreProcessDijkstra; -import org.matsim.core.router.util.TravelTime; -import org.matsim.core.utils.collections.PseudoRemovePriorityQueue; -import org.matsim.core.utils.misc.Time; -import org.matsim.pt.router.TransitTravelDisutility; - - -/** - * Implementation of Dijkstra's - * shortest-path algorithm on a time-dependent network with arbitrary - * non-negative cost functions (e.g. negative link cost are not allowed). So - * 'shortest' in our context actually means 'least-cost'. - * - *

    - * For every router, there exists a class which computes some preprocessing data - * and is passed to the router class constructor in order to accelerate the - * routing procedure. The one used for Dijkstra is - * {@link org.matsim.core.router.util.PreProcessDijkstra}. - *

    - *
    - * - *

    Code example:

    - *

    - * PreProcessDijkstra preProcessData = new PreProcessDijkstra();
    - * preProcessData.run(network);
    - * TravelCost costFunction = ...
    - * LeastCostPathCalculator routingAlgo = new Dijkstra(network, costFunction, preProcessData);
    - * routingAlgo.calcLeastCostPath(fromNode, toNode, startTime);
    - *

    - *

    - * If you don't want to preprocess the network, you can invoke Dijkstra as - * follows: - *

    - *

    - * LeastCostPathCalculator routingAlgo = new Dijkstra(network, costFunction); - *

    - * - *

    Important note

    - * This class is NOT threadsafe! - * - * @see org.matsim.core.router.util.PreProcessDijkstra - * @see org.matsim.core.router.AStarEuclidean - * @see org.matsim.core.router.AStarLandmarks - * @author lnicolas - * @author mrieser - */ -public class MultiDestinationDijkstra { - - private final static Logger log = LogManager.getLogger(MultiDestinationDijkstra.class); - - /** - * The network on which we find routes. - */ - protected Network network; - - /** - * The cost calculator. Provides the cost for each link and time step. - */ - final TransitTravelDisutility costFunction; - - /** - * The travel time calculator. Provides the travel time for each link and time step. - */ - final TravelTime timeFunction; - - final Map, DijkstraNodeData> nodeData; - - /** - * Provides an unique id (loop number) for each routing request, so we don't - * have to reset all nodes at the beginning of each re-routing but can use the - * loop number instead. - */ - private int iterationID = Integer.MIN_VALUE + 1; - - /** - * Temporary field that is only used if dead ends are being pruned during - * routing and is updated each time a new route has to be calculated. - */ - private Set deadEndEntryNodes = new HashSet(); - - /** - * Determines whether we should mark nodes in dead ends during a - * pre-processing step so they won't be expanded during routing. - */ - /*package*/ final boolean pruneDeadEnds; - - /** - * Comparator that defines how to order the nodes in the pending nodes queue - * during routing. - */ - - private final PreProcessDijkstra preProcessData; - - - private String[] modeRestriction = null; - - private Person person = null; - - /** - * Default constructor. - * - * @param network - * The network on which to route. - * @param costFunction - * Determines the link cost defining the cheapest route. - * @param timeFunction - * Determines the travel time on links. - */ - public MultiDestinationDijkstra(final Network network, final TransitTravelDisutility costFunction, final TravelTime timeFunction) { - this(network, costFunction, timeFunction, null); - } - - /** - * Constructor. - * - * @param network - * The network on which to route. - * @param costFunction - * Determines the link cost defining the cheapest route. - * @param timeFunction - * Determines the travel time on each link. - * @param preProcessData - * The pre processing data used during the routing phase. - */ - public MultiDestinationDijkstra(final Network network, final TransitTravelDisutility costFunction, final TravelTime timeFunction, - final PreProcessDijkstra preProcessData) { - - this.network = network; - this.costFunction = costFunction; - this.timeFunction = timeFunction; - this.preProcessData = preProcessData; - - this.nodeData = new HashMap, DijkstraNodeData>((int)(network.getNodes().size() * 1.1), 0.95f); - - if (preProcessData != null) { - if (preProcessData.containsData() == false) { - this.pruneDeadEnds = false; - log.warn("The preprocessing data provided to router class Dijkstra contains no data! Please execute its run(...) method first!"); - log.warn("Running without dead-end pruning."); - } else { - this.pruneDeadEnds = true; - } - } else { - this.pruneDeadEnds = false; - } - } - - public void setModeRestriction(final Set modeRestriction) { - if (modeRestriction == null) { - this.modeRestriction = null; - } else { - this.modeRestriction = modeRestriction.toArray(new String[modeRestriction.size()]); - } - } - - /** - * Calculates the cheapest route from Node 'fromNode' to Node 'toNode' at - * starting time 'startTime'. - * - * @param fromNode - * The Node at which the route should start. - * @param toNode - * The Node at which the route should end. - * @param startTime - * The time at which the route should start. Note: Using - * {@link Time#UNDEFINED_TIME} does not imply "time is not relevant", - * rather, {@link Path#travelTime} will return {@link Double#NaN}. - * @see org.matsim.core.router.util.LeastCostPathCalculator#calcLeastCostPath(org.matsim.core.network.Node, - * org.matsim.core.network.Node, double) - */ - public Map, Path> calcLeastCostPath(final Node fromNode, final Set toNodes, final double startTime, final Person person) { - - Map, Double> arrivalTimes = new HashMap, Double>(); - boolean stillSearching = true; - int finishedNodes = 0; - augmentIterationId(); // this call makes the class not threadsafe - this.person = person; - - if (this.pruneDeadEnds == true) { - for(Node toNode:toNodes) - deadEndEntryNodes.add(getPreProcessData(toNode).getDeadEndEntryNode()); - } - - PseudoRemovePriorityQueue pendingNodes = new PseudoRemovePriorityQueue(500); - initFromNode(fromNode, startTime, pendingNodes); - - while (stillSearching) { - Node outNode = pendingNodes.poll(); - - if (outNode == null) { - log.warn("No route was found from node " + fromNode.getId() + " to all nodes: " + finishedNodes + " of " + toNodes.size()); - stillSearching = false; - } - else { - if (toNodes.contains(outNode)) { - DijkstraNodeData outData = getData(outNode); - arrivalTimes.put(outNode.getId(), outData.getTime()); - finishedNodes++; - } - relaxNode(outNode, pendingNodes); - if(finishedNodes==toNodes.size()) - stillSearching = false; - } - } - - // now construct and return the path - return constructPaths(fromNode, toNodes, startTime, arrivalTimes); - - } - - /** - * Constructs the path after the algorithm has been run. - * - * @param fromNode - * The node where the path starts. - * @param toNode - * The node where the path ends. - * @param startTime - * The time when the trip starts. - * @param preProcessData - * The time when the trip ends. - */ - protected Map, Path> constructPaths(Node fromNode, Set toNodes, double startTime, Map, Double> arrivalTimes) { - Map, Path> paths = new HashMap, Path>(); - for(Node toNode:toNodes) { - Double arrivalTime = arrivalTimes.get(toNode.getId()); - Path path = null; - if(arrivalTime != null) { - ArrayList nodes = new ArrayList(); - ArrayList links = new ArrayList(); - - nodes.add(0, toNode); - Link tmpLink = getData(toNode).getPrevLink(); - if (tmpLink != null) { - while (tmpLink.getFromNode() != fromNode) { - links.add(0, tmpLink); - nodes.add(0, tmpLink.getFromNode()); - tmpLink = getData(tmpLink.getFromNode()).getPrevLink(); - } - links.add(0, tmpLink); - nodes.add(0, tmpLink.getFromNode()); - } - - DijkstraNodeData toNodeData = getData(toNode); - path = new Path(nodes, links, arrivalTime - startTime, toNodeData.getCost()); - } - paths.put(toNode.getId(), path); - } - return paths; - } - - /** - * Initializes the first node of a route. - * - * @param fromNode - * The Node to be initialized. - * @param toNode - * The Node at which the route should end. - * @param startTime - * The time we start routing. - * @param pendingNodes - * The pending nodes so far. - */ - /*package*/ void initFromNode(final Node fromNode, final double startTime, - final PseudoRemovePriorityQueue pendingNodes) { - DijkstraNodeData data = getData(fromNode); - visitNode(fromNode, data, pendingNodes, startTime, 0, null); - } - - /** - * Expands the given Node in the routing algorithm; may be overridden in - * sub-classes. - * - * @param outNode - * The Node to be expanded. - * @param toNode - * The target Node of the route. - * @param pendingNodes - * The set of pending nodes so far. - */ - protected void relaxNode(final Node outNode, final PseudoRemovePriorityQueue pendingNodes) { - - DijkstraNodeData outData = getData(outNode); - double currTime = outData.getTime(); - double currCost = outData.getCost(); - if (this.pruneDeadEnds) { - PreProcessDijkstra.DeadEndData ddOutData = getPreProcessData(outNode); - - for (Link l : outNode.getOutLinks().values()) { - relaxNodeLogic(l, pendingNodes, currTime, currCost, ddOutData); - } - } else { // this.pruneDeadEnds == false - for (Link l : outNode.getOutLinks().values()) { - relaxNodeLogic(l, pendingNodes, currTime, currCost, null); - } - } - } - - /** - * Logic that was previously located in the relaxNode(...) method. - * By doing so, the FastDijkstra can overwrite relaxNode without copying the logic. - */ - /*package*/ void relaxNodeLogic(final Link l, final PseudoRemovePriorityQueue pendingNodes, - final double currTime, final double currCost, - final PreProcessDijkstra.DeadEndData ddOutData) { - if (this.pruneDeadEnds) { - if (canPassLink(l)) { - Node n = l.getToNode(); - PreProcessDijkstra.DeadEndData ddData = getPreProcessData(n); - /* IF the current node n is not in a dead end - * OR it is in the same dead end as the fromNode - * OR it is in the same dead end as the toNode - * THEN we add the current node to the pending nodes */ - if(ddData.getDeadEndEntryNode()==null || ddOutData.getDeadEndEntryNode()!=null) - addToPendingNodes(l, n, pendingNodes, currTime, currCost); - else { - TO_NODES: - for(Node deadEndEntryNode:deadEndEntryNodes) - if(deadEndEntryNode != null && deadEndEntryNode.getId() == ddData.getDeadEndEntryNode().getId()) { - addToPendingNodes(l, n, pendingNodes, currTime, currCost); - break TO_NODES; - } - } - } - } else { - if (canPassLink(l)) { - addToPendingNodes(l, l.getToNode(), pendingNodes, currTime, currCost); - } - } - } - - /** - * Adds some parameters to the given Node then adds it to the set of pending - * nodes. - * - * @param l - * The link from which we came to this Node. - * @param n - * The Node to add to the pending nodes. - * @param pendingNodes - * The set of pending nodes. - * @param currTime - * The time at which we started to traverse l. - * @param currCost - * The cost at the time we started to traverse l. - * @param toNode - * The target Node of the route. - * @return true if the node was added to the pending nodes, false otherwise - * (e.g. when the same node already has an earlier visiting time). - */ - protected boolean addToPendingNodes(final Link l, final Node n, - final PseudoRemovePriorityQueue pendingNodes, final double currTime, - final double currCost) { - - double travelTime = this.timeFunction.getLinkTravelTime(l, currTime, person, null); - double travelCost = this.costFunction.getLinkTravelDisutility(l, currTime, this.person, null, null); - DijkstraNodeData data = getData(n); - double nCost = data.getCost(); - if (!data.isVisited(getIterationId())) { - visitNode(n, data, pendingNodes, currTime + travelTime, currCost - + travelCost, l); - return true; - } - double totalCost = currCost + travelCost; - if (totalCost < nCost) { - revisitNode(n, data, pendingNodes, currTime + travelTime, totalCost, l); - return true; - } - - return false; - } - - /** - * @param link - * @return true if the link can be passed with respect to a possible mode restriction set - * - * @see #setModeRestriction(Set) - */ - protected boolean canPassLink(final Link link) { - if (this.modeRestriction == null) { - return true; - } - for (String mode : this.modeRestriction) { - if (link.getAllowedModes().contains(mode)) { - return true; - } - } - return false; - } - - /** - * Changes the position of the given Node n in the pendingNodes queue and - * updates its time and cost information. - * - * @param n - * The Node that is revisited. - * @param data - * The data for n. - * @param pendingNodes - * The nodes visited and not processed yet. - * @param time - * The time of the visit of n. - * @param cost - * The accumulated cost at the time of the visit of n. - * @param outLink - * The link from which we came visiting n. - */ - void revisitNode(final Node n, final DijkstraNodeData data, - final PseudoRemovePriorityQueue pendingNodes, final double time, final double cost, - final Link outLink) { - pendingNodes.remove(n); - - data.visit(outLink, cost, time, getIterationId()); - pendingNodes.add(n, getPriority(data)); - } - - /** - * Inserts the given Node n into the pendingNodes queue and updates its time - * and cost information. - * - * @param n - * The Node that is revisited. - * @param data - * The data for n. - * @param pendingNodes - * The nodes visited and not processed yet. - * @param time - * The time of the visit of n. - * @param cost - * The accumulated cost at the time of the visit of n. - * @param outLink - * The node from which we came visiting n. - */ - protected void visitNode(final Node n, final DijkstraNodeData data, - final PseudoRemovePriorityQueue pendingNodes, final double time, final double cost, - final Link outLink) { - data.visit(outLink, cost, time, getIterationId()); - pendingNodes.add(n, getPriority(data)); - } - - /** - * Augments the iterationID and checks whether the visited information in - * the nodes in the nodes have to be reset. - */ - protected void augmentIterationId() { - if (getIterationId() == Integer.MAX_VALUE) { - this.iterationID = Integer.MIN_VALUE + 1; - resetNetworkVisited(); - } else { - this.iterationID++; - } - } - - /** - * @return iterationID - */ - /*package*/ int getIterationId() { - return this.iterationID; - } - - /** - * Resets all nodes in the network as if they have not been visited yet. - */ - private void resetNetworkVisited() { - for (Node node : this.network.getNodes().values()) { - DijkstraNodeData data = getData(node); - data.resetVisited(); - } - } - - /** - * The value used to sort the pending nodes during routing. - * This implementation compares the total effective travel cost - * to sort the nodes in the pending nodes queue during routing. - */ - protected double getPriority(final DijkstraNodeData data) { - return data.getCost(); - } - - /** - * Returns the data for the given node. Creates a new NodeData if none exists - * yet. - * - * @param n - * The Node for which to return the data. - * @return The data for the given Node - */ - protected DijkstraNodeData getData(final Node n) { - DijkstraNodeData r = this.nodeData.get(n.getId()); - if (null == r) { - r = new DijkstraNodeData(); - this.nodeData.put(n.getId(), r); - } - return r; - } - - protected PreProcessDijkstra.DeadEndData getPreProcessData(final Node n) { - return this.preProcessData.getNodeData(n); - } - - protected final Person getPerson() { - return this.person; - } - - protected final void setPerson(final Person person) { - this.person = person; - } - -} diff --git a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/MultiNodeDijkstra.java b/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/MultiNodeDijkstra.java deleted file mode 100644 index 457d0e68bc3..00000000000 --- a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/MultiNodeDijkstra.java +++ /dev/null @@ -1,72 +0,0 @@ -/* *********************************************************************** * - * project: org.matsim.* - * TransitDijkstra.java - * * - * *********************************************************************** * - * * - * copyright : (C) 2009 by the members listed in the COPYING, * - * LICENSE and WARRANTY file. * - * email : info at matsim dot org * - * * - * *********************************************************************** * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * See also COPYING, LICENSE and WARRANTY file * - * * - * *********************************************************************** */ - -package org.matsim.contrib.eventsBasedPTRouter; - -import java.util.HashMap; -import java.util.Map; -import org.matsim.api.core.v01.network.Network; -import org.matsim.api.core.v01.network.Node; -import org.matsim.api.core.v01.population.Person; -import org.matsim.core.router.InitialNode; -import org.matsim.core.router.util.LeastCostPathCalculator.Path; -import org.matsim.core.router.util.TravelTime; -import org.matsim.pt.router.TransitLeastCostPathTree; -import org.matsim.pt.router.TransitTravelDisutility; - -public class MultiNodeDijkstra /*extends Dijkstra*/ { - - /** - * The network on which we find routes. - */ - protected Network network; - - /** - * The cost calculator. Provides the cost for each link and time step. - */ - private final TransitTravelDisutility costFunction; - - /** - * The travel time calculator. Provides the travel time for each link and time step. - */ - private final TravelTime timeFunction; - - public MultiNodeDijkstra(final Network network, final TransitTravelDisutility costFunction, final TravelTime timeFunction) { - this.network = network; - this.costFunction = costFunction; - this.timeFunction = timeFunction; - } - - @SuppressWarnings("unchecked") - public Path calcLeastCostPath(final Map fromNodes, final Map toNodes, final Person person) { - Map swapedToNodes = swapNodes(toNodes); - TransitLeastCostPathTree tree = new TransitLeastCostPathTree(network, costFunction, timeFunction, swapNodes(fromNodes), swapedToNodes, person); - return tree.getPath(swapedToNodes); - } - - private Map swapNodes(final Map original) { - Map result = new HashMap<>(); - for (Map.Entry entry : original.entrySet()) { - result.put(entry.getKey(), new InitialNode(entry.getValue().initialCost, entry.getValue().initialTime)); - } - return result; - } - -} diff --git a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/SerializableLinkTravelTimes.java b/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/SerializableLinkTravelTimes.java deleted file mode 100644 index 2ca3400149b..00000000000 --- a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/SerializableLinkTravelTimes.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.matsim.contrib.eventsBasedPTRouter; - -import java.io.Serializable; -import java.util.Collection; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; - -import org.matsim.api.core.v01.network.Link; -import org.matsim.api.core.v01.population.Person; -import org.matsim.core.router.util.TravelTime; -import org.matsim.vehicles.Vehicle; - -public class SerializableLinkTravelTimes implements Serializable, TravelTime { - - private final double[][] times; - private final Map indices = new HashMap<>(); - private final int travelTimeBinSize; - - public SerializableLinkTravelTimes(TravelTime linkTravelTimes, - int traveltimeBinSize, double endTime, - Collection links) { - this.travelTimeBinSize = traveltimeBinSize; - endTime = endTime <= 0 ? 86400 : endTime; - times = new double[links.size()][(int) (endTime / traveltimeBinSize)]; - Iterator iterator = links.iterator(); - for (int i = 0; i < times.length; i++) { - Link link = iterator.next(); - indices.put(link.getId().toString(), i); - for (int j = 0; j < times[i].length; j++) - times[i][j] = linkTravelTimes.getLinkTravelTime(link, - traveltimeBinSize * j, null, null); - } - } - - @Override - public double getLinkTravelTime(Link link, double time, Person person, - Vehicle vehicle) { - time = time % 86400; - try { - return times[indices.get(link.getId().toString())][(int) (time / travelTimeBinSize)]; - } catch (ArrayIndexOutOfBoundsException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - return time; - } - -} diff --git a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/TransitRouterEventsWLFactory.java b/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/TransitRouterEventsWLFactory.java deleted file mode 100644 index f163879e763..00000000000 --- a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/TransitRouterEventsWLFactory.java +++ /dev/null @@ -1,61 +0,0 @@ -/* *********************************************************************** * - * project: org.matsim.* - * * - * *********************************************************************** * - * * - * copyright : (C) 2012 by the members listed in the COPYING, * - * LICENSE and WARRANTY file. * - * email : info at matsim dot org * - * * - * *********************************************************************** * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * See also COPYING, LICENSE and WARRANTY file * - * * - * *********************************************************************** */ - -package org.matsim.contrib.eventsBasedPTRouter; - -import org.matsim.api.core.v01.network.Network; -import org.matsim.contrib.eventsBasedPTRouter.waitTimes.WaitTime; -import org.matsim.core.controler.MatsimServices; -import org.matsim.pt.router.PreparedTransitSchedule; -import org.matsim.pt.router.TransitRouter; -import org.matsim.pt.router.TransitRouterConfig; - -import jakarta.inject.Provider; -import jakarta.inject.Singleton; - - -/** - * Factory for the variable transit router - * - * @author sergioo - */ -@Singleton -public class TransitRouterEventsWLFactory implements Provider { - - private final TransitRouterConfig config; - private final TransitRouterNetworkWW routerNetwork; - private final Network network; - private MatsimServices controler; - private final WaitTime waitTime; - - public TransitRouterEventsWLFactory(final MatsimServices controler, final WaitTime waitTime) { - this.config = new TransitRouterConfig(controler.getScenario().getConfig().planCalcScore(), - controler.getScenario().getConfig().plansCalcRoute(), controler.getScenario().getConfig().transitRouter(), - controler.getScenario().getConfig().vspExperimental()); - this.network = controler.getScenario().getNetwork(); - this.controler = controler; - this.waitTime = waitTime; - routerNetwork = TransitRouterNetworkWW.createFromSchedule(network, controler.getScenario().getTransitSchedule(), this.config.getBeelineWalkConnectionDistance()); - } - @Override - public TransitRouter get() { - return new TransitRouterVariableImpl(config, new TransitRouterNetworkTravelTimeAndDisutilityWW(config, network, routerNetwork, controler.getLinkTravelTimes(), waitTime, controler.getConfig().travelTimeCalculator(), controler.getConfig().qsim(), new PreparedTransitSchedule(controler.getScenario().getTransitSchedule())), routerNetwork); - } - -} diff --git a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/TransitRouterEventsWSFactory.java b/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/TransitRouterEventsWSFactory.java deleted file mode 100644 index 51a71883525..00000000000 --- a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/TransitRouterEventsWSFactory.java +++ /dev/null @@ -1,71 +0,0 @@ -/* *********************************************************************** * - * project: org.matsim.* - * * - * *********************************************************************** * - * * - * copyright : (C) 2012 by the members listed in the COPYING, * - * LICENSE and WARRANTY file. * - * email : info at matsim dot org * - * * - * *********************************************************************** * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * See also COPYING, LICENSE and WARRANTY file * - * * - * *********************************************************************** */ - -package org.matsim.contrib.eventsBasedPTRouter; - -import com.google.inject.Inject; -import org.matsim.api.core.v01.Scenario; -import org.matsim.contrib.eventsBasedPTRouter.stopStopTimes.StopStopTime; -import org.matsim.contrib.eventsBasedPTRouter.waitTimes.WaitTime; -import org.matsim.pt.router.PreparedTransitSchedule; -import org.matsim.pt.router.TransitRouter; -import org.matsim.pt.router.TransitRouterConfig; - -import jakarta.inject.Provider; -import jakarta.inject.Singleton; - -/** - * Factory for the variable transit router - * - * @author sergioo - */ -@Singleton -public class TransitRouterEventsWSFactory implements Provider { - - private final TransitRouterConfig config; - private final TransitRouterNetworkWW routerNetwork; - private final Scenario scenario; - private WaitTime waitTime; - - public void setStopStopTime(StopStopTime stopStopTime) { - this.stopStopTime = stopStopTime; - } - - public void setWaitTime(WaitTime waitTime) { - this.waitTime = waitTime; - } - - private StopStopTime stopStopTime; - - @Inject - public TransitRouterEventsWSFactory(final Scenario scenario, final WaitTime waitTime, final StopStopTime stopStopTime) { - this.config = new TransitRouterConfig(scenario.getConfig().planCalcScore(), - scenario.getConfig().plansCalcRoute(), scenario.getConfig().transitRouter(), - scenario.getConfig().vspExperimental()); - routerNetwork = TransitRouterNetworkWW.createFromSchedule(scenario.getNetwork(), scenario.getTransitSchedule(), this.config.getBeelineWalkConnectionDistance()); - this.scenario = scenario; - this.waitTime = waitTime; - this.stopStopTime = stopStopTime; - } - @Override - public TransitRouter get() { - return new TransitRouterVariableImpl(config, new TransitRouterNetworkTravelTimeAndDisutilityWS(config, routerNetwork, waitTime, stopStopTime, scenario.getConfig().travelTimeCalculator(), scenario.getConfig().qsim(), new PreparedTransitSchedule(scenario.getTransitSchedule())), routerNetwork); - } - -} diff --git a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/TransitRouterEventsWSVFactory.java b/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/TransitRouterEventsWSVFactory.java deleted file mode 100644 index d3c398de718..00000000000 --- a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/TransitRouterEventsWSVFactory.java +++ /dev/null @@ -1,63 +0,0 @@ -/* *********************************************************************** * - * project: org.matsim.* - * * - * *********************************************************************** * - * * - * copyright : (C) 2012 by the members listed in the COPYING, * - * LICENSE and WARRANTY file. * - * email : info at matsim dot org * - * * - * *********************************************************************** * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * See also COPYING, LICENSE and WARRANTY file * - * * - * *********************************************************************** */ - -package org.matsim.contrib.eventsBasedPTRouter; - -import org.matsim.api.core.v01.Scenario; -import org.matsim.contrib.eventsBasedPTRouter.stopStopTimes.StopStopTime; -import org.matsim.contrib.eventsBasedPTRouter.vehicleOccupancy.VehicleOccupancy; -import org.matsim.contrib.eventsBasedPTRouter.waitTimes.WaitTime; -import org.matsim.pt.router.PreparedTransitSchedule; -import org.matsim.pt.router.TransitRouter; -import org.matsim.pt.router.TransitRouterConfig; - -import jakarta.inject.Provider; -import jakarta.inject.Singleton; - -/** - * Factory for the variable transit router - * - * @author sergioo - */ -@Singleton -public class TransitRouterEventsWSVFactory implements Provider { - - private final TransitRouterConfig config; - private final TransitRouterNetworkWW routerNetwork; - private final Scenario scenario; - private final WaitTime waitTime; - private final StopStopTime stopStopTime; - private final VehicleOccupancy vehicleOccupancy; - - public TransitRouterEventsWSVFactory(final Scenario scenario, final WaitTime waitTime, final StopStopTime stopStopTime, final VehicleOccupancy vehicleOccupancy) { - this.config = new TransitRouterConfig(scenario.getConfig().planCalcScore(), - scenario.getConfig().plansCalcRoute(), scenario.getConfig().transitRouter(), - scenario.getConfig().vspExperimental()); - routerNetwork = TransitRouterNetworkWW.createFromSchedule(scenario.getNetwork(), scenario.getTransitSchedule(), this.config.getBeelineWalkConnectionDistance()); - this.scenario = scenario; - this.waitTime = waitTime; - this.stopStopTime = stopStopTime; - this.vehicleOccupancy = vehicleOccupancy; - } - @Override - public TransitRouter get() { - return new TransitRouterVariableImpl(config, new TransitRouterNetworkTravelTimeAndDisutilityWSV(config, routerNetwork, waitTime, stopStopTime, vehicleOccupancy, scenario.getConfig().travelTimeCalculator(), scenario.getConfig().qsim(), new PreparedTransitSchedule(scenario.getTransitSchedule())), routerNetwork); - } - -} diff --git a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/TransitRouterNetworkTravelTimeAndDisutilityWS.java b/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/TransitRouterNetworkTravelTimeAndDisutilityWS.java deleted file mode 100644 index 2c2b68c17a7..00000000000 --- a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/TransitRouterNetworkTravelTimeAndDisutilityWS.java +++ /dev/null @@ -1,144 +0,0 @@ -/* *********************************************************************** * - * project: org.matsim.* - * TransitRouterNetworkTravelTimeAndDisutilityVariableWW.java - * * - * *********************************************************************** * - * * - * copyright : (C) 2012 by the members listed in the COPYING, * - * LICENSE and WARRANTY file. * - * email : info at matsim dot org * - * * - * *********************************************************************** * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * See also COPYING, LICENSE and WARRANTY file * - * * - * *********************************************************************** */ - -package org.matsim.contrib.eventsBasedPTRouter; - -import java.util.HashMap; -import java.util.Map; - -import org.matsim.api.core.v01.Id; -import org.matsim.api.core.v01.network.Link; -import org.matsim.api.core.v01.population.Person; -import org.matsim.contrib.eventsBasedPTRouter.stopStopTimes.StopStopTime; -import org.matsim.contrib.eventsBasedPTRouter.waitTimes.WaitTime; -import org.matsim.core.config.groups.QSimConfigGroup; -import org.matsim.core.config.groups.TravelTimeCalculatorConfigGroup; -import org.matsim.core.router.util.TravelDisutility; -import org.matsim.pt.router.CustomDataManager; -import org.matsim.pt.router.PreparedTransitSchedule; -import org.matsim.pt.router.TransitRouterConfig; -import org.matsim.pt.router.TransitRouterNetworkTravelTimeAndDisutility; -import org.matsim.vehicles.Vehicle; - -import com.google.inject.Provider; - -/** - * TravelTime and TravelDisutility calculator to be used with the transit network used for transit routing. - * This version considers waiting time at stops, and takes travel time between stops from a {@link StopStopTime} object. - * - * @author sergioo - */ -public class TransitRouterNetworkTravelTimeAndDisutilityWS extends TransitRouterNetworkTravelTimeAndDisutility implements TravelDisutility { - - private Link previousLink; - private double previousTime; - private double cachedLinkTime; - private final Map, double[]> linkTravelTimes = new HashMap, double[]>(); - private final Map, double[]> linkWaitingTimes = new HashMap, double[]>(); - private final int numSlots; - private final double timeSlot; - - public TransitRouterNetworkTravelTimeAndDisutilityWS(final TransitRouterConfig config, TransitRouterNetworkWW routerNetwork, Provider waitTime, Provider stopStopTime, TravelTimeCalculatorConfigGroup tTConfigGroup, QSimConfigGroup qSimConfigGroup, PreparedTransitSchedule preparedTransitSchedule) { - this(config, routerNetwork, waitTime.get(), stopStopTime.get(), tTConfigGroup, qSimConfigGroup.getStartTime().seconds(), qSimConfigGroup.getEndTime().seconds(), preparedTransitSchedule); - } - - public TransitRouterNetworkTravelTimeAndDisutilityWS(final TransitRouterConfig config, TransitRouterNetworkWW routerNetwork, WaitTime waitTime, StopStopTime stopStopTime, TravelTimeCalculatorConfigGroup tTConfigGroup, QSimConfigGroup qSimConfigGroup, PreparedTransitSchedule preparedTransitSchedule) { - this(config, routerNetwork, waitTime, stopStopTime, tTConfigGroup, qSimConfigGroup.getStartTime().seconds(), qSimConfigGroup.getEndTime().seconds(), preparedTransitSchedule); - } - public TransitRouterNetworkTravelTimeAndDisutilityWS(final TransitRouterConfig config, TransitRouterNetworkWW routerNetwork, WaitTime waitTime, StopStopTime stopStopTime, TravelTimeCalculatorConfigGroup tTConfigGroup, double startTime, double endTime, PreparedTransitSchedule preparedTransitSchedule) { - super(config, preparedTransitSchedule); - timeSlot = tTConfigGroup.getTraveltimeBinSize(); - numSlots = (int) ((endTime-startTime)/timeSlot); - for(TransitRouterNetworkWW.TransitRouterNetworkLink link:routerNetwork.getLinks().values()) - if(link.route!=null) { - double[] times = new double[numSlots]; - for(int slot = 0; slot, double[]> linkTravelTimes = new HashMap, double[]>(); - private final Map, double[]> linkWaitingTimes = new HashMap, double[]>(); - private final Map, double[]> linkVehicleOccupancy = new HashMap, double[]>(); - private final int numSlots; - private final double timeSlot; - - public TransitRouterNetworkTravelTimeAndDisutilityWSV(final TransitRouterConfig config, TransitRouterNetworkWW routerNetwork, WaitTime waitTime, StopStopTime stopStopTime, VehicleOccupancy vehicleOccupancy, TravelTimeCalculatorConfigGroup tTConfigGroup, QSimConfigGroup qSimConfigGroup, PreparedTransitSchedule preparedTransitSchedule) { - this(config, routerNetwork, waitTime, stopStopTime, vehicleOccupancy, tTConfigGroup, qSimConfigGroup.getStartTime().seconds(), qSimConfigGroup.getEndTime().seconds(), preparedTransitSchedule); - } - public TransitRouterNetworkTravelTimeAndDisutilityWSV(final TransitRouterConfig config, TransitRouterNetworkWW routerNetwork, WaitTime waitTime, StopStopTime stopStopTime, VehicleOccupancy vehicleOccupancy, TravelTimeCalculatorConfigGroup tTConfigGroup, double startTime, double endTime, PreparedTransitSchedule preparedTransitSchedule) { - super(config, preparedTransitSchedule); - timeSlot = tTConfigGroup.getTraveltimeBinSize(); - numSlots = (int) ((endTime-startTime)/timeSlot); - for(TransitRouterNetworkWW.TransitRouterNetworkLink link:routerNetwork.getLinks().values()) - if(link.route!=null) { - double[] times = new double[numSlots]; - double[] occs = new double[numSlots]; - for(int slot = 0; slotSIT_PERCENTAGE?NO_SIT_FACTOR:1 - - link.getLength() * this.config.getMarginalUtilityOfTravelDistancePt_utl_m(); - else if (wrapped.toNode.route!=null) - // it's a wait link - return -(cachedTravelDisutility?cachedTravelTime:linkWaitingTimes.get(wrapped.getId())[time/timeSlotSIT_PERCENTAGE?NO_SIT_FACTOR:1 - - link.getLength() * this.config.getMarginalUtilityOfTravelDistancePt_utl_m(); - else if (wrapped.toNode.route!=null) - // it's a wait link - return - linkWaitingTimes.get(wrapped.getId())[time/timeSlot, double[]> linkTravelTimes = new HashMap, double[]>(); - private final Map, double[]> linkWaitingTimes = new HashMap, double[]>(); - private final double timeSlot; - private final int numSlots; - private Link previousLink; - private double previousTime; - private double cachedTravelTime; - - public TransitRouterNetworkTravelTimeAndDisutilityWW(final TransitRouterConfig config, Network network, TransitRouterNetworkWW routerNetwork, TravelTime travelTime, WaitTime waitTime, TravelTimeCalculatorConfigGroup tTConfigGroup, QSimConfigGroup qSimConfigGroup, PreparedTransitSchedule preparedTransitSchedule) { - this(config, network, routerNetwork, travelTime, waitTime, tTConfigGroup, qSimConfigGroup.getStartTime().seconds(), qSimConfigGroup.getEndTime().seconds(), preparedTransitSchedule); - } - public TransitRouterNetworkTravelTimeAndDisutilityWW(final TransitRouterConfig config, Network network, TransitRouterNetworkWW routerNetwork, TravelTime travelTime, WaitTime waitTime, TravelTimeCalculatorConfigGroup tTConfigGroup, double startTime, double endTime, PreparedTransitSchedule preparedTransitSchedule) { - super(config, preparedTransitSchedule); - timeSlot = tTConfigGroup.getTraveltimeBinSize(); - numSlots = (int) ((endTime-startTime)/timeSlot); - for(TransitRouterNetworkWW.TransitRouterNetworkLink link:routerNetwork.getLinks().values()) - if(link.route!=null) { - double[] times = new double[numSlots]; - for(int slot = 0; slot linkId:link.route.getRoute().getSubRoute(link.fromNode.stop.getStopFacility().getLinkId(), link.toNode.stop.getStopFacility().getLinkId()).getLinkIds()) - linksTime += travelTime.getLinkTravelTime(network.getLinks().get(linkId), startTime+slot*timeSlot, null, null); - times[slot] = linksTime; - } - linkTravelTimes.put(link.getId(), times); - } - else if(link.toNode.route!=null) { - double[] times = new double[numSlots]; - for(int slot = 0; slot, TransitRouterNetworkLink> links = new LinkedHashMap<>(); - private final Map, TransitRouterNetworkNode> nodes = new LinkedHashMap<>(); - protected QuadTree qtNodes = null; - - private long nextNodeId = 0; - protected long nextLinkId = 0; - - public static final class TransitRouterNetworkNode implements Node { - - public final TransitRouteStop stop; - public final TransitRoute route; - public final TransitLine line; - final Id id; - final Map, TransitRouterNetworkLink> ingoingLinks = new LinkedHashMap<>(); - final Map, TransitRouterNetworkLink> outgoingLinks = new LinkedHashMap<>(); - - public TransitRouterNetworkNode(final Id id, final TransitRouteStop stop, final TransitRoute route, final TransitLine line) { - this.id = id; - this.stop = stop; - this.route = route; - this.line = line; - } - - @Override - public Map, ? extends Link> getInLinks() { - return this.ingoingLinks; - } - - @Override - public Map, ? extends Link> getOutLinks() { - return this.outgoingLinks; - } - - @Override - public boolean addInLink(final Link link) { - throw new UnsupportedOperationException(); - } - - @Override - public boolean addOutLink(final Link link) { - throw new UnsupportedOperationException(); - } - - @Override - public Coord getCoord() { - return this.stop.getStopFacility().getCoord(); - } - - @Override - public Id getId() { - return this.id; - } - - public TransitRouteStop getStop() { - return stop; - } - - public TransitRoute getRoute() { - return route; - } - - public TransitLine getLine() { - return line; - } - - @Override - public Link removeInLink(Id linkId) { - throw new RuntimeException("not implemented") ; - } - - @Override - public Link removeOutLink(Id outLinkId) { - throw new RuntimeException("not implemented") ; - } - - @Override - public void setCoord(Coord coord) { - throw new RuntimeException("not implemented") ; - } - - @Override - public Attributes getAttributes() { - throw new UnsupportedOperationException(); - } - } - - /** - * Looks to me like an implementation of the Link interface, with get(Transit)Route and get(Transit)Line on top. - * To recall: TransitLine is something like M44. But it can have more than one route, e.g. going north, going south, - * long route, short route. That is, presumably we have one such TransitRouterNetworkLink per TransitRoute. kai/manuel, feb'12 - */ - public static final class TransitRouterNetworkLink implements Link { - - final TransitRouterNetworkNode fromNode; - final TransitRouterNetworkNode toNode; - final TransitRoute route; - final TransitLine line; - final Id id; - private double length; - - public TransitRouterNetworkLink(final Id id, final TransitRouterNetworkNode fromNode, final TransitRouterNetworkNode toNode, final TransitRoute route, final TransitLine line, Network network) { - this.id = id; - this.fromNode = fromNode; - this.toNode = toNode; - this.route = route; - this.line = line; - if(route==null) - this.length = CoordUtils.calcEuclideanDistance(this.toNode.stop.getStopFacility().getCoord(), this.fromNode.stop.getStopFacility().getCoord()); - else { - this.length = 0; - for(Id linkId:route.getRoute().getSubRoute(fromNode.stop.getStopFacility().getLinkId(), toNode.stop.getStopFacility().getLinkId()).getLinkIds()) - this.length += network.getLinks().get(linkId).getLength(); - this.length += network.getLinks().get(toNode.stop.getStopFacility().getLinkId()).getLength(); - } - } - - @Override - public TransitRouterNetworkNode getFromNode() { - return this.fromNode; - } - - @Override - public TransitRouterNetworkNode getToNode() { - return this.toNode; - } - - @Override - public double getCapacity() { - return 9999; - } - - @Override - public double getCapacity(final double time) { - return getCapacity(); - } - - @Override - public double getFreespeed() { - return 10; - } - - @Override - public double getFreespeed(final double time) { - return getFreespeed(); - } - - @Override - public Id getId() { - return this.id; - } - - @Override - public double getNumberOfLanes() { - return 1; - } - - @Override - public double getNumberOfLanes(final double time) { - return getNumberOfLanes(); - } - - @Override - public double getLength() { - return this.length; - } - - @Override - public void setCapacity(final double capacity) { - throw new UnsupportedOperationException(); - } - - @Override - public void setFreespeed(final double freespeed) { - throw new UnsupportedOperationException(); - } - - @Override - public boolean setFromNode(final Node node) { - throw new UnsupportedOperationException(); - } - - @Override - public void setNumberOfLanes(final double lanes) { - throw new UnsupportedOperationException(); - } - - @Override - public void setLength(final double length) { - this.length = length; - } - - @Override - public boolean setToNode(final Node node) { - throw new UnsupportedOperationException(); - } - - @Override - public Coord getCoord() { - throw new UnsupportedOperationException(); - } - - @Override - public Set getAllowedModes() { - return null; - } - - @Override - public void setAllowedModes(final Set modes) { - throw new UnsupportedOperationException(); - } - - public TransitRoute getRoute() { - return route; - } - - public TransitLine getLine() { - return line; - } - - @Override - public double getCapacityPeriod() { - throw new UnsupportedOperationException(); - } - - @Override - public Attributes getAttributes() { - throw new UnsupportedOperationException(); - } - } - public TransitRouterNetworkNode createNode(final TransitRouteStop stop, final TransitRoute route, final TransitLine line) { - Id id = null; - if(line==null && route==null) - id = Id.createNodeId(stop.getStopFacility().getId().toString()); - else - id = Id.createNodeId("number:"+nextNodeId++); - final TransitRouterNetworkNode node = new TransitRouterNetworkNode(id, stop, route, line); - if(this.nodes.get(node.getId())!=null) - throw new RuntimeException(); - this.nodes.put(node.getId(), node); - return node; - } - - public TransitRouterNetworkLink createLink(final Network network, final TransitRouterNetworkNode fromNode, final TransitRouterNetworkNode toNode) { - final TransitRouterNetworkLink link = new TransitRouterNetworkLink(Id.createLinkId(this.nextLinkId++), fromNode, toNode, null, null, network); - this.links.put(link.getId(), link); - fromNode.outgoingLinks.put(link.getId(), link); - toNode.ingoingLinks.put(link.getId(), link); - return link; - } - public TransitRouterNetworkLink createLink(final Network network, final TransitRouterNetworkNode fromNode, final TransitRouterNetworkNode toNode, final TransitRoute route, final TransitLine line) { - final TransitRouterNetworkLink link = new TransitRouterNetworkLink(Id.createLinkId(this.nextLinkId++), fromNode, toNode, route, line, network); - this.getLinks().put(link.getId(), link); - fromNode.outgoingLinks.put(link.getId(), link); - toNode.ingoingLinks.put(link.getId(), link); - return link; - } - @Override - public Map, TransitRouterNetworkNode> getNodes() { - return this.nodes; - } - @Override - public Map, TransitRouterNetworkLink> getLinks() { - return this.links; - } - public void finishInit() { - double minX = Double.POSITIVE_INFINITY; - double minY = Double.POSITIVE_INFINITY; - double maxX = Double.NEGATIVE_INFINITY; - double maxY = Double.NEGATIVE_INFINITY; - for (TransitRouterNetworkNode node : getNodes().values()) - if(node.line == null) { - Coord c = node.stop.getStopFacility().getCoord(); - if (c.getX() < minX) - minX = c.getX(); - if (c.getY() < minY) - minY = c.getY(); - if (c.getX() > maxX) - maxX = c.getX(); - if (c.getY() > maxY) - maxY = c.getY(); - } - QuadTree quadTree = new QuadTree(minX, minY, maxX, maxY); - for (TransitRouterNetworkNode node : getNodes().values()) { - if(node.line == null) { - Coord c = node.stop.getStopFacility().getCoord(); - quadTree.put(c.getX(), c.getY(), node); - } - } - this.qtNodes = quadTree; - } - public static TransitRouterNetworkWW createFromSchedule(final Network network, final TransitSchedule schedule, final double maxBeelineWalkConnectionDistance) { - log.info("start creating transit network"); - final TransitRouterNetworkWW transitNetwork = new TransitRouterNetworkWW(); - final Counter linkCounter = new Counter(" link #"); - final Counter nodeCounter = new Counter(" node #"); - int numTravelLinks = 0, numWaitingLinks = 0, numInsideLinks = 0, numTransferLinks = 0; - Map, TransitRouterNetworkNode> stops = new HashMap, TransitRouterNetworkNode>(); - TransitRouterNetworkNode nodeSR, nodeS; - // build stop nodes - for (TransitLine line : schedule.getTransitLines().values()) - for (TransitRoute route : line.getRoutes().values()) - for (TransitRouteStop stop : route.getStops()) { - nodeS = stops.get(stop.getStopFacility().getId()); - if(nodeS == null) { - nodeS = transitNetwork.createNode(stop, null, null); - nodeCounter.incCounter(); - stops.put(stop.getStopFacility().getId(), nodeS); - } - } - transitNetwork.finishInit(); - // build transfer links - log.info("add transfer links"); - // connect all stops with walking links if they're located less than beelineWalkConnectionDistance from each other - for (TransitRouterNetworkNode node : transitNetwork.getNodes().values()) - for (TransitRouterNetworkNode node2 : transitNetwork.getNearestNodes(node.stop.getStopFacility().getCoord(), maxBeelineWalkConnectionDistance)) - if (node!=node2) { - transitNetwork.createLink(network, node, node2); - linkCounter.incCounter(); - numTransferLinks++; - } - // build nodes and links connecting the nodes according to the transit routes - log.info("add travel, waiting and inside links"); - for (TransitLine line : schedule.getTransitLines().values()) - for (TransitRoute route : line.getRoutes().values()) { - TransitRouterNetworkNode prevNode = null; - for (TransitRouteStop stop : route.getStops()) { - nodeS = stops.get(stop.getStopFacility().getId()); - nodeSR = transitNetwork.createNode(stop, route, line); - nodeCounter.incCounter(); - if (prevNode != null) { - transitNetwork.createLink(network, prevNode, nodeSR, route, line); - linkCounter.incCounter(); - numTravelLinks++; - } - prevNode = nodeSR; - transitNetwork.createLink(network, nodeS, nodeSR); - linkCounter.incCounter(); - numWaitingLinks++; - transitNetwork.createLink(network, nodeSR, nodeS); - linkCounter.incCounter(); - numInsideLinks++; - } - } - log.info("transit router network statistics:"); - log.info(" # nodes: " + transitNetwork.getNodes().size()); - log.info(" # links total: " + transitNetwork.getLinks().size()); - log.info(" # travel links: " + numTravelLinks); - log.info(" # waiting links: " + numWaitingLinks); - log.info(" # inside links: " + numInsideLinks); - log.info(" # transfer links: " + numTransferLinks); - return transitNetwork; - } - public Collection getNearestNodes(final Coord coord, final double distance) { - return this.qtNodes.getDisk(coord.getX(), coord.getY(), distance); - } - - public TransitRouterNetworkNode getNearestNode(final Coord coord) { - return this.qtNodes.getClosest(coord.getX(), coord.getY()); - } - - @Override - public double getCapacityPeriod() { - return 3600.0; - } - - @Override - public NetworkFactory getFactory() { - return null; - } - - @Override - public double getEffectiveLaneWidth() { - return 3; - } - - @Override - public void addNode(Node nn) { - throw new UnsupportedOperationException(); - } - - @Override - public void addLink(Link ll) { - throw new UnsupportedOperationException(); - } - - @Override - public Link removeLink(Id linkId) { - throw new UnsupportedOperationException(); - } - - @Override - public Node removeNode(Id nodeId) { - throw new UnsupportedOperationException(); - } - - @Override - public void setCapacityPeriod(double capPeriod) { - throw new RuntimeException("not implemented") ; - } - - @Override - public void setEffectiveCellSize(double effectiveCellSize) { - throw new RuntimeException("not implemented") ; - } - - @Override - public void setEffectiveLaneWidth(double effectiveLaneWidth) { - throw new RuntimeException("not implemented") ; - } - - @Override - public void setName(String name) { - throw new RuntimeException("not implemented") ; - } - - @Override - public String getName() { - throw new RuntimeException("not implemented") ; - } - - @Override - public double getEffectiveCellSize() { - throw new RuntimeException("not implemented") ; - } - - @Override - public Attributes getAttributes() { - throw new UnsupportedOperationException(); - } -} diff --git a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/TransitRouterVariableImpl.java b/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/TransitRouterVariableImpl.java deleted file mode 100644 index 3c867f3240b..00000000000 --- a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/TransitRouterVariableImpl.java +++ /dev/null @@ -1,243 +0,0 @@ -/* *********************************************************************** * - * project: org.matsim.* - * TranitRouterVariableImpl.java - * * - * *********************************************************************** * - * * - * copyright : (C) 2009 by the members listed in the COPYING, * - * LICENSE and WARRANTY file. * - * email : info at matsim dot org * - * * - * *********************************************************************** * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * See also COPYING, LICENSE and WARRANTY file * - * * - * *********************************************************************** */ - -package org.matsim.contrib.eventsBasedPTRouter; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.matsim.api.core.v01.Coord; -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.api.core.v01.network.Node; -import org.matsim.api.core.v01.population.Leg; -import org.matsim.api.core.v01.population.Person; -import org.matsim.api.core.v01.population.Route; -import org.matsim.core.population.PopulationUtils; -import org.matsim.core.population.routes.RouteUtils; -import org.matsim.core.router.InitialNode; -import org.matsim.core.router.RoutingRequest; -import org.matsim.core.router.TripStructureUtils; -import org.matsim.core.router.util.LeastCostPathCalculator.Path; -import org.matsim.core.router.util.PreProcessDijkstra; -import org.matsim.core.utils.geometry.CoordUtils; -import org.matsim.facilities.Facility; -import org.matsim.pt.router.TransitRouter; -import org.matsim.pt.router.TransitRouterConfig; -import org.matsim.pt.router.TransitRouterNetworkTravelTimeAndDisutility; -import org.matsim.pt.routes.DefaultTransitPassengerRoute; -import org.matsim.pt.routes.TransitPassengerRoute; -import org.matsim.pt.transitSchedule.api.TransitRouteStop; - -public class TransitRouterVariableImpl implements TransitRouter { - - private final TransitRouterNetworkWW transitNetwork; - - private final MultiNodeDijkstra dijkstra; - private final MultiDestinationDijkstra mDijkstra; - private final TransitRouterConfig config; - private final TransitRouterNetworkTravelTimeAndDisutility ttCalculator; - - public TransitRouterVariableImpl(final TransitRouterConfig config, final TransitRouterNetworkTravelTimeAndDisutility ttCalculator, final TransitRouterNetworkWW routerNetwork) { - this.config = config; - this.transitNetwork = routerNetwork; - this.ttCalculator = ttCalculator; - this.dijkstra = new MultiNodeDijkstra(this.transitNetwork, this.ttCalculator, this.ttCalculator); - PreProcessDijkstra preProcessDijkstra = new PreProcessDijkstra(); - preProcessDijkstra.run(routerNetwork); - mDijkstra = new MultiDestinationDijkstra(routerNetwork, this.ttCalculator, this.ttCalculator, preProcessDijkstra); - } - - private Map locateWrappedNearestTransitNodes(Person person, Coord coord, double departureTime){ - Collection nearestNodes = this.transitNetwork.getNearestNodes(coord, this.config.getSearchRadius()); - if (nearestNodes.size() < 2) { - // also enlarge search area if only one stop found, maybe a second one is near the border of the search area - TransitRouterNetworkWW.TransitRouterNetworkNode nearestNode = this.transitNetwork.getNearestNode(coord); - double distance = CoordUtils.calcEuclideanDistance(coord, nearestNode.stop.getStopFacility().getCoord()); - nearestNodes = this.transitNetwork.getNearestNodes(coord, distance + this.config.getExtensionRadius()); - } - Map wrappedNearestNodes = new LinkedHashMap(); - for (TransitRouterNetworkWW.TransitRouterNetworkNode node : nearestNodes) { - Coord toCoord = node.stop.getStopFacility().getCoord(); - double initialTime = getWalkTime(person, coord, toCoord); - double initialCost = getWalkDisutility(person, coord, toCoord); - wrappedNearestNodes.put(node, new InitialNode(initialCost, initialTime + departureTime)); - } - return wrappedNearestNodes; - } - - private double getWalkTime(Person person, Coord coord, Coord toCoord) { - return this.ttCalculator.getWalkTravelTime(person, coord, toCoord); - } - - private double getWalkDisutility(Person person, Coord coord, Coord toCoord) { - return this.ttCalculator.getWalkTravelDisutility(person, coord, toCoord); - } - - public Map, Path> calcPathRoutes(final Id fromNodeId, final Set> toNodeIds, final double startTime, final Person person) { - Set toNodes = new HashSet<>(); - for(Id toNode:toNodeIds) - if(transitNetwork.getNodes().get(toNode)!=null) - toNodes.add(transitNetwork.getNodes().get(toNode)); - Node node = transitNetwork.getNodes().get(fromNodeId); - if(node!=null) - return mDijkstra.calcLeastCostPath(node, toNodes, startTime, person); - else - return new HashMap<>(); - } - @Override - public List calcRoute(RoutingRequest request) { - final Facility fromFacility = request.getFromFacility(); - final Facility toFacility = request.getToFacility(); - final double departureTime = request.getDepartureTime(); - final Person person = request.getPerson(); - - // find possible start stops - Map wrappedFromNodes = this.locateWrappedNearestTransitNodes(person, fromFacility.getCoord(), departureTime); - // find possible end stops - Map wrappedToNodes = this.locateWrappedNearestTransitNodes(person, toFacility.getCoord(), departureTime); - - // find routes between start and end stops - Path p = this.dijkstra.calcLeastCostPath(wrappedFromNodes, wrappedToNodes, person); - if (p == null) { - return null; - } - - double directWalkCost = CoordUtils.calcEuclideanDistance(fromFacility.getCoord(), toFacility.getCoord()) / this.config.getBeelineWalkSpeed() * ( 0 - this.config.getMarginalUtilityOfTravelTimeWalk_utl_s()); - double pathCost = p.travelCost + wrappedFromNodes.get(p.getFromNode()).initialCost + wrappedToNodes.get( - p.getToNode()).initialCost; - if (directWalkCost < pathCost) { - List legs = new ArrayList(); - Leg leg = PopulationUtils.createLeg(TransportMode.walk); // formerly transit_walk - TripStructureUtils.setRoutingMode(leg, TransportMode.pt); - double walkDistance = CoordUtils.calcEuclideanDistance(fromFacility.getCoord(), toFacility.getCoord()); - Route walkRoute = RouteUtils.createGenericRouteImpl(null, null); - walkRoute.setDistance(walkDistance); - leg.setRoute(walkRoute); - leg.setTravelTime(walkDistance/this.config.getBeelineWalkSpeed()); - legs.add(leg); - return legs; - } - - return convertPathToLegList( departureTime, p, fromFacility.getCoord(), toFacility.getCoord(), person ) ; - } - - public Path calcPathRoute(final Coord fromCoord, final Coord toCoord, final double departureTime, final Person person) { - // find possible start stops - // find possible start stops - Map wrappedFromNodes = this.locateWrappedNearestTransitNodes(person, fromCoord, departureTime); - // find possible end stops - Map wrappedToNodes = this.locateWrappedNearestTransitNodes(person, toCoord, departureTime); - // find routes between start and end stops - Path path = this.dijkstra.calcLeastCostPath(wrappedFromNodes, wrappedToNodes, person); - if (path == null) { - return null; - } - double directWalkTime = CoordUtils.calcEuclideanDistance(fromCoord, toCoord) / this.config.getBeelineWalkSpeed(); - double directWalkCost = directWalkTime * ( 0 - this.config.getMarginalUtilityOfTravelTimeWalk_utl_s()); - double pathCost = path.travelCost + wrappedFromNodes.get(path.getFromNode()).initialCost + wrappedToNodes.get( - path.getToNode()).initialCost; - if (directWalkCost < pathCost) { - return new Path(new ArrayList(), new ArrayList(), directWalkTime, directWalkCost); - } - double pathTime = path.travelTime + wrappedFromNodes.get(path.getFromNode()).initialTime + wrappedToNodes.get( - path.getToNode()).initialTime - 2 * departureTime; - return new Path(path.nodes, path.links, pathTime, pathCost); - } - - protected List convertPathToLegList( double departureTime, Path p, Coord fromCoord, Coord toCoord, Person person) { - List legs = new ArrayList(); - Leg leg; - double walkDistance, walkWaitTime, travelTime = 0; - Route walkRoute; - Coord coord = fromCoord; - TransitRouteStop stop = null; - double time = departureTime; - for (Link link : p.links) { - TransitRouterNetworkWW.TransitRouterNetworkLink l = (TransitRouterNetworkWW.TransitRouterNetworkLink) link; - if(l.route!=null) { - //in line link - double ttime = ttCalculator.getLinkTravelTime(l, time, person, null); - travelTime += ttime; - time += ttime; - } - else if(l.fromNode.route!=null) { - //inside link - leg = PopulationUtils.createLeg(TransportMode.pt); - TransitPassengerRoute ptRoute = new DefaultTransitPassengerRoute(stop.getStopFacility(), l.fromNode.line, l.fromNode.route, l.fromNode.stop.getStopFacility()); - leg.setRoute(ptRoute); - leg.setTravelTime(travelTime); - legs.add(leg); - travelTime = 0; - stop = l.fromNode.stop; - coord = l.fromNode.stop.getStopFacility().getCoord(); - } - else if(l.toNode.route!=null) { - //wait link - leg = PopulationUtils.createLeg(TransportMode.walk); - TripStructureUtils.setRoutingMode(leg, TransportMode.pt); - walkDistance = CoordUtils.calcEuclideanDistance(coord, l.toNode.stop.getStopFacility().getCoord()); - walkWaitTime = walkDistance/this.config.getBeelineWalkSpeed()/*+ttCalculator.getLinkTravelTime(l, time+walkDistance/this.config.getBeelineWalkSpeed(), person, null)*/; - walkRoute = RouteUtils.createGenericRouteImpl(stop==null?null:stop.getStopFacility().getLinkId(), l.toNode.stop.getStopFacility().getLinkId()); - walkRoute.setDistance(walkDistance); - leg.setRoute(walkRoute); - leg.setTravelTime(walkWaitTime); - legs.add(leg); - stop = l.toNode.stop; - time += walkWaitTime; - } - - } - leg = PopulationUtils.createLeg(TransportMode.walk); - TripStructureUtils.setRoutingMode(leg, TransportMode.pt); - walkDistance = CoordUtils.calcEuclideanDistance(coord, toCoord); - walkWaitTime = walkDistance/this.config.getBeelineWalkSpeed(); - walkRoute = RouteUtils.createGenericRouteImpl(stop==null?null:stop.getStopFacility().getLinkId(), null); - walkRoute.setDistance(walkDistance); - leg.setRoute(walkRoute); - leg.setTravelTime(walkWaitTime); - legs.add(leg); - return legs; - } - - public TransitRouterNetworkWW getTransitRouterNetwork() { - return this.transitNetwork; - } - - protected TransitRouterNetworkWW getTransitNetwork() { - return transitNetwork; - } - - protected MultiNodeDijkstra getDijkstra() { - return dijkstra; - } - - protected TransitRouterConfig getConfig() { - return config; - } - -} diff --git a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/controler/RunControlerWS.java b/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/controler/RunControlerWS.java deleted file mode 100644 index 56ea9525a6b..00000000000 --- a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/controler/RunControlerWS.java +++ /dev/null @@ -1,66 +0,0 @@ -/* *********************************************************************** * - * project: org.matsim.* - * ControlerWW.java - * * - * *********************************************************************** * - * * - * copyright : (C) 2012 by the members listed in the COPYING, * - * LICENSE and WARRANTY file. * - * email : info at matsim dot org * - * * - * *********************************************************************** * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * See also COPYING, LICENSE and WARRANTY file * - * * - * *********************************************************************** */ - -package org.matsim.contrib.eventsBasedPTRouter.controler; - -import org.matsim.contrib.eventsBasedPTRouter.TransitRouterEventsWSFactory; -import org.matsim.contrib.eventsBasedPTRouter.stopStopTimes.StopStopTimeCalculatorImpl; -import org.matsim.contrib.eventsBasedPTRouter.waitTimes.WaitTimeStuckCalculator; -import org.matsim.core.config.Config; -import org.matsim.core.config.ConfigUtils; -import org.matsim.core.controler.AbstractModule; -import org.matsim.core.controler.Controler; -import org.matsim.core.controler.OutputDirectoryHierarchy; -import org.matsim.core.scenario.ScenarioUtils; -import org.matsim.pt.router.TransitRouter; - - -/** - * A run Controler for a transit router that depends on the travel times and wait times - * - * @author sergioo - */ - -public class RunControlerWS { - - public static void main(String[] args) { - Config config = ConfigUtils.createConfig(); - ConfigUtils.loadConfig(config, args[0]); - final Controler controler = new Controler(ScenarioUtils.loadScenario(config)); - controler.getConfig().controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles); - final WaitTimeStuckCalculator waitTimeCalculator = new WaitTimeStuckCalculator(controler.getScenario().getPopulation(), - controler.getScenario().getTransitSchedule(), controler.getConfig().travelTimeCalculator().getTraveltimeBinSize(), - (int) (controler.getConfig().qsim().getEndTime().seconds()-controler.getConfig().qsim().getStartTime().seconds())); - controler.getEvents().addHandler(waitTimeCalculator); - final StopStopTimeCalculatorImpl stopStopTimeCalculator = new StopStopTimeCalculatorImpl(controler.getScenario().getTransitSchedule(), - controler.getConfig().travelTimeCalculator().getTraveltimeBinSize(), - (int) (controler.getConfig().qsim().getEndTime().seconds()-controler.getConfig().qsim().getStartTime().seconds())); - controler.getEvents().addHandler(stopStopTimeCalculator); - controler.addOverridingModule(new AbstractModule() { - @Override - public void install() { - bind(TransitRouter.class).toProvider(new TransitRouterEventsWSFactory(controler.getScenario(), waitTimeCalculator.get(), - stopStopTimeCalculator.get())); - } - }); - controler.run(); - } - -} diff --git a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/controler/RunControlerWSV.java b/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/controler/RunControlerWSV.java deleted file mode 100644 index a40e1bdf88f..00000000000 --- a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/controler/RunControlerWSV.java +++ /dev/null @@ -1,77 +0,0 @@ -/* *********************************************************************** * - * project: org.matsim.* - * ControlerWW.java - * * - * *********************************************************************** * - * * - * copyright : (C) 2012 by the members listed in the COPYING, * - * LICENSE and WARRANTY file. * - * email : info at matsim dot org * - * * - * *********************************************************************** * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * See also COPYING, LICENSE and WARRANTY file * - * * - * *********************************************************************** */ - -package org.matsim.contrib.eventsBasedPTRouter.controler; - -import org.matsim.contrib.eventsBasedPTRouter.TransitRouterEventsWSVFactory; -import org.matsim.contrib.eventsBasedPTRouter.stopStopTimes.StopStopTimeCalculatorImpl; -import org.matsim.contrib.eventsBasedPTRouter.vehicleOccupancy.VehicleOccupancyCalculator; -import org.matsim.contrib.eventsBasedPTRouter.waitTimes.WaitTimeStuckCalculator; -import org.matsim.core.config.Config; -import org.matsim.core.config.ConfigUtils; -import org.matsim.core.controler.AbstractModule; -import org.matsim.core.controler.Controler; -import org.matsim.core.scenario.MutableScenario; -import org.matsim.core.scenario.ScenarioUtils; -import org.matsim.pt.router.TransitRouter; - - -/** - * A run Controler for a transit router that depends on the travel times and wait times - * - * @author sergioo - */ - -public class RunControlerWSV { - - public static void main(String[] args) { - Config config = ConfigUtils.createConfig(); - ConfigUtils.loadConfig(config, args[0]); - final Controler controler = new Controler(ScenarioUtils.loadScenario(config)); - final WaitTimeStuckCalculator waitTimeCalculator = new WaitTimeStuckCalculator(controler.getScenario().getPopulation(), - controler.getScenario().getTransitSchedule(), controler.getConfig().travelTimeCalculator().getTraveltimeBinSize(), - (int) (controler.getConfig().qsim().getEndTime().seconds()-controler.getConfig().qsim().getStartTime().seconds())); - controler.getEvents().addHandler(waitTimeCalculator); - final StopStopTimeCalculatorImpl stopStopTimeCalculator = new StopStopTimeCalculatorImpl(controler.getScenario().getTransitSchedule(), - controler.getConfig().travelTimeCalculator().getTraveltimeBinSize(), - (int) (controler.getConfig().qsim().getEndTime().seconds()-controler.getConfig().qsim().getStartTime().seconds())); - controler.getEvents().addHandler(stopStopTimeCalculator); - final VehicleOccupancyCalculator vehicleOccupancyCalculator = new VehicleOccupancyCalculator(controler.getScenario().getTransitSchedule(), - ((MutableScenario)controler.getScenario()).getTransitVehicles(), - controler.getConfig().travelTimeCalculator().getTraveltimeBinSize(), - (int) (controler.getConfig().qsim().getEndTime().seconds()-controler.getConfig().qsim().getStartTime().seconds())); - controler.getEvents().addHandler(vehicleOccupancyCalculator); - controler.addOverridingModule(new AbstractModule() { - @Override - public void install() { - bind(TransitRouter.class).toProvider(new TransitRouterEventsWSVFactory(controler.getScenario(), waitTimeCalculator.get(), - stopStopTimeCalculator.get(), vehicleOccupancyCalculator.getVehicleOccupancy())); - } - }); - - // yyyyyy note that in the above script only the router is modified, but not the scoring. With standard matsim, a slower bu - // less crowded pt route will only be accepted by the agent when the faster but more crowded option was never presented - // to the agent. (Alternatively, e.g. with the Singapore scenario, there may be boarding denials, in which case - // routes that avoid crowded sections may also be beneficial.) kai, jul'15 - - controler.run(); - } - -} diff --git a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/controler/RunControlerWW.java b/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/controler/RunControlerWW.java deleted file mode 100644 index 27c713ed684..00000000000 --- a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/controler/RunControlerWW.java +++ /dev/null @@ -1,56 +0,0 @@ -/* *********************************************************************** * - * project: org.matsim.* - * ControlerWW.java - * * - * *********************************************************************** * - * * - * copyright : (C) 2012 by the members listed in the COPYING, * - * LICENSE and WARRANTY file. * - * email : info at matsim dot org * - * * - * *********************************************************************** * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * See also COPYING, LICENSE and WARRANTY file * - * * - * *********************************************************************** */ - -package org.matsim.contrib.eventsBasedPTRouter.controler; - -import org.matsim.contrib.eventsBasedPTRouter.TransitRouterEventsWLFactory; -import org.matsim.core.config.Config; -import org.matsim.core.config.ConfigUtils; -import org.matsim.core.controler.AbstractModule; -import org.matsim.core.controler.Controler; -import org.matsim.core.scenario.ScenarioUtils; -import org.matsim.contrib.eventsBasedPTRouter.waitTimes.WaitTimeStuckCalculator; -import org.matsim.pt.router.TransitRouter; - - -/** - * A run Controler for a transit router that depends on the travel times and wait times - * - * @author sergioo - */ - -public class RunControlerWW { - - public static void main(String[] args) { - Config config = ConfigUtils.createConfig(); - ConfigUtils.loadConfig(config, args[0]); - final Controler controler = new Controler(ScenarioUtils.loadScenario(config)); - final WaitTimeStuckCalculator waitTimeCalculator = new WaitTimeStuckCalculator(controler.getScenario().getPopulation(), controler.getScenario().getTransitSchedule(), controler.getConfig(), controler.getEvents()); - controler.getEvents().addHandler(waitTimeCalculator); - controler.addOverridingModule(new AbstractModule() { - @Override - public void install() { - bind(TransitRouter.class).toProvider(new TransitRouterEventsWLFactory(controler, waitTimeCalculator.get())); - } - }); - controler.run(); - } - -} diff --git a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/stopStopTimes/StopStopTime.java b/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/stopStopTimes/StopStopTime.java deleted file mode 100644 index 0b5fa9056f5..00000000000 --- a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/stopStopTimes/StopStopTime.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.matsim.contrib.eventsBasedPTRouter.stopStopTimes; - -import org.matsim.api.core.v01.Id; -import org.matsim.pt.transitSchedule.api.TransitStopFacility; - -import java.io.Serializable; - -public interface StopStopTime extends Serializable { - - //Methods - public double getStopStopTime(Id stopOId, Id stopDId, double time); - public double getStopStopTimeVariance(Id stopOId, Id stopDId, double time); - -} diff --git a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/stopStopTimes/StopStopTimeCalculator.java b/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/stopStopTimes/StopStopTimeCalculator.java deleted file mode 100644 index a27652742bd..00000000000 --- a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/stopStopTimes/StopStopTimeCalculator.java +++ /dev/null @@ -1,20 +0,0 @@ -package org.matsim.contrib.eventsBasedPTRouter.stopStopTimes; - -import com.google.inject.Provider; -import com.google.inject.Provides; -import org.matsim.api.core.v01.Id; -import org.matsim.pt.transitSchedule.api.TransitStopFacility; - - - -public interface StopStopTimeCalculator extends Provider { - - //Methods - double getStopStopTime(Id stopOId, Id stopDId, double time); - - double getStopStopTimeVariance(Id stopOId, Id stopDId, double time); - - @Override - @Provides - StopStopTime get(); -} diff --git a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/stopStopTimes/StopStopTimeCalculatorImpl.java b/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/stopStopTimes/StopStopTimeCalculatorImpl.java deleted file mode 100644 index c2ffef28c35..00000000000 --- a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/stopStopTimes/StopStopTimeCalculatorImpl.java +++ /dev/null @@ -1,153 +0,0 @@ -package org.matsim.contrib.eventsBasedPTRouter.stopStopTimes; - -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; - -import org.matsim.api.core.v01.Id; -import org.matsim.api.core.v01.events.PersonLeavesVehicleEvent; -import org.matsim.api.core.v01.events.handler.PersonLeavesVehicleEventHandler; -import org.matsim.core.api.experimental.events.EventsManager; -import org.matsim.core.api.experimental.events.VehicleArrivesAtFacilityEvent; -import org.matsim.core.api.experimental.events.handler.VehicleArrivesAtFacilityEventHandler; -import org.matsim.core.config.Config; -import org.matsim.core.trafficmonitoring.TimeBinUtils; -import org.matsim.core.utils.collections.Tuple; -import org.matsim.pt.transitSchedule.api.Departure; -import org.matsim.pt.transitSchedule.api.TransitLine; -import org.matsim.pt.transitSchedule.api.TransitRoute; -import org.matsim.pt.transitSchedule.api.TransitSchedule; -import org.matsim.pt.transitSchedule.api.TransitStopFacility; -import org.matsim.vehicles.Vehicle; - -import com.google.inject.Inject; -import com.google.inject.Provides; -import com.google.inject.Singleton; -@Singleton -public class StopStopTimeCalculatorImpl implements VehicleArrivesAtFacilityEventHandler, PersonLeavesVehicleEventHandler, StopStopTimeCalculator { - - private final Map, Map, StopStopTimeData>> stopStopTimes = new HashMap, Map, StopStopTimeData>>(5000); - private final Map, Map, Double>> scheduledStopStopTimes = new HashMap, Map, Double>>(5000); - private final Map, Tuple, Double>> inTransitVehicles = new HashMap, Tuple, Double>>(1000); - private final Set> vehicleIds = new HashSet>(); - private final double timeSlot; - private final int totalTime; - private boolean useVehicleIds = true; - - //Constructors - @Inject - public StopStopTimeCalculatorImpl(final TransitSchedule transitSchedule, final Config config, EventsManager eventsManager) { - this(transitSchedule, config.travelTimeCalculator().getTraveltimeBinSize(), (int) (config.qsim().getEndTime().seconds()-config.qsim().getStartTime().seconds())); - eventsManager.addHandler(this); - } - public StopStopTimeCalculatorImpl(final TransitSchedule transitSchedule, final double timeSlot, final int totalTime) { - this.timeSlot = timeSlot; - this.totalTime = totalTime; - Map, Map, Integer>> numObservations = new HashMap, Map, Integer>>(); - for(TransitLine line:transitSchedule.getTransitLines().values()) - for(TransitRoute route:line.getRoutes().values()) { - for(int s=0; s, StopStopTimeData> map = stopStopTimes.computeIfAbsent( - route.getStops().get(s).getStopFacility().getId(), - k -> new HashMap<>(2)); - map.put(route.getStops().get(s+1).getStopFacility().getId(), new StopStopTimeDataArray(TimeBinUtils.getTimeBinCount(totalTime, timeSlot))); - Map, Double> map2 = scheduledStopStopTimes.get(route.getStops().get(s).getStopFacility().getId()); - Map, Integer> map3 = numObservations.get(route.getStops().get(s).getStopFacility().getId()); - Double stopStopTime; - Integer num; - if(map2==null) { - map2 = new HashMap, Double>(2); - scheduledStopStopTimes.put(route.getStops().get(s).getStopFacility().getId(), map2); - map3 = new HashMap, Integer>(2); - numObservations.put(route.getStops().get(s).getStopFacility().getId(), map3); - stopStopTime = 0.0; - num = 0; - } - else { - stopStopTime = map2.get(route.getStops().get(s+1).getStopFacility().getId()); - num = map3.get(route.getStops().get(s+1).getStopFacility().getId()); - if(stopStopTime==null) { - stopStopTime = 0.0; - num = 0; - } - } - map2.put(route.getStops().get(s+1).getStopFacility().getId(), - stopStopTime+route.getStops().get(s+1).getArrivalOffset().seconds()-route.getStops().get(s).getDepartureOffset().seconds()); - map3.put(route.getStops().get(s+1).getStopFacility().getId(), ++num); - } - for(Departure departure:route.getDepartures().values()) - vehicleIds.add(departure.getVehicleId()); - } - for(Entry, Map, Double>> entry:scheduledStopStopTimes.entrySet()) - for(Entry, Double> entry2:entry.getValue().entrySet()) - entry.getValue().put(entry2.getKey(), entry2.getValue()/numObservations.get(entry.getKey()).get(entry2.getKey())); - } - - //Methods - @Override - public double getStopStopTime(Id stopOId, Id stopDId, double time) { - StopStopTimeData stopStopTimeData = stopStopTimes.get(stopOId).get(stopDId); - int timeBinIndex = TimeBinUtils.getTimeBinIndex(time, timeSlot, TimeBinUtils.getTimeBinCount(totalTime, timeSlot)); - if(stopStopTimeData.getNumData(timeBinIndex)==0) - return scheduledStopStopTimes.get(stopOId).get(stopDId); - else - return stopStopTimeData.getStopStopTime(timeBinIndex); - } - @Override - public double getStopStopTimeVariance(Id stopOId, Id stopDId, double time) { - StopStopTimeData stopStopTimeData = stopStopTimes.get(stopOId).get(stopDId); - int timeBinIndex = TimeBinUtils.getTimeBinIndex(time, timeSlot, TimeBinUtils.getTimeBinCount(totalTime, timeSlot)); - if(stopStopTimeData.getNumData(timeBinIndex)==0) - return 0; - else - return stopStopTimeData.getStopStopTimeVariance(timeBinIndex); - } - @Override - public void reset(int iteration) { - for(Map, StopStopTimeData> map:stopStopTimes.values()) - for(StopStopTimeData stopStopTimeData:map.values()) - stopStopTimeData.resetStopStopTimes(); - inTransitVehicles.clear(); - } - @Override - public void handleEvent(VehicleArrivesAtFacilityEvent event) { - if(!useVehicleIds || vehicleIds.contains(event.getVehicleId())) { - Tuple, Double> route = inTransitVehicles.remove(event.getVehicleId()); - if(route!=null) - stopStopTimes.get(route.getFirst()).get(event.getFacilityId()).addStopStopTime( - TimeBinUtils.getTimeBinIndex(route.getSecond(), timeSlot, TimeBinUtils.getTimeBinCount(totalTime, timeSlot)), - event.getTime()-route.getSecond()); - inTransitVehicles.put(event.getVehicleId(), new Tuple, Double>(event.getFacilityId(), event.getTime())); - } - } - @Override - public void handleEvent(PersonLeavesVehicleEvent event) { - if((!useVehicleIds || vehicleIds.contains(event.getVehicleId())) && event.getPersonId().toString().startsWith("pt_") - && event.getPersonId().toString().contains(event.getVehicleId().toString())) - inTransitVehicles.remove(event.getVehicleId()); - } - public void setUseVehicleIds(boolean useVehicleIds) { - this.useVehicleIds = useVehicleIds; - } - - @Override - @Provides - public StopStopTime get() { - return new StopStopTime() { - /** - * - */ - private static final long serialVersionUID = 1L; - @Override - public double getStopStopTime(Id stopOId, Id stopDId, double time) { - return StopStopTimeCalculatorImpl.this.getStopStopTime(stopOId, stopDId, time); - } - @Override - public double getStopStopTimeVariance(Id stopOId, Id stopDId, double time) { - return StopStopTimeCalculatorImpl.this.getStopStopTimeVariance(stopOId, stopDId, time); - } - }; - } -} diff --git a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/stopStopTimes/StopStopTimeCalculatorSerializable.java b/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/stopStopTimes/StopStopTimeCalculatorSerializable.java deleted file mode 100644 index d03b9ed5f2b..00000000000 --- a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/stopStopTimes/StopStopTimeCalculatorSerializable.java +++ /dev/null @@ -1,192 +0,0 @@ -package org.matsim.contrib.eventsBasedPTRouter.stopStopTimes; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; - -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.events.PersonLeavesVehicleEvent; -import org.matsim.api.core.v01.events.handler.PersonLeavesVehicleEventHandler; -import org.matsim.core.api.experimental.events.VehicleArrivesAtFacilityEvent; -import org.matsim.core.api.experimental.events.handler.VehicleArrivesAtFacilityEventHandler; -import org.matsim.core.config.Config; -import org.matsim.core.trafficmonitoring.TimeBinUtils; -import org.matsim.core.utils.collections.Tuple; -import org.matsim.pt.transitSchedule.api.Departure; -import org.matsim.pt.transitSchedule.api.TransitLine; -import org.matsim.pt.transitSchedule.api.TransitRoute; -import org.matsim.pt.transitSchedule.api.TransitSchedule; -import org.matsim.pt.transitSchedule.api.TransitStopFacility; - -import com.google.inject.Provider; -import com.google.inject.Provides; - -public class StopStopTimeCalculatorSerializable implements StopStopTimeCalculator, VehicleArrivesAtFacilityEventHandler, PersonLeavesVehicleEventHandler, Serializable, Provider { - - /** - * - */ - private static final long serialVersionUID = 1L; - private final Map> stopStopTimes = new HashMap>(5000); - private final Map> scheduledStopStopTimes = new HashMap>(5000); - private final Map> inTransitVehicles = new HashMap>(1000); - private final Set vehicleIds = new HashSet(); - private final double timeSlot; - private final int totalTime; - private boolean useVehicleIds = true; - private static int scheduleCalls = 0; - private static int totalCalls = 0; - private static double stopTimesInflation = 0; - - //Constructors - public StopStopTimeCalculatorSerializable(final TransitSchedule transitSchedule, final Config config) { - this(transitSchedule, config.travelTimeCalculator().getTraveltimeBinSize(), (int) (config.qsim().getEndTime().seconds()-config.qsim().getStartTime().seconds())); - } - public static void printCallStatisticsAndReset(){ - Logger logger = LogManager.getLogger(StopStopTimeCalculatorSerializable.class); - logger.warn("stop times read from schedule vs total (S:T) = " + scheduleCalls + " : " + totalCalls); - logger.warn("inflation of recorded times called vs their scheduled time:" +stopTimesInflation/(double)(totalCalls -scheduleCalls)); - scheduleCalls = 0; - totalCalls = 0; - stopTimesInflation=0; - } - public StopStopTimeCalculatorSerializable(final TransitSchedule transitSchedule, final double timeSlot, final int totalTime) { - this.timeSlot = timeSlot; - this.totalTime = totalTime; - Map> numObservations = new HashMap>(); - for(TransitLine line:transitSchedule.getTransitLines().values()) - for(TransitRoute route:line.getRoutes().values()) { - for(int s=0; s map = stopStopTimes.get(route.getStops().get(s).getStopFacility().getId().toString()); - if(map==null) { - map = new HashMap(2); - stopStopTimes.put(route.getStops().get(s).getStopFacility().getId().toString(), map); - } - map.put(route.getStops().get(s+1).getStopFacility().getId().toString(), - new StopStopTimeDataArray(TimeBinUtils.getTimeBinCount(totalTime, timeSlot))); - Map map2 = scheduledStopStopTimes.get(route.getStops().get(s).getStopFacility().getId().toString()); - Map map3 = numObservations.get(route.getStops().get(s).getStopFacility().getId().toString()); - Double stopStopTime; - Integer num; - if(map2==null) { - map2 = new HashMap(2); - scheduledStopStopTimes.put(route.getStops().get(s).getStopFacility().getId().toString(), map2); - map3 = new HashMap(2); - numObservations.put(route.getStops().get(s).getStopFacility().getId().toString(), map3); - stopStopTime = 0.0; - num = 0; - } - else { - stopStopTime = map2.get(route.getStops().get(s+1).getStopFacility().getId().toString()); - num = map3.get(route.getStops().get(s+1).getStopFacility().getId().toString()); - if(stopStopTime==null) { - stopStopTime = 0.0; - num = 0; - } - } - map2.put(route.getStops().get(s+1).getStopFacility().getId().toString(), - stopStopTime+route.getStops().get(s+1).getArrivalOffset().seconds() - - route.getStops().get(s).getDepartureOffset().seconds()); - map3.put(route.getStops().get(s+1).getStopFacility().getId().toString(), ++num); - } - for(Departure departure:route.getDepartures().values()) - vehicleIds.add(departure.getVehicleId().toString()); - } - for(Entry> entry:scheduledStopStopTimes.entrySet()) - for(Entry entry2:entry.getValue().entrySet()) - entry.getValue().put(entry2.getKey(), entry2.getValue()/numObservations.get(entry.getKey()).get(entry2.getKey())); - } - - //Methods - public StopStopTime getStopStopTimes() { - return new StopStopTime() { - /** - * - */ - private static final long serialVersionUID = 1L; - @Override - public double getStopStopTime(Id stopOId, Id stopDId, double time) { - return StopStopTimeCalculatorSerializable.this.getStopStopTime(stopOId, stopDId, time); - } - @Override - public double getStopStopTimeVariance(Id stopOId, Id stopDId, double time) { - return StopStopTimeCalculatorSerializable.this.getStopStopTimeVariance(stopOId, stopDId, time); - } - }; - } - @Override - public double getStopStopTime(Id stopOId, Id stopDId, double time) { - StopStopTimeData stopStopTimeData = stopStopTimes.get(stopOId.toString()).get(stopDId.toString()); - totalCalls++; - int timeBinIndex = TimeBinUtils.getTimeBinIndex(time, timeSlot, TimeBinUtils.getTimeBinCount(totalTime, timeSlot)); - if(stopStopTimeData.getNumData(timeBinIndex)==0) { - scheduleCalls++; - return scheduledStopStopTimes.get(stopOId.toString()).get(stopDId.toString()); - } - else { - stopTimesInflation += stopStopTimeData.getStopStopTime(timeBinIndex)/scheduledStopStopTimes.get(stopOId.toString()).get(stopDId.toString()); - return stopStopTimeData.getStopStopTime(timeBinIndex); - } - } - @Override - public double getStopStopTimeVariance(Id stopOId, Id stopDId, double time) { - StopStopTimeData stopStopTimeData = stopStopTimes.get(stopOId.toString()).get(stopDId.toString()); - int timeBinIndex = TimeBinUtils.getTimeBinIndex(time, timeSlot, TimeBinUtils.getTimeBinCount(totalTime, timeSlot)); - if(stopStopTimeData.getNumData(timeBinIndex)==0) - return 0; - else - return stopStopTimeData.getStopStopTimeVariance(timeBinIndex); - } - - @Provides - public StopStopTime get() { - return new StopStopTime() { - @Override - public double getStopStopTime(Id stopOId, Id stopDId, double time) { - return StopStopTimeCalculatorSerializable.this.getStopStopTime(stopOId,stopDId,time); - } - - @Override - public double getStopStopTimeVariance(Id stopOId, Id stopDId, double time) { - return StopStopTimeCalculatorSerializable.this.getStopStopTimeVariance(stopOId,stopDId,time); - } - }; - } - - @Override - public void reset(int iteration) { - for(Map map:stopStopTimes.values()) - for(StopStopTimeData stopStopTimeData:map.values()) - stopStopTimeData.resetStopStopTimes(); - inTransitVehicles.clear(); - } - @Override - public void handleEvent(VehicleArrivesAtFacilityEvent event) { - if(!useVehicleIds || vehicleIds.contains(event.getVehicleId().toString())) { - Tuple route = inTransitVehicles.remove(event.getVehicleId().toString()); - if(route!=null) - try { - stopStopTimes.get(route.getFirst()).get(event.getFacilityId().toString()).addStopStopTime( - TimeBinUtils.getTimeBinIndex(route.getSecond(), timeSlot, TimeBinUtils.getTimeBinCount(totalTime, timeSlot)), - event.getTime()-route.getSecond()); - } catch(Exception e) { - //System.out.println("No: "+route.getFirst()+"-->"+event.getFacilityId()); - } - inTransitVehicles.put(event.getVehicleId().toString(), new Tuple(event.getFacilityId().toString(), event.getTime())); - } - } - @Override - public void handleEvent(PersonLeavesVehicleEvent event) { - if((!useVehicleIds || vehicleIds.contains(event.getVehicleId().toString())) && event.getPersonId().toString().startsWith("pt_") - && event.getPersonId().toString().contains(event.getVehicleId().toString())) - inTransitVehicles.remove(event.getVehicleId().toString()); - } - public void setUseVehicleIds(boolean useVehicleIds) { - this.useVehicleIds = useVehicleIds; - } -} diff --git a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/stopStopTimes/StopStopTimeCalculatorTuple.java b/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/stopStopTimes/StopStopTimeCalculatorTuple.java deleted file mode 100644 index 1d6a522694e..00000000000 --- a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/stopStopTimes/StopStopTimeCalculatorTuple.java +++ /dev/null @@ -1,134 +0,0 @@ -package org.matsim.contrib.eventsBasedPTRouter.stopStopTimes; - -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import org.matsim.api.core.v01.Id; -import org.matsim.api.core.v01.Scenario; -import org.matsim.api.core.v01.events.PersonLeavesVehicleEvent; -import org.matsim.api.core.v01.events.handler.PersonLeavesVehicleEventHandler; -import org.matsim.core.api.experimental.events.VehicleArrivesAtFacilityEvent; -import org.matsim.core.api.experimental.events.handler.VehicleArrivesAtFacilityEventHandler; -import org.matsim.core.config.Config; -import org.matsim.core.config.ConfigUtils; -import org.matsim.core.scenario.ScenarioUtils; -import org.matsim.core.trafficmonitoring.TimeBinUtils; -import org.matsim.core.utils.collections.Tuple; -import org.matsim.core.utils.misc.Time; -import org.matsim.pt.transitSchedule.api.Departure; -import org.matsim.pt.transitSchedule.api.TransitLine; -import org.matsim.pt.transitSchedule.api.TransitRoute; -import org.matsim.pt.transitSchedule.api.TransitSchedule; -import org.matsim.pt.transitSchedule.api.TransitScheduleReader; -import org.matsim.pt.transitSchedule.api.TransitStopFacility; -import org.matsim.vehicles.Vehicle; - -public class StopStopTimeCalculatorTuple implements VehicleArrivesAtFacilityEventHandler, PersonLeavesVehicleEventHandler { - - private final Map, Id>, StopStopTimeData> stopStopTimes = new HashMap, Id>, StopStopTimeData>(); - private final Map, Id>, Double> scheduledStopStopTimes = new HashMap, Id>, Double>(); - private final Map, Tuple, Double>> inTransitVehicles = new HashMap, Tuple, Double>>(1000); - private final Set> vehicleIds = new HashSet>(); - private final double timeSlot; - private final int totalTime; - - //Constructors - public StopStopTimeCalculatorTuple(final TransitSchedule transitSchedule, final Config config) { - this(transitSchedule, config.travelTimeCalculator().getTraveltimeBinSize(), (int) (config.qsim().getEndTime().seconds()-config.qsim().getStartTime().seconds())); - } - public StopStopTimeCalculatorTuple(final TransitSchedule transitSchedule, final double timeSlot, final int totalTime) { - this.timeSlot = timeSlot; - this.totalTime = totalTime; - Map, Id>, Integer> numObservations = new HashMap, Id>, Integer>(); - for(TransitLine line:transitSchedule.getTransitLines().values()) - for(TransitRoute route:line.getRoutes().values()) { - for(int s=0; s, Id> key = new Tuple, Id>(route.getStops().get(s).getStopFacility().getId(), - route.getStops().get(s+1).getStopFacility().getId()); - StopStopTimeData data = stopStopTimes.get(key); - if(data==null) - stopStopTimes.put(key, new StopStopTimeDataArray(TimeBinUtils.getTimeBinCount(totalTime, timeSlot))); - Double sTime = scheduledStopStopTimes.get(key); - Integer num = numObservations.get(key); - if(sTime==null) { - sTime = 0.0; - scheduledStopStopTimes.put(key, sTime); - num = 0; - numObservations.put(key, num); - } - scheduledStopStopTimes.put(key, (num*sTime+route.getStops().get(s+1).getArrivalOffset().seconds() - - route.getStops().get(s).getDepartureOffset().seconds())/++num); - numObservations.put(key, num); - } - for(Departure departure:route.getDepartures().values()) - vehicleIds.add(departure.getVehicleId()); - } - System.out.println(stopStopTimes.size()); - } - public static void main(String[] args) { - Scenario scenario = ScenarioUtils.createScenario(ConfigUtils.createConfig()); - scenario.getConfig().transit().setUseTransit(true); - new TransitScheduleReader(scenario).readFile(args[0]); - new StopStopTimeCalculatorTuple(scenario.getTransitSchedule(), 900, 30*3600); - } - //Methods - public StopStopTime getStopStopTimes() { - return new StopStopTime() { - /** - * - */ - private static final long serialVersionUID = 1L; - @Override - public double getStopStopTime(Id stopOId, Id stopDId, double time) { - return StopStopTimeCalculatorTuple.this.getStopStopTime(stopOId, stopDId, time); - } - @Override - public double getStopStopTimeVariance(Id stopOId, Id stopDId, double time) { - return StopStopTimeCalculatorTuple.this.getStopStopTimeVariance(stopOId, stopDId, time); - } - }; - } - private double getStopStopTime(Id stopOId, Id stopDId, double time) { - Tuple, Id> key = new Tuple, Id>(stopOId, stopDId); - StopStopTimeData stopStopTimeData = stopStopTimes.get(key); - int timeBinIndex = TimeBinUtils.getTimeBinIndex(time, timeSlot, TimeBinUtils.getTimeBinCount(totalTime, timeSlot)); - if(stopStopTimeData.getNumData(timeBinIndex)==0) - return scheduledStopStopTimes.get(key); - else - return stopStopTimeData.getStopStopTime(timeBinIndex); - } - private double getStopStopTimeVariance(Id stopOId, Id stopDId, double time) { - Tuple, Id> key = new Tuple, Id>(stopOId, stopDId); - StopStopTimeData stopStopTimeData = stopStopTimes.get(key); - int timeBinIndex = TimeBinUtils.getTimeBinIndex(time, timeSlot, TimeBinUtils.getTimeBinCount(totalTime, timeSlot)); - if(stopStopTimeData.getNumData(timeBinIndex)==0) - return 0; - else - return stopStopTimeData.getStopStopTimeVariance(timeBinIndex); - } - @Override - public void reset(int iteration) { - for(StopStopTimeData stopStopTimeData:stopStopTimes.values()) - stopStopTimeData.resetStopStopTimes(); - inTransitVehicles.clear(); - } - @Override - public void handleEvent(VehicleArrivesAtFacilityEvent event) { - if(vehicleIds.contains(event.getVehicleId())) { - Tuple, Double> route = inTransitVehicles.remove(event.getVehicleId()); - if(route!=null) - stopStopTimes.get(new Tuple, Id>(route.getFirst(), - event.getFacilityId())).addStopStopTime( - TimeBinUtils.getTimeBinIndex(route.getSecond(), timeSlot, - TimeBinUtils.getTimeBinCount(totalTime, timeSlot)), event.getTime()-route.getSecond()); - inTransitVehicles.put(event.getVehicleId(), new Tuple, Double>(event.getFacilityId(), event.getTime())); - } - } - @Override - public void handleEvent(PersonLeavesVehicleEvent event) { - if(vehicleIds.contains(event.getVehicleId()) && event.getPersonId().toString().startsWith("pt_"+event.getVehicleId()+"_")) - inTransitVehicles.remove(event.getVehicleId()); - } -} diff --git a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/stopStopTimes/StopStopTimeData.java b/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/stopStopTimes/StopStopTimeData.java deleted file mode 100644 index 9f3de496a90..00000000000 --- a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/stopStopTimes/StopStopTimeData.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.matsim.contrib.eventsBasedPTRouter.stopStopTimes; - -import java.io.Serializable; - -public interface StopStopTimeData extends Serializable { - - int getNumData(int i); - double getStopStopTime(int i); - void addStopStopTime(final int timeSlot, final double stopStopTime); - void resetStopStopTimes(); - double getStopStopTimeVariance(int timeSlot); - -} diff --git a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/stopStopTimes/StopStopTimeDataArray.java b/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/stopStopTimes/StopStopTimeDataArray.java deleted file mode 100644 index b1ac8626324..00000000000 --- a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/stopStopTimes/StopStopTimeDataArray.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.matsim.contrib.eventsBasedPTRouter.stopStopTimes; - -public class StopStopTimeDataArray implements StopStopTimeData { - - /** - * - */ - private static final long serialVersionUID = 1L; - //Attributes - private double[] stopStopTimeMeans; - private double[] stopStopTimeSquares; - private int[] numTimes; - - //Constructors - public StopStopTimeDataArray(int numSlots) { - stopStopTimeSquares = new double[numSlots]; - stopStopTimeMeans = new double[numSlots]; - numTimes = new int[numSlots]; - resetStopStopTimes(); - } - - //Methods - @Override - public int getNumData(int timeSlot) { - return numTimes[timeSlotWhen StopStopTimes are generated externally, e.g. by a regression. - *

    - * See constructor for input format. - *

    - */ -public class StopStopTimePreCalcSerializable implements StopStopTime, Serializable { - - private final Map>>> stopStopTimes = new HashMap<>(5000); - private final Scenario scenario; - - public boolean isLogarithmic() { - return logarithmic; - } - - private final boolean logarithmic; - private int nfeCounter = 0; - private int aiobCounter = 0; - private int errorCounter = 0; - - //Constructors - - - /** - * Populates a StopStopTime object with stop to stop travel times and their variances - * recorded at particular times. - * Needs at minimum one record per stop-to-stop combination. - * Times at which records are recorded needn't be regular intervals, because a TreeMap is used. - * - * @param inputFile path to the tab-separated file.Format is fromStopId (String), toStopId (String), time of record (seconds, double), - * travelTime (seconds, double), travelTimeVariance (seconds**2, double). No headings or row numbers. - * @param logarithmic if times are recorded as logarithms (normally distributed residuals) - */ - public StopStopTimePreCalcSerializable(String inputFile, Scenario scenario, boolean logarithmic) { - this.logarithmic = logarithmic; - this.scenario = scenario; - BufferedReader reader = IOUtils.getBufferedReader(inputFile); - String txt = ""; - while (true) { - try { - txt = reader.readLine(); - if (txt == null) - break; - String[] split = txt.split("\t"); -// get the map from this stop id - Map>> toMap = stopStopTimes.get(split[0]); - if (toMap == null) { - toMap = new HashMap<>(); - stopStopTimes.put(split[0], toMap); - } - - Map> timeData = toMap.get(split[1]); - if (timeData == null) { - timeData = new TreeMap<>(); - toMap.put(split[1], timeData); - } - - timeData.put(Integer.parseInt(split[2]), new Tuple<>(Double.parseDouble(split[3]), Double.parseDouble(split[4]))); - - } catch (IOException e) { - e.printStackTrace(); - } catch (ArrayIndexOutOfBoundsException e) { - if (aiobCounter < 10) { - System.err.println("Seems one of the lines in the StopStopTime input file is missing a value. Skipping it."); - } else { - System.err.println("Seems one of the lines in the StopStopTime input file is missing a value. Skipping further warnings..."); - - } - aiobCounter++; - } catch (NumberFormatException e) { - if (nfeCounter < 10) { - System.err.println("Some values in the StopStopTime input file are of the wrong type. Skipping it."); - } else { - System.err.println("Some values in the StopStopTime input file are of the wrong type. Skipping further warnings..."); - } - nfeCounter++; - } - } - System.out.println("\n\n*************************************************************************\n\n"); - System.out.println("STOPSTOPTIMES LOADED, filling in the blanks from the schedule and network"); - System.out.println("\n\n*************************************************************************\n\n"); - - for (TransitLine transitLine : scenario.getTransitSchedule().getTransitLines().values()) { - for (TransitRoute route : transitLine.getRoutes().values()) { - TRANSITSTOPS: - for (int s = 0; s < route.getStops().size() - 1; s++) { - String origin = route.getStops().get(s).getStopFacility().getId().toString(); - String destination = route.getStops().get(s + 1).getStopFacility().getId().toString(); - Map>> toMap = stopStopTimes.get(origin); - if (toMap == null) { - toMap = new HashMap<>(); - stopStopTimes.put(origin, toMap); - } - - Map> timeData = toMap.get(destination); - if (timeData == null) { - timeData = new TreeMap<>(); - toMap.put(destination, timeData); - - try { - List stops; - stops = scenario.getTransitSchedule().getTransitLines().get(transitLine.getId()).getRoutes().get(route.getId()).getStops(); - if (stops == null) - throw new NullPointerException(); - Link fromLink = null; - Link toLink = null; - for (TransitRouteStop tss : stops) { - if (tss.getStopFacility().getId().toString().equals(origin)) { - fromLink = scenario.getNetwork().getLinks().get(tss.getStopFacility().getLinkId()); - } - if (tss.getStopFacility().getId().toString().equals(destination)) { - toLink = scenario.getNetwork().getLinks().get(tss.getStopFacility().getLinkId()); - } - } - if (fromLink == null || toLink == null) - throw new NullPointerException(); - NetworkRoute networkRoute = scenario.getTransitSchedule().getTransitLines().get(transitLine.getId()) - .getRoutes().get(route.getId()).getRoute(); - NetworkRoute subRoute = networkRoute.getSubRoute(fromLink.getId(), toLink.getId()); - List> linkIds = new ArrayList<>(); - linkIds.addAll(subRoute.getLinkIds()); - linkIds.add(toLink.getId()); - double freeSpeedTravelTime = 0; - for (Id id : linkIds) { - Link link = scenario.getNetwork().getLinks().get(id); - freeSpeedTravelTime += link.getLength() / link.getFreespeed(); - } - if (logarithmic) - timeData.put(0, new Tuple(Math.log(freeSpeedTravelTime), 0.005)); - else - timeData.put(0, new Tuple(freeSpeedTravelTime, 0.0)); - - } catch (NullPointerException ne) { - System.err.printf("Couldnt create STOP-STOP entry for for from: %s, to: %s, route: %s, line: %s\n", - origin, destination, route.getId().toString(), transitLine.getId().toString()); - continue TRANSITSTOPS; - } - - } else { - //value already exists (assuming singular stop-stop network routes) - continue TRANSITSTOPS; - } - - } - } - } - } - - - /** - * Retrieves the interpolated travel time for a combination of stops at a particular time, or the first/last variance observation if one cannot be interpolated. - *

    - * Returns the error value of infinity for a compbination that doesn't appear in the map - * - * @param stopOId - * @param stopDId - * @param time - * @return the travel time, or Double.POSITIVE_INFINITY - */ - public double getStopStopTime(Id stopOId, Id stopDId, double time) { - Map>> toMap = stopStopTimes.get(stopOId.toString()); - - if (toMap == null) { - return errorValue(stopOId, stopDId); - } - - TreeMap> timedObservations = (TreeMap>) toMap.get(stopDId.toString()); - - if (timedObservations == null) { - return errorValue(stopOId, stopDId); - } - - Map.Entry> ceilingEntry = timedObservations.ceilingEntry((int) time); - Map.Entry> floorEntry = timedObservations.floorEntry((int) time); - if (ceilingEntry == null) { - if (floorEntry == null) { - return errorValue(stopOId, stopDId); - } else { - return floorEntry.getValue().getFirst(); - } - } else { - if (floorEntry == null) { - return ceilingEntry.getValue().getFirst(); - } else { - // I have both, so can interpolate a travel time - double x1 = floorEntry.getKey(); - double x2 = ceilingEntry.getKey(); - double y1 = floorEntry.getValue().getFirst(); - double y2 = ceilingEntry.getValue().getFirst(); - double m = (y2 - y1) / (x2 - x1); - double x = time - x1; - return y1 + m * x; - } - } - } - - private double errorValue(Id stopOId, Id stopDId) { - if (errorCounter < 10) { - System.err.println("No StopStop data for origin stop " + stopOId.toString() + ", destination stop " + stopDId.toString() + ". Returning estimation..."); - } else if (errorCounter == 10) { - System.err.println("No StopStop data for origin stop " + stopOId.toString() + ". Skipping further warnings..."); - } - errorCounter++; - - return Double.POSITIVE_INFINITY; - } - - /** - * Retrieves the interpolated travel time variance for a combination of stops at a particular time, or the first/last variance observation if one cannot be interpolated. - *

    - * Returns the error value of infinity for a compbination that doesn't appear in the map - * - * @param stopOId - * @param stopDId - * @param time seconds till the start of the sim - * @return the travel time, or Double.POSITIVE_INFINITY - */ - public double getStopStopTimeVariance(Id stopOId, Id stopDId, double time) { - Map>> toMap = stopStopTimes.get(stopOId.toString()); - - if (toMap == null) { - return errorValue(stopOId, stopDId); - } - - TreeMap> timedObservations = (TreeMap>) toMap.get(stopDId.toString()); - - if (timedObservations == null) { - return errorValue(stopOId, stopDId); - } - - Map.Entry> ceilingEntry = timedObservations.ceilingEntry((int) time); - Map.Entry> floorEntry = timedObservations.floorEntry((int) time); - if (ceilingEntry == null) { - if (floorEntry == null) { - return 0; - } else { - return floorEntry.getValue().getSecond(); - } - } else { - if (floorEntry == null) { - return ceilingEntry.getValue().getSecond(); - } else { - // I have both, so can interpolate a travel time - double x1 = floorEntry.getKey(); - double x2 = ceilingEntry.getKey(); - double y1 = floorEntry.getValue().getSecond(); - double y2 = ceilingEntry.getValue().getSecond(); - double m = (y2 - y1) / (x2 - x1); - double x = time - x1; - return y1 + m * x; - } - } - } - - -} diff --git a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/vehicleOccupancy/VehicleOccupancy.java b/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/vehicleOccupancy/VehicleOccupancy.java deleted file mode 100644 index 22168b8ce75..00000000000 --- a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/vehicleOccupancy/VehicleOccupancy.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.matsim.contrib.eventsBasedPTRouter.vehicleOccupancy; - -import org.matsim.api.core.v01.Id; -import org.matsim.pt.transitSchedule.api.TransitLine; -import org.matsim.pt.transitSchedule.api.TransitRoute; -import org.matsim.pt.transitSchedule.api.TransitStopFacility; - -public interface VehicleOccupancy { - - //Methods - public double getVehicleOccupancy(Id stopOId, Id lineId, Id routeId, double time); - -} diff --git a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/vehicleOccupancy/VehicleOccupancyCalculator.java b/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/vehicleOccupancy/VehicleOccupancyCalculator.java deleted file mode 100644 index 9cae7720b1b..00000000000 --- a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/vehicleOccupancy/VehicleOccupancyCalculator.java +++ /dev/null @@ -1,106 +0,0 @@ -package org.matsim.contrib.eventsBasedPTRouter.vehicleOccupancy; - -import java.util.HashMap; -import java.util.Map; - -import org.matsim.api.core.v01.Id; -import org.matsim.api.core.v01.events.PersonEntersVehicleEvent; -import org.matsim.api.core.v01.events.PersonLeavesVehicleEvent; -import org.matsim.api.core.v01.events.TransitDriverStartsEvent; -import org.matsim.api.core.v01.events.handler.PersonEntersVehicleEventHandler; -import org.matsim.api.core.v01.events.handler.PersonLeavesVehicleEventHandler; -import org.matsim.api.core.v01.events.handler.TransitDriverStartsEventHandler; -import org.matsim.core.api.experimental.events.VehicleDepartsAtFacilityEvent; -import org.matsim.core.api.experimental.events.handler.VehicleDepartsAtFacilityEventHandler; -import org.matsim.core.config.Config; -import org.matsim.core.trafficmonitoring.TimeBinUtils; -import org.matsim.core.utils.collections.Tuple; -import org.matsim.pt.transitSchedule.api.TransitLine; -import org.matsim.pt.transitSchedule.api.TransitRoute; -import org.matsim.pt.transitSchedule.api.TransitSchedule; -import org.matsim.pt.transitSchedule.api.TransitStopFacility; -import org.matsim.vehicles.Vehicle; -import org.matsim.vehicles.VehicleCapacity; -import org.matsim.vehicles.Vehicles; - -public class VehicleOccupancyCalculator implements VehicleDepartsAtFacilityEventHandler, PersonEntersVehicleEventHandler, PersonLeavesVehicleEventHandler, TransitDriverStartsEventHandler { - - private final Map, Id>, Map, VehicleOccupancyData>> vehicleOccupancy = new HashMap, Id>, Map, VehicleOccupancyData>>(1000); - private double timeSlot; - private int totalTime; - private Map, Integer> ptVehicles = new HashMap, Integer>(); - private Map, Integer> capacities = new HashMap, Integer>(); - private Map, Tuple, Id>> linesRoutesOfVehicle = new HashMap, Tuple, Id>>(); - private final Vehicles vehicles; - - //Constructors - public VehicleOccupancyCalculator(final TransitSchedule transitSchedule, final Vehicles vehicles, final Config config) { - this(transitSchedule, vehicles, config.travelTimeCalculator().getTraveltimeBinSize(), (int) (config.qsim().getEndTime().seconds()-config.qsim().getStartTime().seconds())); - } - public VehicleOccupancyCalculator(final TransitSchedule transitSchedule, final Vehicles vehicles, final double timeSlot, final int totalTime) { - this.timeSlot = timeSlot; - this.totalTime = totalTime; - for(TransitLine line:transitSchedule.getTransitLines().values()) - for(TransitRoute route:line.getRoutes().values()) { - Map, VehicleOccupancyData> routeMap = new HashMap, VehicleOccupancyData>(100); - vehicleOccupancy.put(new Tuple, Id>(line.getId(), route.getId()), routeMap); - for(int s=0; s stopOId, Id lineId, Id routeId, double time) { - return VehicleOccupancyCalculator.this.getVehicleOccupancy(stopOId, lineId, routeId, time); - } - }; - } - private double getVehicleOccupancy(Id stopOId, Id lineId, Id routeId, double time) { - return vehicleOccupancy.get(new Tuple, Id>(lineId, routeId)).get(stopOId).getVehicleOccupancy(TimeBinUtils.getTimeBinIndex(time, timeSlot, totalTime)); - } - @Override - public void reset(int iteration) { - for(Map, VehicleOccupancyData> map:vehicleOccupancy.values()) - for(VehicleOccupancyData vehicleOcupancyData:map.values()) - vehicleOcupancyData.resetVehicleOccupancies(); - this.ptVehicles.clear(); - } - @Override - public void handleEvent(VehicleDepartsAtFacilityEvent event) { - Integer num = ptVehicles.get(event.getVehicleId()); - if(num!=null) { - VehicleOccupancyData vehicleOccupancyData = vehicleOccupancy.get(linesRoutesOfVehicle.get(event.getVehicleId())).get(event.getFacilityId()); - if(vehicleOccupancyData!=null) - vehicleOccupancyData.addVehicleOccupancy( - TimeBinUtils.getTimeBinIndex(event.getTime(), timeSlot, - TimeBinUtils.getTimeBinCount(totalTime, timeSlot)), - num/(double)capacities.get(event.getVehicleId())); - } - } - @Override - public void handleEvent(PersonLeavesVehicleEvent event) { - Integer num = this.ptVehicles.get(event.getVehicleId()); - if(num!=null) - this.ptVehicles.put(event.getVehicleId(), num-1); - } - @Override - public void handleEvent(PersonEntersVehicleEvent event) { - Integer num = this.ptVehicles.get(event.getVehicleId()); - if(num!=null) - this.ptVehicles.put(event.getVehicleId(), num+1); - } - @Override - public void handleEvent(TransitDriverStartsEvent event) { - this.ptVehicles.put(event.getVehicleId(), 0); - VehicleCapacity vehicleCapacity = vehicles.getVehicles().get(event.getVehicleId()).getType().getCapacity(); - this.capacities.put(event.getVehicleId(), vehicleCapacity.getSeats()+vehicleCapacity.getStandingRoom()); - linesRoutesOfVehicle.put(event.getVehicleId(), new Tuple, Id>(event.getTransitLineId(), event.getTransitRouteId())); - } - - -} diff --git a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/vehicleOccupancy/VehicleOccupancyData.java b/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/vehicleOccupancy/VehicleOccupancyData.java deleted file mode 100644 index 59e155a79e9..00000000000 --- a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/vehicleOccupancy/VehicleOccupancyData.java +++ /dev/null @@ -1,9 +0,0 @@ -package org.matsim.contrib.eventsBasedPTRouter.vehicleOccupancy; - -public interface VehicleOccupancyData { - - double getVehicleOccupancy(int i); - void addVehicleOccupancy(final int timeSlot, final double vehicleOccupancy); - void resetVehicleOccupancies(); - -} diff --git a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/vehicleOccupancy/VehicleOccupancyDataArray.java b/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/vehicleOccupancy/VehicleOccupancyDataArray.java deleted file mode 100644 index 29c405c1772..00000000000 --- a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/vehicleOccupancy/VehicleOccupancyDataArray.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.matsim.contrib.eventsBasedPTRouter.vehicleOccupancy; - -public class VehicleOccupancyDataArray implements VehicleOccupancyData { - - //Attributes - private double[] vehicleOccupancies; - private int[] numTimes; - private int lastPosition; - - //Constructors - public VehicleOccupancyDataArray(int numSlots) { - vehicleOccupancies = new double[numSlots]; - numTimes = new int[numSlots]; - resetVehicleOccupancies(); - } - - //Methods - @Override - public double getVehicleOccupancy(int timeSlot) { - if(timeSlot>lastPosition) - return 1; - else - while(vehicleOccupancies[timeSlot]==-1) - timeSlot++; - return vehicleOccupancies[timeSlot]; - } - @Override - public synchronized void addVehicleOccupancy(int timeSlot, double vehicleOccupancy) { - if(lastPosition lineId, Id routeId, Id stopId, double time); - -} diff --git a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/waitTimes/WaitTimeCalculator.java b/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/waitTimes/WaitTimeCalculator.java deleted file mode 100644 index 3cec2e82f67..00000000000 --- a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/waitTimes/WaitTimeCalculator.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.matsim.contrib.eventsBasedPTRouter.waitTimes; - -import com.google.inject.Provider; -import com.google.inject.Provides; -import org.matsim.api.core.v01.Id; -import org.matsim.pt.transitSchedule.api.TransitLine; -import org.matsim.pt.transitSchedule.api.TransitRoute; -import org.matsim.pt.transitSchedule.api.TransitStopFacility; - - -public interface WaitTimeCalculator extends Provider { - double getRouteStopWaitTime(Id lineId, Id routeId, Id stopId, double time); - - @Override - @Provides - WaitTime get(); -} diff --git a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/waitTimes/WaitTimeCalculatorImpl.java b/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/waitTimes/WaitTimeCalculatorImpl.java deleted file mode 100644 index ed80d814c81..00000000000 --- a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/waitTimes/WaitTimeCalculatorImpl.java +++ /dev/null @@ -1,181 +0,0 @@ -/* *********************************************************************** * - * project: org.matsim.* - * WaitTimeCalculator.java - * * - * *********************************************************************** * - * * - * copyright : (C) 2012 by the members listed in the COPYING, * - * LICENSE and WARRANTY file. * - * email : info at matsim dot org * - * * - * *********************************************************************** * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * See also COPYING, LICENSE and WARRANTY file * - * * - * *********************************************************************** */ - -package org.matsim.contrib.eventsBasedPTRouter.waitTimes; - -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; - -import org.matsim.api.core.v01.Id; -import org.matsim.api.core.v01.events.PersonDepartureEvent; -import org.matsim.api.core.v01.events.PersonEntersVehicleEvent; -import org.matsim.api.core.v01.events.TransitDriverStartsEvent; -import org.matsim.api.core.v01.events.handler.PersonDepartureEventHandler; -import org.matsim.api.core.v01.events.handler.PersonEntersVehicleEventHandler; -import org.matsim.api.core.v01.events.handler.TransitDriverStartsEventHandler; -import org.matsim.api.core.v01.population.Person; -import org.matsim.core.api.experimental.events.EventsManager; -import org.matsim.core.api.experimental.events.VehicleArrivesAtFacilityEvent; -import org.matsim.core.api.experimental.events.handler.VehicleArrivesAtFacilityEventHandler; -import org.matsim.core.config.Config; -import org.matsim.core.trafficmonitoring.TimeBinUtils; -import org.matsim.core.utils.collections.Tuple; -import org.matsim.pt.transitSchedule.api.Departure; -import org.matsim.pt.transitSchedule.api.TransitLine; -import org.matsim.pt.transitSchedule.api.TransitRoute; -import org.matsim.pt.transitSchedule.api.TransitRouteStop; -import org.matsim.pt.transitSchedule.api.TransitSchedule; -import org.matsim.pt.transitSchedule.api.TransitStopFacility; -import org.matsim.vehicles.Vehicle; - -import com.google.inject.Inject; -import com.google.inject.Provider; -import com.google.inject.Singleton; - -/** - * Save waiting times of agents while mobsim is running - * - * @author sergioo - */ - -@Singleton -public class WaitTimeCalculatorImpl implements WaitTimeCalculator, PersonDepartureEventHandler, PersonEntersVehicleEventHandler, TransitDriverStartsEventHandler, VehicleArrivesAtFacilityEventHandler, Provider { - - //Attributes - private final double timeSlot; - private final int totalTime; - private final Map, Id>, Map, WaitTimeData>> waitTimes = new HashMap, Id>, Map, WaitTimeData>>(1000); - private final Map, Id>, Map, double[]>> scheduledWaitTimes = new HashMap, Id>, Map, double[]>>(1000); - private final Map, Double> agentsWaitingData = new HashMap, Double>(); - private Map, Tuple, Id>> linesRoutesOfVehicle = new HashMap, Tuple, Id>>(); - private Map, Id> stopOfVehicle = new HashMap, Id>(); - - //Constructors - @Inject - public WaitTimeCalculatorImpl(final TransitSchedule transitSchedule, final Config config, EventsManager eventsManager) { - this(transitSchedule, config.travelTimeCalculator().getTraveltimeBinSize(), (int) (config.qsim().getEndTime().seconds()-config.qsim().getStartTime().seconds())); - eventsManager.addHandler(this); - } - public WaitTimeCalculatorImpl(final TransitSchedule transitSchedule, final double timeSlot, final int totalTime) { - this.timeSlot = timeSlot; - this.totalTime = totalTime; - for(TransitLine line:transitSchedule.getTransitLines().values()) - for(TransitRoute route:line.getRoutes().values()) { - double[] sortedDepartures = new double[route.getDepartures().size()]; - int d=0; - for(Departure departure:route.getDepartures().values()) - sortedDepartures[d++] = departure.getDepartureTime(); - Arrays.sort(sortedDepartures); - Map, WaitTimeData> stopsMap = new HashMap, WaitTimeData>(100); - Map, double[]> stopsScheduledMap = new HashMap, double[]>(100); - for(TransitRouteStop stop:route.getStops()) { - stopsMap.put(stop.getStopFacility().getId(), new WaitTimeDataArray(TimeBinUtils.getTimeBinCount(totalTime, timeSlot))); - double[] cacheWaitTimes = new double[TimeBinUtils.getTimeBinCount(totalTime, timeSlot)]; - for(int i=0; i24*3600) - endTime-=24*3600; - cacheWaitTimes[i] = Double.NaN; - SORTED_DEPARTURES: - for(double departure:sortedDepartures) { - double arrivalTime = departure+stop.getArrivalOffset().or(stop::getDepartureOffset).seconds(); - if(arrivalTime>=endTime) { - cacheWaitTimes[i] = arrivalTime-endTime; - break SORTED_DEPARTURES; - } - } - if(Double.isNaN(cacheWaitTimes[i])) - cacheWaitTimes[i] = sortedDepartures[0]+24*3600+stop.getArrivalOffset().or(stop::getDepartureOffset).seconds()-endTime; - } - stopsScheduledMap.put(stop.getStopFacility().getId(), cacheWaitTimes); - } - Tuple, Id> key = new Tuple, Id>(line.getId(), route.getId()); - waitTimes.put(key, stopsMap); - scheduledWaitTimes.put(key, stopsScheduledMap); - } - } - - //Methods - @Override - public WaitTime get() { - return new WaitTime() { - /** - * - */ - private static final long serialVersionUID = 1L; - - @Override - public double getRouteStopWaitTime(Id lineId, Id routeId, Id stopId, double time) { - return WaitTimeCalculatorImpl.this.getRouteStopWaitTime(lineId, routeId, stopId, time); - } - }; - } - @Override - public double getRouteStopWaitTime(Id lineId, Id routeId, Id stopId, double time) { - Tuple, Id> key = new Tuple, Id>(lineId, routeId); - WaitTimeData waitTimeData = waitTimes.get(key).get(stopId); - int timeBinIndex = TimeBinUtils.getTimeBinIndex(time, timeSlot, TimeBinUtils.getTimeBinCount(totalTime, timeSlot)); - if(waitTimeData.getNumData(timeBinIndex)==0) { - double[] waitTimes = scheduledWaitTimes.get(key).get(stopId); - return waitTimes[timeBinIndex, WaitTimeData> routeData:waitTimes.values()) - for(WaitTimeData waitTimeData:routeData.values()) - waitTimeData.resetWaitTimes(); - agentsWaitingData.clear(); - linesRoutesOfVehicle.clear(); - stopOfVehicle.clear(); - } - @Override - public void handleEvent(PersonDepartureEvent event) { - if(event.getLegMode().equals("pt") && agentsWaitingData.get(event.getPersonId())==null) - agentsWaitingData.put(event.getPersonId(), event.getTime()); - else if(agentsWaitingData.get(event.getPersonId())!=null) - new RuntimeException("Departing with old data"); - } - @Override - public void handleEvent(PersonEntersVehicleEvent event) { - Double startWaitingTime = agentsWaitingData.get(event.getPersonId()); - if(startWaitingTime!=null) { - Tuple, Id> lineRoute = linesRoutesOfVehicle.get(event.getVehicleId()); - WaitTimeData data = waitTimes.get(lineRoute).get(stopOfVehicle.get(event.getVehicleId())); - data.addWaitTime((int) (startWaitingTime/timeSlot), event.getTime()-startWaitingTime); - agentsWaitingData.remove(event.getPersonId()); - } - } - - @Override - public void handleEvent(VehicleArrivesAtFacilityEvent event) { - if(linesRoutesOfVehicle.get(event.getVehicleId())!=null) - stopOfVehicle.put(event.getVehicleId(), event.getFacilityId()); - } - - @Override - public void handleEvent(TransitDriverStartsEvent event) { - linesRoutesOfVehicle.put(event.getVehicleId(), new Tuple, Id>(event.getTransitLineId(), event.getTransitRouteId())); - } - -} diff --git a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/waitTimes/WaitTimeCalculatorSerializable.java b/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/waitTimes/WaitTimeCalculatorSerializable.java deleted file mode 100644 index 17a93bd0410..00000000000 --- a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/waitTimes/WaitTimeCalculatorSerializable.java +++ /dev/null @@ -1,216 +0,0 @@ -/* *********************************************************************** * - * project: org.matsim.* - * WaitTimeCalculator.java - * * - * *********************************************************************** * - * * - * copyright : (C) 2012 by the members listed in the COPYING, * - * LICENSE and WARRANTY file. * - * email : info at matsim dot org * - * * - * *********************************************************************** * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * See also COPYING, LICENSE and WARRANTY file * - * * - * *********************************************************************** */ - -package org.matsim.contrib.eventsBasedPTRouter.waitTimes; - -import java.io.Serializable; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; - -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.events.PersonDepartureEvent; -import org.matsim.api.core.v01.events.PersonEntersVehicleEvent; -import org.matsim.api.core.v01.events.TransitDriverStartsEvent; -import org.matsim.api.core.v01.events.handler.PersonDepartureEventHandler; -import org.matsim.api.core.v01.events.handler.PersonEntersVehicleEventHandler; -import org.matsim.api.core.v01.events.handler.TransitDriverStartsEventHandler; -import org.matsim.core.api.experimental.events.VehicleArrivesAtFacilityEvent; -import org.matsim.core.api.experimental.events.handler.VehicleArrivesAtFacilityEventHandler; -import org.matsim.core.config.Config; -import org.matsim.core.trafficmonitoring.TimeBinUtils; -import org.matsim.core.utils.collections.Tuple; -import org.matsim.pt.transitSchedule.api.Departure; -import org.matsim.pt.transitSchedule.api.TransitLine; -import org.matsim.pt.transitSchedule.api.TransitRoute; -import org.matsim.pt.transitSchedule.api.TransitRouteStop; -import org.matsim.pt.transitSchedule.api.TransitSchedule; -import org.matsim.pt.transitSchedule.api.TransitStopFacility; - -import com.google.inject.Provider; -import com.google.inject.Provides; - -/** - * Save waiting times of agents while mobsim is running - * - * @author sergioo - */ - -public class WaitTimeCalculatorSerializable implements - WaitTimeCalculator, PersonDepartureEventHandler, - PersonEntersVehicleEventHandler, TransitDriverStartsEventHandler, - VehicleArrivesAtFacilityEventHandler, Serializable, - Provider { - - /** - * - */ - private static final long serialVersionUID = 1L; - private static int scheduleCalls; - private static int waitTimeCalls; - //Attributes - private final double timeSlot; - private final int totalTime; - private final Map, Map> waitTimes = new HashMap, Map>(1000); - private final Map, Map> scheduledWaitTimes = new HashMap, Map>(1000); - private final Map agentsWaitingData = new HashMap(); - private Map> linesRoutesOfVehicle = new HashMap>(); - private Map stopOfVehicle = new HashMap(); - - public static void printCallStatisticsAndReset() { - Logger logger = LogManager.getLogger(WaitTimeCalculatorSerializable.class); - logger.warn("scheduled wait time calls vs unscheduled: " + scheduleCalls + " : " + waitTimeCalls); - scheduleCalls = 0; - waitTimeCalls = 0; - } - - //Constructors - public WaitTimeCalculatorSerializable(final TransitSchedule transitSchedule, final Config config) { - this(transitSchedule, config.travelTimeCalculator().getTraveltimeBinSize(), (int) (config.qsim().getEndTime().seconds() - config.qsim().getStartTime().seconds())); - } - - public WaitTimeCalculatorSerializable(final TransitSchedule transitSchedule, final double timeSlot, final int totalTime) { - this.timeSlot = timeSlot; - this.totalTime = totalTime; - for (TransitLine line : transitSchedule.getTransitLines().values()) - for (TransitRoute route : line.getRoutes().values()) { - double[] sortedDepartures = new double[route.getDepartures().size()]; - int d = 0; - for (Departure departure : route.getDepartures().values()) - sortedDepartures[d++] = departure.getDepartureTime(); - Arrays.sort(sortedDepartures); - Map stopsMap = new HashMap(100); - Map stopsScheduledMap = new HashMap(100); - for (TransitRouteStop stop : route.getStops()) { - stopsMap.put(stop.getStopFacility().getId().toString(), new WaitTimeDataArray(TimeBinUtils.getTimeBinCount(totalTime , timeSlot))); - double[] cacheWaitTimes = new double[TimeBinUtils.getTimeBinCount(totalTime , timeSlot)]; - for (int i = 0; i < cacheWaitTimes.length; i++) { - double endTime = timeSlot * (i + 1); - if (endTime > 24 * 3600) - endTime -= 24 * 3600; - cacheWaitTimes[i] = Double.NaN; - SORTED_DEPARTURES: - for (double departure : sortedDepartures) { - double arrivalTime = departure + stop.getArrivalOffset().or(stop::getDepartureOffset).seconds(); - if (arrivalTime >= endTime) { - cacheWaitTimes[i] = arrivalTime - endTime; - break SORTED_DEPARTURES; - } - } - if (Double.isNaN(cacheWaitTimes[i])) - cacheWaitTimes[i] = sortedDepartures[0] + 24 * 3600 + stop.getArrivalOffset().or(stop::getDepartureOffset).seconds() - endTime; - } - stopsScheduledMap.put(stop.getStopFacility().getId().toString(), cacheWaitTimes); - } - Tuple key = new Tuple(line.getId().toString(), route.getId().toString()); - waitTimes.put(key, stopsMap); - scheduledWaitTimes.put(key, stopsScheduledMap); - } - } - - //Methods - public WaitTime getWaitTimes() { - return new WaitTime() { - /** - * - */ - private static final long serialVersionUID = 1L; - - @Override - public double getRouteStopWaitTime(Id lineId, Id routeId, Id stopId, double time) { - return WaitTimeCalculatorSerializable.this.getRouteStopWaitTime(lineId, routeId, stopId, time); - } - }; - } - - @Override - public double getRouteStopWaitTime(Id lineId, Id routeId, Id stopId, double time) { - Tuple key = new Tuple(lineId.toString(), routeId.toString()); - waitTimeCalls++; - WaitTimeData waitTimeData = waitTimes.get(key).get(stopId.toString()); - int timeBinIndex = TimeBinUtils.getTimeBinIndex(time, timeSlot, TimeBinUtils.getTimeBinCount(totalTime, timeSlot)); - if (waitTimeData.getNumData(timeBinIndex) == 0) { - scheduleCalls++; - double[] waitTimes = scheduledWaitTimes.get(key).get(stopId.toString()); - return waitTimes[timeBinIndex < waitTimes.length ? timeBinIndex : (waitTimes.length - 1)]; - } else { - return waitTimeData.getWaitTime(timeBinIndex); - } - } - - @Override - public void reset(int iteration) { - for (Map routeData : waitTimes.values()) - for (WaitTimeData waitTimeData : routeData.values()) - waitTimeData.resetWaitTimes(); - agentsWaitingData.clear(); - linesRoutesOfVehicle.clear(); - stopOfVehicle.clear(); - } - - @Override - public void handleEvent(PersonDepartureEvent event) { - if (event.getLegMode().equals("pt") && agentsWaitingData.get(event.getPersonId().toString()) == null) - agentsWaitingData.put(event.getPersonId().toString(), event.getTime()); - else if (agentsWaitingData.get(event.getPersonId().toString()) != null) - new RuntimeException("Departing with old data"); - } - - @Override - public void handleEvent(PersonEntersVehicleEvent event) { - Double startWaitingTime = agentsWaitingData.get(event.getPersonId().toString()); - if (startWaitingTime != null) { - Tuple lineRoute = linesRoutesOfVehicle.get(event.getVehicleId().toString()); - WaitTimeData data = waitTimes.get(lineRoute).get(stopOfVehicle.get(event.getVehicleId().toString())); - data.addWaitTime(TimeBinUtils.getTimeBinIndex(startWaitingTime, timeSlot, TimeBinUtils.getTimeBinCount(totalTime, timeSlot)), - event.getTime() - startWaitingTime); - agentsWaitingData.remove(event.getPersonId().toString()); - } - } - - @Override - public void handleEvent(VehicleArrivesAtFacilityEvent event) { - if (linesRoutesOfVehicle.get(event.getVehicleId().toString()) != null) - stopOfVehicle.put(event.getVehicleId().toString(), event.getFacilityId().toString()); - } - - @Override - public void handleEvent(TransitDriverStartsEvent event) { - linesRoutesOfVehicle.put(event.getVehicleId().toString(), new Tuple(event.getTransitLineId().toString(), event.getTransitRouteId().toString())); - } - - @Override - @Provides - public WaitTime get() { - return new WaitTime() { - /** - * - */ - private static final long serialVersionUID = 1L; - - @Override - public double getRouteStopWaitTime(Id lineId, Id routeId, Id stopId, double time) { - return WaitTimeCalculatorSerializable.this.getRouteStopWaitTime(lineId, routeId, stopId, time); - } - }; - } -} diff --git a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/waitTimes/WaitTimeData.java b/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/waitTimes/WaitTimeData.java deleted file mode 100644 index 645a1a39efd..00000000000 --- a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/waitTimes/WaitTimeData.java +++ /dev/null @@ -1,39 +0,0 @@ -/* *********************************************************************** * - * project: org.matsim.* - * WaitTimeCalculator.java - * * - * *********************************************************************** * - * * - * copyright : (C) 2012 by the members listed in the COPYING, * - * LICENSE and WARRANTY file. * - * email : info at matsim dot org * - * * - * *********************************************************************** * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * See also COPYING, LICENSE and WARRANTY file * - * * - * *********************************************************************** */ - -package org.matsim.contrib.eventsBasedPTRouter.waitTimes; - -import java.io.Serializable; - -/** - * Structure for saving waiting times - * - * @author sergioo - */ - -public interface WaitTimeData extends Serializable { - - //Methods - void resetWaitTimes(); - void addWaitTime(final int timeSlot, final double waitTime); - double getWaitTime(final int timeSlot); - int getNumData(final int timeSlot); - -} diff --git a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/waitTimes/WaitTimeDataArray.java b/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/waitTimes/WaitTimeDataArray.java deleted file mode 100644 index 43064e2f913..00000000000 --- a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/waitTimes/WaitTimeDataArray.java +++ /dev/null @@ -1,67 +0,0 @@ -/* *********************************************************************** * - * project: org.matsim.* - * WaitTimeCalculator.java - * * - * *********************************************************************** * - * * - * copyright : (C) 2012 by the members listed in the COPYING, * - * LICENSE and WARRANTY file. * - * email : info at matsim dot org * - * * - * *********************************************************************** * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * See also COPYING, LICENSE and WARRANTY file * - * * - * *********************************************************************** */ - -package org.matsim.contrib.eventsBasedPTRouter.waitTimes; - -/** - * Array implementation of the structure for saving wait times - * - * @author sergioo - */ - -public class WaitTimeDataArray implements WaitTimeData { - - /** - * - */ - private static final long serialVersionUID = 1L; - //Attributes - private double[] waitTimes; - private int[] numTimes; - - //Constructors - public WaitTimeDataArray(int numSlots) { - waitTimes = new double[numSlots]; - numTimes = new int[numSlots]; - resetWaitTimes(); - } - - //Methods - @Override - public void resetWaitTimes() { - for(int i=0; i, Id>, Map, WaitTimeData>> waitTimes = new HashMap, Id>, Map, WaitTimeData>>(1000); - private final Map, Id>, Map, double[]>> scheduledWaitTimes = new HashMap, Id>, Map, double[]>>(1000); - private final Map, Double> agentsWaitingData = new HashMap, Double>(); - private final Map, Integer> agentsCurrentLeg = new HashMap, Integer>(); - private final Population population; - - //Constructors - @Inject - public WaitTimeStuckCalculator(final Population population, final TransitSchedule transitSchedule, final Config config, final EventsManager eventsManager) { - this(population, transitSchedule, config.travelTimeCalculator().getTraveltimeBinSize(), (int) (config.qsim().getEndTime().seconds()-config.qsim().getStartTime().seconds())); - eventsManager.addHandler(this); - } - public WaitTimeStuckCalculator(final Population population, final TransitSchedule transitSchedule, final double timeSlot, final int totalTime) { - this.population = population; - this.timeSlot = timeSlot; - this.totalTime = totalTime; - for(TransitLine line:transitSchedule.getTransitLines().values()) - for(TransitRoute route:line.getRoutes().values()) { - double[] sortedDepartures = new double[route.getDepartures().size()]; - int d=0; - for(Departure departure:route.getDepartures().values()) - sortedDepartures[d++] = departure.getDepartureTime(); - Arrays.sort(sortedDepartures); - Map, WaitTimeData> stopsMap = new HashMap, WaitTimeData>(100); - Map, double[]> stopsScheduledMap = new HashMap, double[]>(100); - for(TransitRouteStop stop:route.getStops()) { - stopsMap.put(stop.getStopFacility().getId(), new WaitTimeDataArray(TimeBinUtils.getTimeBinCount(totalTime, timeSlot))); - double[] cacheWaitTimes = new double[TimeBinUtils.getTimeBinCount(totalTime, timeSlot)]; - for(int i=0; i24*3600) - endTime-=24*3600; - cacheWaitTimes[i] = Double.NaN; - SORTED_DEPARTURES: - for(double departure:sortedDepartures) { - double arrivalTime = departure+stop.getArrivalOffset().or(stop::getDepartureOffset).seconds(); - if(arrivalTime>=endTime) { - cacheWaitTimes[i] = arrivalTime-endTime; - break SORTED_DEPARTURES; - } - } - if(Double.isNaN(cacheWaitTimes[i])) - cacheWaitTimes[i] = sortedDepartures[0]+24*3600+stop.getArrivalOffset().or(stop::getDepartureOffset).seconds()-endTime; - } - stopsScheduledMap.put(stop.getStopFacility().getId(), cacheWaitTimes); - } - Tuple, Id> key = new Tuple, Id>(line.getId(), route.getId()); - waitTimes.put(key, stopsMap); - scheduledWaitTimes.put(key, stopsScheduledMap); - } - } - - //Methods - public double getRouteStopWaitTime(Id lineId, Id routeId, Id stopId, double time) { - Tuple, Id> key = new Tuple, Id>(lineId, routeId); - WaitTimeData waitTimeData = waitTimes.get(key).get(stopId); - int timeBinIndex = TimeBinUtils.getTimeBinIndex(time, timeSlot, TimeBinUtils.getTimeBinCount(totalTime, timeSlot)); - if(waitTimeData.getNumData(timeBinIndex)==0) { - double[] waitTimes = scheduledWaitTimes.get(key).get(stopId); - return waitTimes[timeBinIndex, WaitTimeData> routeData:waitTimes.values()) - for(WaitTimeData waitTimeData:routeData.values()) - waitTimeData.resetWaitTimes(); - agentsWaitingData.clear(); - agentsCurrentLeg.clear(); - } - @Override - public void handleEvent(PersonDepartureEvent event) { - Integer currentLeg = agentsCurrentLeg.get(event.getPersonId()); - if(currentLeg == null) - currentLeg = 0; - else - currentLeg++; - agentsCurrentLeg.put(event.getPersonId(), currentLeg); - if(event.getLegMode().equals("pt") && agentsWaitingData.get(event.getPersonId())==null) - agentsWaitingData.put(event.getPersonId(), event.getTime()); - else if(agentsWaitingData.get(event.getPersonId())!=null) - new RuntimeException("Departing with old data"); - } - @Override - public void handleEvent(PersonEntersVehicleEvent event) { - Double startWaitingTime = agentsWaitingData.get(event.getPersonId()); - if(startWaitingTime!=null) { - int legs = 0, currentLeg = agentsCurrentLeg.get(event.getPersonId()); - PLAN_ELEMENTS: - for(PlanElement planElement:population.getPersons().get(event.getPersonId()).getSelectedPlan().getPlanElements()) - if(planElement instanceof Leg) { - if(currentLeg==legs) { - Route route = (((Leg)planElement).getRoute()); - TransitPassengerRoute eRoute = (TransitPassengerRoute) new DefaultTransitPassengerRouteFactory(). - createRoute(route.getStartLinkId(), route.getEndLinkId()); - eRoute.setStartLinkId(route.getStartLinkId()); - eRoute.setEndLinkId(route.getEndLinkId()); - eRoute.setRouteDescription(route.getRouteDescription()); - WaitTimeData data = waitTimes.get(new Tuple, Id>(eRoute.getLineId(), - eRoute.getRouteId())).get(eRoute.getAccessStopId()); - data.addWaitTime(TimeBinUtils.getTimeBinIndex(startWaitingTime, timeSlot, totalTime), event.getTime()-startWaitingTime); - agentsWaitingData.remove(event.getPersonId()); - break PLAN_ELEMENTS; - } - else - legs++; - } - } - } - - @Override - public void handleEvent(PersonStuckEvent event) { - Double startWaitingTime = agentsWaitingData.get(event.getPersonId()); - if(startWaitingTime!=null) { - int legs = 0, currentLeg = agentsCurrentLeg.get(event.getPersonId()); - PLAN_ELEMENTS: - for(PlanElement planElement:population.getPersons().get(event.getPersonId()).getSelectedPlan().getPlanElements()) - if(planElement instanceof Leg) { - if(currentLeg==legs) { - Route route = ((Leg)planElement).getRoute(); - TransitPassengerRoute eRoute = (TransitPassengerRoute) new DefaultTransitPassengerRouteFactory(). - createRoute(route.getStartLinkId(), route.getEndLinkId()); - eRoute.setStartLinkId(route.getStartLinkId()); - eRoute.setEndLinkId(route.getEndLinkId()); - eRoute.setRouteDescription(route.getRouteDescription()); - WaitTimeData data = waitTimes.get(new Tuple, Id>(eRoute.getLineId(), - eRoute.getRouteId())).get(eRoute.getAccessStopId()); - if(data!=null) - data.addWaitTime(TimeBinUtils.getTimeBinIndex(startWaitingTime, timeSlot, totalTime), event.getTime()-startWaitingTime); - agentsWaitingData.remove(event.getPersonId()); - break PLAN_ELEMENTS; - } - else - legs++; - } - } - } - - @Override - public WaitTime get() { - return new WaitTime() { - - /** - * - */ - private static final long serialVersionUID = 1L; - - @Override - public double getRouteStopWaitTime(Id lineId, Id routeId, Id stopId, double time) { - return WaitTimeStuckCalculator.this.getRouteStopWaitTime(lineId, routeId, stopId, time); - } - - }; - } -} - diff --git a/contribs/eventsBasedPTRouter/src/test/java/org/matsim/contrib/eventsBasedPTRouter/MultiNodeDijkstraTest.java b/contribs/eventsBasedPTRouter/src/test/java/org/matsim/contrib/eventsBasedPTRouter/MultiNodeDijkstraTest.java deleted file mode 100644 index 96574ed0d84..00000000000 --- a/contribs/eventsBasedPTRouter/src/test/java/org/matsim/contrib/eventsBasedPTRouter/MultiNodeDijkstraTest.java +++ /dev/null @@ -1,495 +0,0 @@ -/* *********************************************************************** * - * project: org.matsim.* - * TransitDijkstraTest.java - * * - * *********************************************************************** * - * * - * copyright : (C) 2009 by the members listed in the COPYING, * - * LICENSE and WARRANTY file. * - * email : info at matsim dot org * - * * - * *********************************************************************** * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * See also COPYING, LICENSE and WARRANTY file * - * * - * *********************************************************************** */ - -package org.matsim.contrib.eventsBasedPTRouter; - -import static org.junit.Assert.*; - -import java.util.HashMap; -import java.util.Map; - -import org.junit.Test; -import org.matsim.api.core.v01.Coord; -import org.matsim.api.core.v01.Id; -import org.matsim.api.core.v01.network.Link; -import org.matsim.api.core.v01.network.Network; -import org.matsim.api.core.v01.network.Node; -import org.matsim.api.core.v01.population.Person; -import org.matsim.core.network.NetworkUtils; -import org.matsim.core.router.InitialNode; -import org.matsim.core.router.util.LeastCostPathCalculator.Path; -import org.matsim.core.router.util.TravelTime; -import org.matsim.pt.router.CustomDataManager; -import org.matsim.pt.router.TransitTravelDisutility; -import org.matsim.vehicles.Vehicle; - -/** - * @author mrieser - */ -public class MultiNodeDijkstraTest { - - @Test public void testMultipleStarts() { - Fixture f = new Fixture(); - TestTimeCost tc = new TestTimeCost(); - tc.setData(Id.create(1, Link.class), 2.0, 2.0); - tc.setData(Id.create(2, Link.class), 1.0, 1.0); - tc.setData(Id.create(3, Link.class), 3.0, 3.0); - tc.setData(Id.create(4, Link.class), 2.0, 2.0); - tc.setData(Id.create(5, Link.class), 1.0, 1.0); - tc.setData(Id.create(6, Link.class), 3.0, 3.0); - tc.setData(Id.create(7, Link.class), 4.0, 4.0); - MultiNodeDijkstra dijkstra = new MultiNodeDijkstra(f.network, tc, tc); - Map fromNodes = new HashMap(); - fromNodes.put(f.network.getNodes().get(Id.create(1, Node.class)), new InitialNode(1.0, 1.0)); - fromNodes.put(f.network.getNodes().get(Id.create(2, Node.class)), new InitialNode(3.0, 3.0)); - fromNodes.put(f.network.getNodes().get(Id.create(3, Node.class)), new InitialNode(2.0, 2.0)); - Map toNodes = new HashMap(); - toNodes.put(f.network.getNodes().get(Id.create(5, Node.class)), new InitialNode(0.0, 0.0)); - - Path p = dijkstra.calcLeastCostPath(fromNodes, toNodes, null); - assertNotNull("no path found!", p); - assertEquals(3, p.links.size()); - assertEquals("1", p.links.get(0).getId().toString()); - assertEquals("7", p.links.get(1).getId().toString()); - assertEquals("5", p.links.get(2).getId().toString()); - - // change costs - tc.setData(Id.create(1, Link.class), 2.0, 5.0); - - p = dijkstra.calcLeastCostPath(fromNodes, toNodes, null); - assertNotNull("no path found!", p); - assertEquals(3, p.links.size()); - assertEquals("2", p.links.get(0).getId().toString()); - assertEquals("7", p.links.get(1).getId().toString()); - assertEquals("5", p.links.get(2).getId().toString()); - - // change costs again - tc.setData(Id.create(1, Link.class), 2.0, 1.0); - - p = dijkstra.calcLeastCostPath(fromNodes, toNodes, null); - assertNotNull("no path found!", p); - assertEquals(3, p.links.size()); - assertEquals("1", p.links.get(0).getId().toString()); - assertEquals("7", p.links.get(1).getId().toString()); - assertEquals("5", p.links.get(2).getId().toString()); - } - - @Test public void testMultipleEnds() { - Fixture f = new Fixture(); - TestTimeCost tc = new TestTimeCost(); - tc.setData(Id.create(1, Link.class), 2.0, 2.0); - tc.setData(Id.create(2, Link.class), 1.0, 1.0); - tc.setData(Id.create(3, Link.class), 3.0, 3.0); - tc.setData(Id.create(4, Link.class), 4.0, 4.0); - tc.setData(Id.create(5, Link.class), 3.0, 3.0); - tc.setData(Id.create(6, Link.class), 7.0, 7.0); - tc.setData(Id.create(7, Link.class), 4.0, 4.0); - MultiNodeDijkstra dijkstra = new MultiNodeDijkstra(f.network, tc, tc); - Map fromNodes = new HashMap(); - fromNodes.put(f.network.getNodes().get(Id.create(2, Node.class)), new InitialNode(0.0, 0.0)); - Map toNodes = new HashMap(); - toNodes.put(f.network.getNodes().get(Id.create(4, Node.class)), new InitialNode(5.0, 5.0)); - toNodes.put(f.network.getNodes().get(Id.create(5, Node.class)), new InitialNode(4.0, 4.0)); - toNodes.put(f.network.getNodes().get(Id.create(6, Node.class)), new InitialNode(1.0, 1.0)); - - Path p = dijkstra.calcLeastCostPath(fromNodes, toNodes, null); - assertNotNull("no path found!", p); - assertEquals(3, p.links.size()); - assertEquals("2", p.links.get(0).getId().toString()); - assertEquals("7", p.links.get(1).getId().toString()); - assertEquals("5", p.links.get(2).getId().toString()); - - // change costs - tc.setData(Id.create(4, Link.class), 3.0, 1.0); - - p = dijkstra.calcLeastCostPath(fromNodes, toNodes, null); - assertNotNull("no path found!", p); - assertEquals(3, p.links.size()); - assertEquals("2", p.links.get(0).getId().toString()); - assertEquals("7", p.links.get(1).getId().toString()); - assertEquals("4", p.links.get(2).getId().toString()); - - // change costs again - tc.setData(Id.create(6, Link.class), 7.0, 3.0); - - p = dijkstra.calcLeastCostPath(fromNodes, toNodes, null); - assertNotNull("no path found!", p); - assertEquals(3, p.links.size()); - assertEquals("2", p.links.get(0).getId().toString()); - assertEquals("7", p.links.get(1).getId().toString()); - assertEquals("6", p.links.get(2).getId().toString()); - } - - @Test public void testMultipleStartsAndEnds() { - Fixture f = new Fixture(); - TestTimeCost tc = new TestTimeCost(); - tc.setData(Id.create(1, Link.class), 2.0, 2.0); - tc.setData(Id.create(2, Link.class), 1.0, 1.0); - tc.setData(Id.create(3, Link.class), 3.0, 3.0); - tc.setData(Id.create(4, Link.class), 4.0, 4.0); - tc.setData(Id.create(5, Link.class), 3.0, 3.0); - tc.setData(Id.create(6, Link.class), 7.0, 7.0); - tc.setData(Id.create(7, Link.class), 4.0, 4.0); - MultiNodeDijkstra dijkstra = new MultiNodeDijkstra(f.network, tc, tc); - Map fromNodes = new HashMap(); - fromNodes.put(f.network.getNodes().get(Id.create(2, Node.class)), new InitialNode(4.0, 4.0)); - fromNodes.put(f.network.getNodes().get(Id.create(3, Node.class)), new InitialNode(3.0, 3.0)); - Map toNodes = new HashMap(); - toNodes.put(f.network.getNodes().get(Id.create(4, Node.class)), new InitialNode(5.0, 5.0)); - toNodes.put(f.network.getNodes().get(Id.create(5, Node.class)), new InitialNode(4.0, 4.0)); - toNodes.put(f.network.getNodes().get(Id.create(6, Node.class)), new InitialNode(1.0, 1.0)); - - Path p = dijkstra.calcLeastCostPath(fromNodes, toNodes, null); - assertNotNull("no path found!", p); - assertEquals(3, p.links.size()); - assertEquals("2", p.links.get(0).getId().toString()); - assertEquals("7", p.links.get(1).getId().toString()); - assertEquals("5", p.links.get(2).getId().toString()); - - // change costs - tc.setData(Id.create(3, Link.class), 3.0, 1.0); - tc.setData(Id.create(4, Link.class), 3.0, 1.0); - - p = dijkstra.calcLeastCostPath(fromNodes, toNodes, null); - assertNotNull("no path found!", p); - assertEquals(3, p.links.size()); - assertEquals("3", p.links.get(0).getId().toString()); - assertEquals("7", p.links.get(1).getId().toString()); - assertEquals("4", p.links.get(2).getId().toString()); - - // change costs again - tc.setData(Id.create(3, Link.class), 3.0, 4.0); - tc.setData(Id.create(6, Link.class), 7.0, 3.0); - - p = dijkstra.calcLeastCostPath(fromNodes, toNodes, null); - assertNotNull("no path found!", p); - assertEquals(3, p.links.size()); - assertEquals("2", p.links.get(0).getId().toString()); - assertEquals("7", p.links.get(1).getId().toString()); - assertEquals("6", p.links.get(2).getId().toString()); - } - - /** - * Both nodes 1 and 4 are part of the start set. Even if the path from 1 to the - * target leads over node 4, it may be faster, due to the intial cost values. - * Test that the route does not cut at node 4 as the first node backwards from - * the start set. - */ - @Test public void testStartViaFaster() { - Fixture f = new Fixture(); - TestTimeCost tc = new TestTimeCost(); - tc.setData(Id.create(1, Link.class), 2.0, 2.0); - tc.setData(Id.create(2, Link.class), 1.0, 1.0); - tc.setData(Id.create(3, Link.class), 3.0, 3.0); - tc.setData(Id.create(4, Link.class), 2.0, 2.0); - tc.setData(Id.create(5, Link.class), 1.0, 1.0); - tc.setData(Id.create(6, Link.class), 3.0, 3.0); - tc.setData(Id.create(7, Link.class), 4.0, 4.0); - MultiNodeDijkstra dijkstra = new MultiNodeDijkstra(f.network, tc, tc); - Map fromNodes = new HashMap(); - fromNodes.put(f.network.getNodes().get(Id.create(1, Node.class)), new InitialNode(1.0, 1.0)); - fromNodes.put(f.network.getNodes().get(Id.create(4, Node.class)), new InitialNode(4.0, 4.0)); - Map toNodes = new HashMap(); - toNodes.put(f.network.getNodes().get(Id.create(5, Node.class)), new InitialNode(0.0, 0.0)); - - Path p = dijkstra.calcLeastCostPath(fromNodes, toNodes, null); - assertNotNull("no path found!", p); - assertEquals(3, p.links.size()); - assertEquals("1", p.links.get(0).getId().toString()); - assertEquals("7", p.links.get(1).getId().toString()); - assertEquals("5", p.links.get(2).getId().toString()); - } - - @Test public void testEndViaFaster() { - Fixture f = new Fixture(); - TestTimeCost tc = new TestTimeCost(); - tc.setData(Id.create(1, Link.class), 2.0, 2.0); - tc.setData(Id.create(2, Link.class), 1.0, 1.0); - tc.setData(Id.create(3, Link.class), 3.0, 3.0); - tc.setData(Id.create(4, Link.class), 2.0, 2.0); - tc.setData(Id.create(5, Link.class), 1.0, 1.0); - tc.setData(Id.create(6, Link.class), 3.0, 3.0); - tc.setData(Id.create(7, Link.class), 4.0, 4.0); - MultiNodeDijkstra dijkstra = new MultiNodeDijkstra(f.network, tc, tc); - Map fromNodes = new HashMap(); - fromNodes.put(f.network.getNodes().get(Id.create(2, Node.class)), new InitialNode(1.0, 1.0)); - Map toNodes = new HashMap(); - toNodes.put(f.network.getNodes().get(Id.create(8, Node.class)), new InitialNode(3.0, 3.0)); - toNodes.put(f.network.getNodes().get(Id.create(5, Node.class)), new InitialNode(1.0, 1.0)); - - Path p = dijkstra.calcLeastCostPath(fromNodes, toNodes, null); - assertNotNull("no path found!", p); - assertEquals(3, p.links.size()); - assertEquals("2", p.links.get(0).getId().toString()); - assertEquals("7", p.links.get(1).getId().toString()); - assertEquals("5", p.links.get(2).getId().toString()); - } - - @Test public void testOnlyFromToSameNode() { - Fixture f = new Fixture(); - TestTimeCost tc = new TestTimeCost(); - tc.setData(Id.create(1, Link.class), 2.0, 2.0); - tc.setData(Id.create(2, Link.class), 1.0, 1.0); - tc.setData(Id.create(3, Link.class), 3.0, 3.0); - tc.setData(Id.create(4, Link.class), 2.0, 2.0); - tc.setData(Id.create(5, Link.class), 1.0, 1.0); - tc.setData(Id.create(6, Link.class), 3.0, 3.0); - tc.setData(Id.create(7, Link.class), 4.0, 4.0); - MultiNodeDijkstra dijkstra = new MultiNodeDijkstra(f.network, tc, tc); - Map fromNodes = new HashMap(); - fromNodes.put(f.network.getNodes().get(Id.create(2, Node.class)), new InitialNode(1.0, 1.0)); - Map toNodes = new HashMap(); - toNodes.put(f.network.getNodes().get(Id.create(2, Node.class)), new InitialNode(3.0, 3.0)); - - Path p = dijkstra.calcLeastCostPath(fromNodes, toNodes, null); - assertNotNull("no path found!", p); - assertEquals(0, p.links.size()); - assertEquals(1, p.nodes.size()); - assertEquals("2", p.nodes.get(0).getId().toString()); - } - - /** - * Tests that a path is found if some links are in the set of start - * as well as in the set of end nodes and the path only containing - * of this node is the cheapest. - */ - @Test public void testSameNodeInFromToSetCheapest() { - Fixture f = new Fixture(); - TestTimeCost tc = new TestTimeCost(); - tc.setData(Id.create(1, Link.class), 2.0, 2.0); - tc.setData(Id.create(2, Link.class), 1.0, 1.0); - tc.setData(Id.create(3, Link.class), 3.0, 3.0); - tc.setData(Id.create(4, Link.class), 2.0, 2.0); - tc.setData(Id.create(5, Link.class), 1.0, 1.0); - tc.setData(Id.create(6, Link.class), 3.0, 3.0); - tc.setData(Id.create(7, Link.class), 4.0, 4.0); - MultiNodeDijkstra dijkstra = new MultiNodeDijkstra(f.network, tc, tc); - Map fromNodes = new HashMap(); - fromNodes.put(f.network.getNodes().get(Id.create(2, Node.class)), new InitialNode(2.0, 2.0)); - fromNodes.put(f.network.getNodes().get(Id.create(4, Node.class)), new InitialNode(1.0, 1.0)); - Map toNodes = new HashMap(); - toNodes.put(f.network.getNodes().get(Id.create(4, Node.class)), new InitialNode(1.0, 1.0)); - toNodes.put(f.network.getNodes().get(Id.create(6, Node.class)), new InitialNode(3.0, 3.0)); - - Path p = dijkstra.calcLeastCostPath(fromNodes, toNodes, null); - assertNotNull("no path found!", p); - assertEquals(0, p.links.size()); - assertEquals(1, p.nodes.size()); - assertEquals("4", p.nodes.get(0).getId().toString()); - } - - /** - * Tests that a path is found if some links are in the set of start - * as well as in the set of end nodes, but the path only containing - * of this node is the not the cheapest. - */ - @Test public void testSameNodeInFromToSetNotCheapest() { - Fixture f = new Fixture(); - TestTimeCost tc = new TestTimeCost(); - tc.setData(Id.create(1, Link.class), 2.0, 2.0); - tc.setData(Id.create(2, Link.class), 1.0, 1.0); - tc.setData(Id.create(3, Link.class), 3.0, 3.0); - tc.setData(Id.create(4, Link.class), 2.0, 2.0); - tc.setData(Id.create(5, Link.class), 1.0, 1.0); - tc.setData(Id.create(6, Link.class), 3.0, 3.0); - tc.setData(Id.create(7, Link.class), 4.0, 4.0); - MultiNodeDijkstra dijkstra = new MultiNodeDijkstra(f.network, tc, tc); - Map fromNodes = new HashMap(); - fromNodes.put(f.network.getNodes().get(Id.create(2, Node.class)), new InitialNode(2.0, 2.0)); - fromNodes.put(f.network.getNodes().get(Id.create(4, Node.class)), new InitialNode(10.0, 10.0)); - Map toNodes = new HashMap(); - toNodes.put(f.network.getNodes().get(Id.create(4, Node.class)), new InitialNode(8.0, 8.0)); - toNodes.put(f.network.getNodes().get(Id.create(6, Node.class)), new InitialNode(3.0, 3.0)); - - Path p = dijkstra.calcLeastCostPath(fromNodes, toNodes, null); - assertNotNull("no path found!", p); - assertEquals(3, p.links.size()); - assertEquals("2", p.links.get(0).getId().toString()); - assertEquals("7", p.links.get(1).getId().toString()); - assertEquals("6", p.links.get(2).getId().toString()); - } - - /** - * Tests that a route is found even if not all given end nodes are reachable - */ - @Test public void testSomeEndNodesNotReachable() { - Fixture f = new Fixture(); - TestTimeCost tc = new TestTimeCost(); - tc.setData(Id.create(1, Link.class), 2.0, 2.0); - tc.setData(Id.create(2, Link.class), 1.0, 1.0); - tc.setData(Id.create(3, Link.class), 3.0, 3.0); - tc.setData(Id.create(4, Link.class), 2.0, 2.0); - tc.setData(Id.create(5, Link.class), 1.0, 1.0); - tc.setData(Id.create(6, Link.class), 3.0, 3.0); - tc.setData(Id.create(7, Link.class), 4.0, 4.0); - MultiNodeDijkstra dijkstra = new MultiNodeDijkstra(f.network, tc, tc); - Map fromNodes = new HashMap(); - fromNodes.put(f.network.getNodes().get(Id.create(2, Node.class)), new InitialNode(2.0, 2.0)); - fromNodes.put(f.network.getNodes().get(Id.create(1, Node.class)), new InitialNode(3.0, 3.0)); - Map toNodes = new HashMap(); - toNodes.put(f.network.getNodes().get(Id.create(5, Node.class)), new InitialNode(1.0, 1.0)); - toNodes.put(f.network.getNodes().get(Id.create(3, Node.class)), new InitialNode(3.0, 3.0)); // cannot be reached! - - Path p = dijkstra.calcLeastCostPath(fromNodes, toNodes, null); - assertNotNull("no path found!", p); - assertEquals(3, p.links.size()); - assertEquals("2", p.links.get(0).getId().toString()); - assertEquals("7", p.links.get(1).getId().toString()); - assertEquals("5", p.links.get(2).getId().toString()); - } - - /** - * Tests that a route is found even if not all given start nodes lead to an end node - */ - @Test public void testSomeStartNodesNotUseable() { - Fixture f = new Fixture(); - TestTimeCost tc = new TestTimeCost(); - tc.setData(Id.create(1, Link.class), 2.0, 2.0); - tc.setData(Id.create(2, Link.class), 1.0, 1.0); - tc.setData(Id.create(3, Link.class), 3.0, 3.0); - tc.setData(Id.create(4, Link.class), 2.0, 2.0); - tc.setData(Id.create(5, Link.class), 1.0, 1.0); - tc.setData(Id.create(6, Link.class), 3.0, 3.0); - tc.setData(Id.create(7, Link.class), 4.0, 4.0); - MultiNodeDijkstra dijkstra = new MultiNodeDijkstra(f.network, tc, tc); - Map fromNodes = new HashMap(); - fromNodes.put(f.network.getNodes().get(Id.create(2, Node.class)), new InitialNode(2.0, 2.0)); - fromNodes.put(f.network.getNodes().get(Id.create(4, Node.class)), new InitialNode(3.0, 3.0)); // cannot lead to 5 or 6 - Map toNodes = new HashMap(); - toNodes.put(f.network.getNodes().get(Id.create(5, Node.class)), new InitialNode(1.0, 1.0)); - toNodes.put(f.network.getNodes().get(Id.create(6, Node.class)), new InitialNode(3.0, 3.0)); - - Path p = dijkstra.calcLeastCostPath(fromNodes, toNodes, null); - assertNotNull("no path found!", p); - assertEquals(3, p.links.size()); - assertEquals("2", p.links.get(0).getId().toString()); - assertEquals("7", p.links.get(1).getId().toString()); - assertEquals("5", p.links.get(2).getId().toString()); - } - - @Test public void testImpossibleRoute() { - Fixture f = new Fixture(); - TestTimeCost tc = new TestTimeCost(); - tc.setData(Id.create(1, Link.class), 2.0, 2.0); - tc.setData(Id.create(2, Link.class), 1.0, 1.0); - tc.setData(Id.create(3, Link.class), 3.0, 3.0); - tc.setData(Id.create(4, Link.class), 2.0, 2.0); - tc.setData(Id.create(5, Link.class), 1.0, 1.0); - tc.setData(Id.create(6, Link.class), 3.0, 3.0); - tc.setData(Id.create(7, Link.class), 4.0, 4.0); - MultiNodeDijkstra dijkstra = new MultiNodeDijkstra(f.network, tc, tc); - Map fromNodes = new HashMap(); - fromNodes.put(f.network.getNodes().get(Id.create(1, Node.class)), new InitialNode(1.0, 1.0)); - Map toNodes = new HashMap(); - toNodes.put(f.network.getNodes().get(Id.create(2, Node.class)), new InitialNode(3.0, 3.0)); - - Path p = dijkstra.calcLeastCostPath(fromNodes, toNodes, null); - assertNull("wow, impossible path found!", p); - } - - /** - * Creates a simple network to be used in tests. - * - *
    -	 *   (1)                       (4)
    -	 *      \                     /
    -	 *       \_1               4_/
    -	 *        \                 /
    -	 *   (2)-2-(7)-----7-----(8)-5-(5)
    -	 *        /                 \
    -	 *       /_3               6_\
    -	 *      /                     \
    -	 *   (3)                       (6)
    -	 * 
    - * - * @author mrieser - */ - /*package*/ static class Fixture { - /*package*/ Network network; - - public Fixture() { - this.network = NetworkUtils.createNetwork(); - Node node1 = NetworkUtils.createAndAddNode(this.network, Id.create(1, Node.class), new Coord((double) 1000, (double) 0)); - Node node2 = NetworkUtils.createAndAddNode(this.network, Id.create(2, Node.class), new Coord((double) 500, (double) 0)); - Node node3 = NetworkUtils.createAndAddNode(this.network, Id.create(3, Node.class), new Coord((double) 0, (double) 0)); - Node node4 = NetworkUtils.createAndAddNode(this.network, Id.create(4, Node.class), new Coord((double) 1000, (double) 2000)); - Node node5 = NetworkUtils.createAndAddNode(this.network, Id.create(5, Node.class), new Coord((double) 500, (double) 2000)); - Node node6 = NetworkUtils.createAndAddNode(this.network, Id.create(6, Node.class), new Coord((double) 0, (double) 2000)); - Node node7 = NetworkUtils.createAndAddNode(this.network, Id.create(7, Node.class), new Coord((double) 500, (double) 500)); - Node node8 = NetworkUtils.createAndAddNode(this.network, Id.create(8, Node.class), new Coord((double) 500, (double) 1500)); - final Node fromNode = node1; - final Node toNode = node7; - NetworkUtils.createAndAddLink(this.network,Id.create(1, Link.class), fromNode, toNode, 1000.0, 10.0, 2000.0, (double) 1 ); - final Node fromNode1 = node2; - final Node toNode1 = node7; - NetworkUtils.createAndAddLink(this.network,Id.create(2, Link.class), fromNode1, toNode1, 1000.0, 10.0, 2000.0, (double) 1 ); - final Node fromNode2 = node3; - final Node toNode2 = node7; - NetworkUtils.createAndAddLink(this.network,Id.create(3, Link.class), fromNode2, toNode2, 1000.0, 10.0, 2000.0, (double) 1 ); - final Node fromNode3 = node8; - final Node toNode3 = node4; - NetworkUtils.createAndAddLink(this.network,Id.create(4, Link.class), fromNode3, toNode3, 1000.0, 10.0, 2000.0, (double) 1 ); - final Node fromNode4 = node8; - final Node toNode4 = node5; - NetworkUtils.createAndAddLink(this.network,Id.create(5, Link.class), fromNode4, toNode4, 1000.0, 10.0, 2000.0, (double) 1 ); - final Node fromNode5 = node8; - final Node toNode5 = node6; - NetworkUtils.createAndAddLink(this.network,Id.create(6, Link.class), fromNode5, toNode5, 1000.0, 10.0, 2000.0, (double) 1 ); - final Node fromNode6 = node7; - final Node toNode6 = node8; - NetworkUtils.createAndAddLink(this.network,Id.create(7, Link.class), fromNode6, toNode6, 1000.0, 10.0, 2000.0, (double) 1 ); - } - } - - /*package*/ static class TestTimeCost implements TravelTime, TransitTravelDisutility { - - private final Map, Double> travelTimes = new HashMap<>(); - private final Map, Double> travelCosts = new HashMap<>(); - - public void setData(final Id id, final double travelTime, final double travelCost) { - this.travelTimes.put(id, Double.valueOf(travelTime)); - this.travelCosts.put(id, Double.valueOf(travelCost)); - } - - @Override - public double getLinkTravelTime(final Link link, final double time, Person person, Vehicle vehicle) { - return this.travelTimes.get(link.getId()).doubleValue(); - } - - @Override - public double getLinkTravelDisutility(final Link link, final double time, final Person person, final Vehicle vehicle, final CustomDataManager dataManager) { - return this.travelCosts.get(link.getId()).doubleValue(); - } - - @Override - public double getWalkTravelTime(Person person, Coord coord, Coord toCoord) { - return 0; - } - - @Override - public double getWalkTravelDisutility(Person person, Coord coord, Coord toCoord) { - return 0; - } - - - - } - -} diff --git a/contribs/pom.xml b/contribs/pom.xml index 90f504be8fa..9ffc2dec10e 100644 --- a/contribs/pom.xml +++ b/contribs/pom.xml @@ -74,7 +74,6 @@ dvrp ev emissions - eventsBasedPTRouter freight freightreceiver hybridsim From 2f9363cb29af39651b8c082ab3d5982464381521 Mon Sep 17 00:00:00 2001 From: Kai Nagel Date: Thu, 12 Oct 2023 11:14:33 +0200 Subject: [PATCH 17/25] fix a javadoc --- .../matsim/contrib/parking/package-info.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/contribs/parking/src/main/java/org/matsim/contrib/parking/package-info.java b/contribs/parking/src/main/java/org/matsim/contrib/parking/package-info.java index 8487313fadf..005b83994a3 100644 --- a/contribs/parking/src/main/java/org/matsim/contrib/parking/package-info.java +++ b/contribs/parking/src/main/java/org/matsim/contrib/parking/package-info.java @@ -1,17 +1,20 @@ /** - * The parking contrib is split into three substantially different parts
      + * The parking contrib is split into several substantially different parts
        + * *
      • Parking Choice, based on work of Rashid Waraich. Parts of the contrib are used in the carsharing contrib. - *

        Its main goal, as far as we understand it, is the simulation of parking choice (e.g. between garages). There is no modelling of circulating traffic searching for parking or walking of agents to/from parking. Currently (2022) unmaintained. + *

        Its main goal, as far as we understand it, is the simulation of parking choice (e.g. between garages). + * There is no modelling of circulating traffic searching for parking or walking of agents to/from parking. Currently (2022) unmaintained. * *

      • Parking Search, by Joschka Bischoff. This contrib is currently developed at TU Berlin. *

        The main goal is to model parking search, including walk legs of agents and vehicles searching for parking spaces. - *

      * - *
        Parking Proxy by Tobias Kohl (Senozon) - *

        This was designed for large scenarios where it's not feasable to fully simulate parking agents. Rather, the additional time needed for parking is estimated

        - *
      - * *
        Parking Costs, developed by Marcel Rieser and Joschka Bischoff at SBB. + *
      • Parking Proxy by Tobias Kohl (Senozon) + *

        This was designed for large scenarios where it's not feasable to fully simulate parking agents. + * Rather, the additional time needed for parking is estimated

        + * + *
      • Parking Costs, developed by Marcel Rieser and Joschka Bischoff at SBB. *

        This modules allows the integration of parking costs based on link attribute data.

        + * *
      * * @author of this doc: jfbischoff, nagel From 11c62dec93120da9076b79e1fa5ca6dd7902d85e Mon Sep 17 00:00:00 2001 From: Marcel Rieser Date: Thu, 12 Oct 2023 11:19:34 +0200 Subject: [PATCH 18/25] pseudosim no longer depends on eventsbasedPtRouter --- contribs/pseudosimulation/pom.xml | 5 -- .../ChoiceGenerationControler.java | 52 ++++++------ .../pseudosimulation/PSimDataProvider.java | 8 +- .../contrib/pseudosimulation/RunPSim.java | 23 +++-- .../distributed/MasterControler.java | 24 +++--- .../distributed/SlaveControler.java | 39 +++------ .../pseudosimulation/mobsim/PSimProvider.java | 26 +++--- ...ormanceFromEventBasedRouterInterfaces.java | 22 ++--- .../PSimStopStopTimeCalculator.java | 49 ----------- .../trafficinfo/PSimWaitTimeCalculator.java | 57 ------------- .../DeterministicStopStopTimeCalculator.java | 66 --------------- .../DeterministicWaitTimeCalculator.java | 84 ------------------- .../contrib/pseudosimulation/RunPSimTest.java | 2 +- 13 files changed, 86 insertions(+), 371 deletions(-) delete mode 100644 contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/trafficinfo/PSimStopStopTimeCalculator.java delete mode 100644 contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/trafficinfo/PSimWaitTimeCalculator.java delete mode 100644 contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/trafficinfo/deterministic/DeterministicStopStopTimeCalculator.java delete mode 100644 contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/trafficinfo/deterministic/DeterministicWaitTimeCalculator.java diff --git a/contribs/pseudosimulation/pom.xml b/contribs/pseudosimulation/pom.xml index 3c8e45cc647..56b3b3b9bfc 100644 --- a/contribs/pseudosimulation/pom.xml +++ b/contribs/pseudosimulation/pom.xml @@ -15,11 +15,6 @@ common 16.0-SNAPSHOT - - org.matsim.contrib - events-based-pt-router - 16.0-SNAPSHOT - commons-cli commons-cli diff --git a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/ChoiceGenerationControler.java b/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/ChoiceGenerationControler.java index 00fc950cbcc..f3acb572ce8 100644 --- a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/ChoiceGenerationControler.java +++ b/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/ChoiceGenerationControler.java @@ -6,9 +6,9 @@ import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.population.Person; import org.matsim.api.core.v01.population.Plan; -import org.matsim.contrib.eventsBasedPTRouter.TransitRouterEventsWSFactory; -import org.matsim.contrib.eventsBasedPTRouter.stopStopTimes.StopStopTimeCalculatorImpl; -import org.matsim.contrib.eventsBasedPTRouter.waitTimes.WaitTimeStuckCalculator; +//import org.matsim.contrib.eventsBasedPTRouter.TransitRouterEventsWSFactory; +//import org.matsim.contrib.eventsBasedPTRouter.stopStopTimes.StopStopTimeCalculatorImpl; +//import org.matsim.contrib.eventsBasedPTRouter.waitTimes.WaitTimeStuckCalculator; import org.matsim.contrib.pseudosimulation.mobsim.PSimProvider; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; @@ -34,8 +34,8 @@ */ public class ChoiceGenerationControler implements BeforeMobsimListener{ - final WaitTimeStuckCalculator waitTimeCalculator; - final StopStopTimeCalculatorImpl stopStopTimeCalculator; +// final WaitTimeStuckCalculator waitTimeCalculator; +// final StopStopTimeCalculatorImpl stopStopTimeCalculator; final TravelTimeCalculator travelTimeCalculator; private PSimProvider pSimProvider; Config config; @@ -49,23 +49,23 @@ public ChoiceGenerationControler(String[] args) { scenario = ScenarioUtils.loadScenario(config); controler = new Controler(scenario); - waitTimeCalculator = new WaitTimeStuckCalculator( - controler.getScenario().getPopulation(), - controler.getScenario().getTransitSchedule(), - controler.getConfig().travelTimeCalculator().getTraveltimeBinSize(), - (int) (controler.getConfig().qsim().getEndTime().seconds() - controler.getConfig().qsim().getStartTime().seconds())); - stopStopTimeCalculator = new StopStopTimeCalculatorImpl( - controler.getScenario().getTransitSchedule(), - controler.getConfig().travelTimeCalculator().getTraveltimeBinSize(), - (int) (controler.getConfig().qsim().getEndTime().seconds() - controler.getConfig().qsim().getStartTime().seconds())); - controler.addOverridingModule(new AbstractModule() { - @Override - public void install() { - bind(TransitRouter.class).toProvider(new TransitRouterEventsWSFactory(controler.getScenario(), - waitTimeCalculator.get(), - stopStopTimeCalculator.get())); - } - }); +// waitTimeCalculator = new WaitTimeStuckCalculator( +// controler.getScenario().getPopulation(), +// controler.getScenario().getTransitSchedule(), +// controler.getConfig().travelTimeCalculator().getTraveltimeBinSize(), +// (int) (controler.getConfig().qsim().getEndTime().seconds() - controler.getConfig().qsim().getStartTime().seconds())); +// stopStopTimeCalculator = new StopStopTimeCalculatorImpl( +// controler.getScenario().getTransitSchedule(), +// controler.getConfig().travelTimeCalculator().getTraveltimeBinSize(), +// (int) (controler.getConfig().qsim().getEndTime().seconds() - controler.getConfig().qsim().getStartTime().seconds())); +// controler.addOverridingModule(new AbstractModule() { +// @Override +// public void install() { +// bind(TransitRouter.class).toProvider(new TransitRouterEventsWSFactory(controler.getScenario(), +// waitTimeCalculator.get(), +// stopStopTimeCalculator.get())); +// } +// }); // controler.setScoringFunctionFactory( // new CharyparNagelOpenTimesScoringFunctionFactory(controler.getConfig().planCalcScore(), // controler.getScenario())); @@ -73,8 +73,8 @@ public void install() { EventsManagerImpl eventsManager = new EventsManagerImpl(); EventsReaderXMLv1 reader = new EventsReaderXMLv1(eventsManager); - eventsManager.addHandler(waitTimeCalculator); - eventsManager.addHandler(stopStopTimeCalculator); +// eventsManager.addHandler(waitTimeCalculator); +// eventsManager.addHandler(stopStopTimeCalculator); eventsManager.addHandler(travelTimeCalculator); reader.readFile(args[1]); @@ -106,8 +106,8 @@ public void notifyBeforeMobsim(BeforeMobsimEvent event) { for(Person person:controler.getScenario().getPopulation().getPersons().values()){ plans.add(person.getSelectedPlan()); } - pSimProvider.setWaitTime(waitTimeCalculator.get()); +// pSimProvider.setWaitTime(waitTimeCalculator.get()); pSimProvider.setTravelTime(travelTimeCalculator.getLinkTravelTimes()); - pSimProvider.setStopStopTime(stopStopTimeCalculator.get()); +// pSimProvider.setStopStopTime(stopStopTimeCalculator.get()); } } diff --git a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/PSimDataProvider.java b/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/PSimDataProvider.java index 7c6368c7528..461999c0120 100644 --- a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/PSimDataProvider.java +++ b/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/PSimDataProvider.java @@ -1,7 +1,7 @@ package org.matsim.contrib.pseudosimulation; -import org.matsim.contrib.eventsBasedPTRouter.stopStopTimes.StopStopTime; -import org.matsim.contrib.eventsBasedPTRouter.waitTimes.WaitTime; +//import org.matsim.contrib.eventsBasedPTRouter.stopStopTimes.StopStopTime; +//import org.matsim.contrib.eventsBasedPTRouter.waitTimes.WaitTime; import org.matsim.contrib.pseudosimulation.distributed.listeners.events.transit.TransitPerformance; import org.matsim.contrib.pseudosimulation.replanning.PlanCatcher; import org.matsim.core.router.util.TravelTime; @@ -10,8 +10,8 @@ * Created by fouriep on 4/21/15. */ public interface PSimDataProvider { - public StopStopTime getStopStopTime(); - public WaitTime getWaitTime(); +// public StopStopTime getStopStopTime(); +// public WaitTime getWaitTime(); public TransitPerformance getTransitPerformance(); public PlanCatcher getPlanCatcher(); public TravelTime getTravelTime(); diff --git a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/RunPSim.java b/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/RunPSim.java index 3df6ab05ecf..fde2b4a010c 100644 --- a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/RunPSim.java +++ b/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/RunPSim.java @@ -23,18 +23,16 @@ import com.google.inject.Singleton; import org.matsim.api.core.v01.Scenario; -import org.matsim.contrib.eventsBasedPTRouter.TransitRouterEventsWSFactory; -import org.matsim.contrib.eventsBasedPTRouter.stopStopTimes.StopStopTime; -import org.matsim.contrib.eventsBasedPTRouter.stopStopTimes.StopStopTimeCalculator; -import org.matsim.contrib.eventsBasedPTRouter.waitTimes.WaitTime; -import org.matsim.contrib.eventsBasedPTRouter.waitTimes.WaitTimeCalculator; +//import org.matsim.contrib.eventsBasedPTRouter.TransitRouterEventsWSFactory; +//import org.matsim.contrib.eventsBasedPTRouter.stopStopTimes.StopStopTime; +//import org.matsim.contrib.eventsBasedPTRouter.stopStopTimes.StopStopTimeCalculator; +//import org.matsim.contrib.eventsBasedPTRouter.waitTimes.WaitTime; +//import org.matsim.contrib.eventsBasedPTRouter.waitTimes.WaitTimeCalculator; //import org.matsim.contrib.pseudosimulation.distributed.listeners.events.transit.TransitPerformanceRecorder; import org.matsim.contrib.pseudosimulation.mobsim.PSimProvider; import org.matsim.contrib.pseudosimulation.mobsim.SwitchingMobsimProvider; import org.matsim.contrib.pseudosimulation.replanning.PlanCatcher; -import org.matsim.contrib.pseudosimulation.trafficinfo.PSimStopStopTimeCalculator; import org.matsim.contrib.pseudosimulation.trafficinfo.PSimTravelTimeCalculator; -import org.matsim.contrib.pseudosimulation.trafficinfo.PSimWaitTimeCalculator; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; import org.matsim.core.controler.AbstractModule; @@ -43,7 +41,6 @@ import org.matsim.core.mobsim.qsim.QSimProvider; import org.matsim.core.router.util.TravelTime; import org.matsim.core.scenario.ScenarioUtils; -import org.matsim.pt.router.TransitRouter; /** * @author pieterfourie @@ -74,10 +71,10 @@ public RunPSim(Config config, PSimConfigGroup pSimConfigGroup) { public void install() { bind(MobSimSwitcher.class).toInstance(mobSimSwitcher); bindMobsim().toProvider(SwitchingMobsimProvider.class); - bind(WaitTimeCalculator.class).to(PSimWaitTimeCalculator.class); - bind(WaitTime.class).toProvider(PSimWaitTimeCalculator.class); - bind(StopStopTimeCalculator.class).to(PSimStopStopTimeCalculator.class); - bind(StopStopTime.class).toProvider(PSimStopStopTimeCalculator.class); +// bind(WaitTimeCalculator.class).to(PSimWaitTimeCalculator.class); +// bind(WaitTime.class).toProvider(PSimWaitTimeCalculator.class); +// bind(StopStopTimeCalculator.class).to(PSimStopStopTimeCalculator.class); +// bind(StopStopTime.class).toProvider(PSimStopStopTimeCalculator.class); // bind(TravelTimeCalculator.class).to(PSimTravelTimeCalculator.class); // I made TravelTimeCalculator final, so PSimTravelTimeCalculator can no longer inherit from it. The following statement binds PSimTravelTimeCalculator @@ -85,7 +82,7 @@ public void install() { bind(PSimTravelTimeCalculator.class).in( Singleton.class ) ; bind(TravelTime.class).toProvider(PSimTravelTimeCalculator.class); - bind(TransitRouter.class).toProvider(TransitRouterEventsWSFactory.class); +// bind(TransitRouter.class).toProvider(TransitRouterEventsWSFactory.class); bind(PlanCatcher.class).toInstance(new PlanCatcher()); bind(PSimProvider.class).toInstance(new PSimProvider(scenario,matsimControler.getEvents())); bind(QSimProvider.class); diff --git a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/distributed/MasterControler.java b/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/distributed/MasterControler.java index 9e1e85a8450..acd92e861e5 100644 --- a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/distributed/MasterControler.java +++ b/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/distributed/MasterControler.java @@ -23,8 +23,6 @@ import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.population.Person; import org.matsim.api.core.v01.population.Plan; -import org.matsim.contrib.eventsBasedPTRouter.stopStopTimes.StopStopTimeCalculatorSerializable; -import org.matsim.contrib.eventsBasedPTRouter.waitTimes.WaitTimeCalculatorSerializable; import org.matsim.contrib.pseudosimulation.distributed.instrumentation.scorestats.SlaveScoreStats; import org.matsim.contrib.pseudosimulation.distributed.listeners.controler.GenomeAnalysis; import org.matsim.contrib.pseudosimulation.distributed.listeners.controler.SlaveScoreWriter; @@ -73,8 +71,8 @@ public class MasterControler implements AfterMobsimListener, ShutdownListener, S private Config config; private Controler matsimControler; private TreeMap slaveHandlerTreeMap; - private WaitTimeCalculatorSerializable waitTimeCalculator; - private StopStopTimeCalculatorSerializable stopStopTimeCalculator; +// private WaitTimeCalculatorSerializable waitTimeCalculator; +// private StopStopTimeCalculatorSerializable stopStopTimeCalculator; private TransitPerformanceRecorder transitPerformanceRecorder; private SerializableLinkTravelTimes linkTravelTimes; private AtomicInteger numThreads = new AtomicInteger(0); @@ -180,13 +178,13 @@ public MasterControler(String configFile) throws NumberFormatException, IOExcept if (this.config.transit().isUseTransit()) { - waitTimeCalculator = new WaitTimeCalculatorSerializable(matsimControler.getScenario().getTransitSchedule(), this.config.travelTimeCalculator().getTraveltimeBinSize(), - (int) (this.config.qsim().getEndTime().seconds() - this.config.qsim().getStartTime().seconds())); - matsimControler.getEvents().addHandler(waitTimeCalculator); - stopStopTimeCalculator = new StopStopTimeCalculatorSerializable(matsimControler.getScenario().getTransitSchedule(), - this.config.travelTimeCalculator().getTraveltimeBinSize(), (int) (this.config.qsim() - .getEndTime().seconds() - this.config.qsim().getStartTime().seconds())); - matsimControler.getEvents().addHandler(stopStopTimeCalculator); +// waitTimeCalculator = new WaitTimeCalculatorSerializable(matsimControler.getScenario().getTransitSchedule(), this.config.travelTimeCalculator().getTraveltimeBinSize(), +// (int) (this.config.qsim().getEndTime().seconds() - this.config.qsim().getStartTime().seconds())); +// matsimControler.getEvents().addHandler(waitTimeCalculator); +// stopStopTimeCalculator = new StopStopTimeCalculatorSerializable(matsimControler.getScenario().getTransitSchedule(), +// this.config.travelTimeCalculator().getTraveltimeBinSize(), (int) (this.config.qsim() +// .getEndTime().seconds() - this.config.qsim().getStartTime().seconds())); +// matsimControler.getEvents().addHandler(stopStopTimeCalculator); //tell PlanSerializable to record transit routes PlanSerializable.isUseTransit = true; if (fullTransitPerformanceTransmission) { @@ -778,8 +776,8 @@ public void transmitTravelTimes() throws IOException { writer.writeInt(currentIteration); writer.writeObject(linkTravelTimes); if (config.transit().isUseTransit()) { - writer.writeObject(stopStopTimeCalculator.getStopStopTimes()); - writer.writeObject(waitTimeCalculator.getWaitTimes()); +// writer.writeObject(stopStopTimeCalculator.getStopStopTimes()); +// writer.writeObject(waitTimeCalculator.getWaitTimes()); if (fullTransitPerformanceTransmission) writer.writeObject(transitPerformanceRecorder.getTransitPerformance()); } diff --git a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/distributed/SlaveControler.java b/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/distributed/SlaveControler.java index a45f80ba4d6..5ec460d62d9 100644 --- a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/distributed/SlaveControler.java +++ b/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/distributed/SlaveControler.java @@ -28,11 +28,6 @@ import org.matsim.api.core.v01.population.Person; import org.matsim.api.core.v01.population.Plan; import org.matsim.contrib.common.diversitygeneration.planselectors.DiversityGeneratingPlansRemover; -import org.matsim.contrib.eventsBasedPTRouter.TransitRouterEventsWSFactory; -import org.matsim.contrib.eventsBasedPTRouter.stopStopTimes.StopStopTime; -import org.matsim.contrib.eventsBasedPTRouter.stopStopTimes.StopStopTimeCalculatorSerializable; -import org.matsim.contrib.eventsBasedPTRouter.waitTimes.WaitTime; -import org.matsim.contrib.eventsBasedPTRouter.waitTimes.WaitTimeCalculatorSerializable; import org.matsim.contrib.pseudosimulation.distributed.instrumentation.scorestats.SlaveScoreStatsCalculator; import org.matsim.contrib.pseudosimulation.distributed.listeners.events.transit.TransitPerformance; import org.matsim.contrib.pseudosimulation.mobsim.PSimProvider; @@ -86,8 +81,6 @@ public class SlaveControler implements IterationStartsListener, StartupListener, private double totalIterationTime; private Controler matsimControler; private TravelTime linkTravelTimes; - private WaitTime waitTimes; - private StopStopTime stopStopTimes; private ObjectInputStream reader; private ObjectOutputStream writer; private PSimProvider pSimProvider; @@ -97,7 +90,6 @@ public class SlaveControler implements IterationStartsListener, StartupListener, private boolean isOkForNextIter = true; private Map, Double> selectedPlanScoreMemory; private TransitPerformance transitPerformance; - private TransitRouterEventsWSFactory transitRouterEventsWSFactory; private void printHelp(Options options) { String header = "The MasterControler takes the following options:\n\n"; @@ -268,15 +260,6 @@ public void install() { }); if (config.transit().isUseTransit()) { - - stopStopTimes = new StopStopTimeCalculatorSerializable(scenario.getTransitSchedule(), - config.travelTimeCalculator().getTraveltimeBinSize(), (int) (config - .qsim().getEndTime().seconds() - config.qsim().getStartTime().seconds())).getStopStopTimes(); - - waitTimes = new WaitTimeCalculatorSerializable(scenario.getTransitSchedule(), - config.travelTimeCalculator().getTraveltimeBinSize(), (int) (config - .qsim().getEndTime().seconds() - config.qsim().getStartTime().seconds())).getWaitTimes(); - // tell PlanSerializable to record transit routes PlanSerializable.isUseTransit = true; @@ -285,11 +268,11 @@ public void install() { matsimControler.addOverridingModule(new AbstractModule() { @Override public void install() { - System.out.println("init routers"); +// System.out.println("init routers"); // transitRouterEventsWSFactory = new TransitRouterEventsWSFactory(scenario, // waitTimes, // stopStopTimes); - bind(TransitRouter.class).toProvider(transitRouterEventsWSFactory); +// bind(TransitRouter.class).toProvider(transitRouterEventsWSFactory); } }); @@ -387,13 +370,13 @@ public void notifyIterationStarts(IterationStartsEvent event) { travelTime.setTravelTime(linkTravelTimes); pSimProvider.setTravelTime(linkTravelTimes); if (config.transit().isUseTransit()) { - pSimProvider.setStopStopTime(stopStopTimes); - pSimProvider.setWaitTime(waitTimes); - pSimProvider.setTransitPerformance(transitPerformance); - if (transitRouterEventsWSFactory != null) { +// pSimProvider.setStopStopTime(stopStopTimes); +// pSimProvider.setWaitTime(waitTimes); +// pSimProvider.setTransitPerformance(transitPerformance); +// if (transitRouterEventsWSFactory != null) { // transitRouterEventsWSFactory.setStopStopTimeCalculator(stopStopTimes); // transitRouterEventsWSFactory.setWaitTimeCalculator(waitTimes); - } +// } } plancatcher.init(); numberOfIterations++; @@ -449,8 +432,8 @@ public void transmitTravelTimes() throws IOException, ClassNotFoundException { masterCurrentIteration = reader.readInt(); linkTravelTimes = (SerializableLinkTravelTimes) reader.readObject(); if (config.transit().isUseTransit()) { - stopStopTimes = (StopStopTime) reader.readObject(); - waitTimes = (WaitTime) reader.readObject(); +// stopStopTimes = (StopStopTime) reader.readObject(); +// waitTimes = (WaitTime) reader.readObject(); if (fullTransitPerformanceTransmission) { Object o = reader.readObject(); transitPerformance = (TransitPerformance) o; @@ -619,8 +602,8 @@ public void notifyBeforeMobsim(BeforeMobsimEvent event) { @Override public void notifyIterationEnds(IterationEndsEvent event) { Iterator, Double>> iterator = selectedPlanScoreMemory.entrySet().iterator(); - StopStopTimeCalculatorSerializable.printCallStatisticsAndReset(); - WaitTimeCalculatorSerializable.printCallStatisticsAndReset(); +// StopStopTimeCalculatorSerializable.printCallStatisticsAndReset(); +// WaitTimeCalculatorSerializable.printCallStatisticsAndReset(); while (iterator.hasNext()) { Map.Entry, Double> entry = iterator.next(); scenario.getPopulation().getPersons().get(entry.getKey()).getSelectedPlan().setScore(entry.getValue()); diff --git a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/mobsim/PSimProvider.java b/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/mobsim/PSimProvider.java index 2759e9c38be..baa9619edc4 100644 --- a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/mobsim/PSimProvider.java +++ b/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/mobsim/PSimProvider.java @@ -4,8 +4,6 @@ package org.matsim.contrib.pseudosimulation.mobsim; import org.matsim.api.core.v01.Scenario; -import org.matsim.contrib.eventsBasedPTRouter.stopStopTimes.StopStopTime; -import org.matsim.contrib.eventsBasedPTRouter.waitTimes.WaitTime; import org.matsim.contrib.pseudosimulation.distributed.listeners.events.transit.TransitPerformance; import org.matsim.contrib.pseudosimulation.mobsim.transitperformance.TransitEmulator; import org.matsim.contrib.pseudosimulation.replanning.PlanCatcher; @@ -42,25 +40,25 @@ public void setTravelTime(TravelTime travelTime) { this.travelTime = travelTime; } - @Deprecated - public void setWaitTime(WaitTime waitTime) { - throw new RuntimeException("Use an instance of " + TransitEmulator.class.getSimpleName() + " instead."); - } +// @Deprecated +// public void setWaitTime(WaitTime waitTime) { +// throw new RuntimeException("Use an instance of " + TransitEmulator.class.getSimpleName() + " instead."); +// } - @Deprecated - public void setStopStopTime(StopStopTime stopStopTime) { - throw new RuntimeException("Use an instance of " + TransitEmulator.class.getSimpleName() + " instead."); - } +// @Deprecated +// public void setStopStopTime(StopStopTime stopStopTime) { +// throw new RuntimeException("Use an instance of " + TransitEmulator.class.getSimpleName() + " instead."); +// } @Deprecated public void setTransitPerformance(TransitPerformance transitPerformance) { throw new RuntimeException("Use an instance of " + TransitEmulator.class.getSimpleName() + " instead."); } - @Deprecated - public void setTimes(TravelTime travelTime, WaitTime waitTime, StopStopTime stopStopTime) { - throw new RuntimeException("Use an instance of " + TransitEmulator.class.getSimpleName() + " instead."); - } +// @Deprecated +// public void setTimes(TravelTime travelTime, WaitTime waitTime, StopStopTime stopStopTime) { +// throw new RuntimeException("Use an instance of " + TransitEmulator.class.getSimpleName() + " instead."); +// } @Deprecated //will replace where necessary diff --git a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/mobsim/transitperformance/TransitPerformanceFromEventBasedRouterInterfaces.java b/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/mobsim/transitperformance/TransitPerformanceFromEventBasedRouterInterfaces.java index 13f2536ddf9..e767a863b02 100644 --- a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/mobsim/transitperformance/TransitPerformanceFromEventBasedRouterInterfaces.java +++ b/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/mobsim/transitperformance/TransitPerformanceFromEventBasedRouterInterfaces.java @@ -1,6 +1,6 @@ /* * Copyright 2018 Gunnar Flötteröd - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -23,8 +23,8 @@ import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Leg; -import org.matsim.contrib.eventsBasedPTRouter.stopStopTimes.StopStopTime; -import org.matsim.contrib.eventsBasedPTRouter.waitTimes.WaitTime; +//import org.matsim.contrib.eventsBasedPTRouter.stopStopTimes.StopStopTime; +//import org.matsim.contrib.eventsBasedPTRouter.waitTimes.WaitTime; import org.matsim.pt.routes.TransitPassengerRoute; import org.matsim.pt.transitSchedule.TransitRouteImpl; import org.matsim.pt.transitSchedule.api.TransitLine; @@ -44,16 +44,16 @@ */ public class TransitPerformanceFromEventBasedRouterInterfaces implements TransitEmulator { - private WaitTime waitTimes; - private StopStopTime stopStopTimes; +// private WaitTime waitTimes; +// private StopStopTime stopStopTimes; private Map, TransitLine> transitLines; private Map, TransitStopFacility> stopFacilities; @Inject - public TransitPerformanceFromEventBasedRouterInterfaces(WaitTime waitTimes, StopStopTime stopStopTimes, + public TransitPerformanceFromEventBasedRouterInterfaces(/*WaitTime waitTimes, StopStopTime stopStopTimes,*/ TransitSchedule transitSchedule) { - this.waitTimes = waitTimes; - this.stopStopTimes = stopStopTimes; +// this.waitTimes = waitTimes; +// this.stopStopTimes = stopStopTimes; this.transitLines = transitSchedule.getTransitLines(); this.stopFacilities = transitSchedule.getFacilities(); } @@ -65,8 +65,8 @@ public Trip findTrip(Leg prevLeg, double earliestDepartureTime_s) { TransitLine line = this.transitLines.get(route.getLineId()); TransitRoute transitRoute = line.getRoutes().get(route.getRouteId()); - final double accessTime_s = earliestDepartureTime_s + this.waitTimes.getRouteStopWaitTime(route.getLineId(), - transitRoute.getId(), route.getAccessStopId(), earliestDepartureTime_s); + final double accessTime_s = earliestDepartureTime_s /*+ this.waitTimes.getRouteStopWaitTime(route.getLineId(), + transitRoute.getId(), route.getAccessStopId(), earliestDepartureTime_s)*/; final double egressTime_s = accessTime_s + this.findTransitTravelTime(route, accessTime_s); return new Trip(null, accessTime_s, egressTime_s); } @@ -99,7 +99,7 @@ private double findTransitTravelTime(TransitPassengerRoute route, double prevEnd Id fromId = transitRoute.getStops().get(i).getStopFacility().getId(); TransitRouteStop toStop = transitRoute.getStops().get(i + 1); Id toId = toStop.getStopFacility().getId(); - travelTime += stopStopTimes.getStopStopTime(fromId, toId, prevStopTime); +// travelTime += stopStopTimes.getStopStopTime(fromId, toId, prevStopTime); prevStopTime += travelTime; if (toStop.getStopFacility().getId().equals(dest)) { destinationFound = true; diff --git a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/trafficinfo/PSimStopStopTimeCalculator.java b/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/trafficinfo/PSimStopStopTimeCalculator.java deleted file mode 100644 index 4b1a0e49a21..00000000000 --- a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/trafficinfo/PSimStopStopTimeCalculator.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.matsim.contrib.pseudosimulation.trafficinfo; - -import com.google.inject.Singleton; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.matsim.api.core.v01.Scenario; -import org.matsim.api.core.v01.events.PersonLeavesVehicleEvent; -import org.matsim.contrib.eventsBasedPTRouter.stopStopTimes.StopStopTimeCalculatorSerializable; -import org.matsim.contrib.pseudosimulation.MobSimSwitcher; -import org.matsim.core.api.experimental.events.EventsManager; -import org.matsim.core.api.experimental.events.VehicleArrivesAtFacilityEvent; -import org.matsim.core.config.Config; -import org.matsim.pt.transitSchedule.api.TransitSchedule; - -import jakarta.inject.Inject; - -@Singleton -public class PSimStopStopTimeCalculator extends StopStopTimeCalculatorSerializable { - private final MobSimSwitcher switcher; - - @Inject - PSimStopStopTimeCalculator(Scenario scenario, MobSimSwitcher switcher, EventsManager eventsManager) { - super(scenario.getTransitSchedule(),scenario.getConfig() ); - this.switcher = switcher; - eventsManager.addHandler(this); - } - - @Override - public void reset(int iteration) { - if (switcher.isQSimIteration()) { - LogManager.getLogger(this.getClass()).error( - "Calling reset on traveltimecalc"); - super.reset(iteration); - } - } - - @Override - public void handleEvent(VehicleArrivesAtFacilityEvent event) { - if (switcher.isQSimIteration()) - super.handleEvent(event); - } - - @Override - public void handleEvent(PersonLeavesVehicleEvent event) { - if (switcher.isQSimIteration()) - super.handleEvent(event); - } - -} diff --git a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/trafficinfo/PSimWaitTimeCalculator.java b/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/trafficinfo/PSimWaitTimeCalculator.java deleted file mode 100644 index f618a5c8a45..00000000000 --- a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/trafficinfo/PSimWaitTimeCalculator.java +++ /dev/null @@ -1,57 +0,0 @@ -package org.matsim.contrib.pseudosimulation.trafficinfo; - -import com.google.inject.Inject; -import com.google.inject.Singleton; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.matsim.api.core.v01.Scenario; -import org.matsim.api.core.v01.events.PersonDepartureEvent; -import org.matsim.api.core.v01.events.PersonEntersVehicleEvent; -import org.matsim.contrib.eventsBasedPTRouter.waitTimes.WaitTimeCalculatorSerializable; -import org.matsim.contrib.eventsBasedPTRouter.waitTimes.WaitTimeStuckCalculator; -import org.matsim.contrib.pseudosimulation.MobSimSwitcher; -import org.matsim.core.api.experimental.events.EventsManager; - - -/** - * @author fouriep - *

      - * Extends Ordonez's {@link WaitTimeStuckCalculator} to only handle - * events during QSim iterations. - */ -@Singleton -public class PSimWaitTimeCalculator extends WaitTimeCalculatorSerializable { - private final MobSimSwitcher switcher; - - @Inject - public PSimWaitTimeCalculator(Scenario scenario, - MobSimSwitcher switcher, EventsManager eventsManager) { - super(scenario.getTransitSchedule(),scenario.getConfig()); - this.switcher = switcher; - eventsManager.addHandler(this); - } - - @Override - public void reset(int iteration) { - if (switcher.isQSimIteration()) { - LogManager.getLogger(this.getClass()).error( - "Calling reset on traveltimecalc"); - super.reset(iteration); - } - } - - @Override - public void handleEvent(PersonDepartureEvent event) { - if (switcher.isQSimIteration()) - super.handleEvent(event); - } - - @Override - public void handleEvent(PersonEntersVehicleEvent event) { - if (switcher.isQSimIteration()) - super.handleEvent(event); - } - - - -} diff --git a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/trafficinfo/deterministic/DeterministicStopStopTimeCalculator.java b/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/trafficinfo/deterministic/DeterministicStopStopTimeCalculator.java deleted file mode 100644 index 567187f053d..00000000000 --- a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/trafficinfo/deterministic/DeterministicStopStopTimeCalculator.java +++ /dev/null @@ -1,66 +0,0 @@ -package org.matsim.contrib.pseudosimulation.trafficinfo.deterministic; - -import java.util.List; - -import org.matsim.api.core.v01.Id; -import org.matsim.api.core.v01.population.Leg; -import org.matsim.api.core.v01.population.PlanElement; -import org.matsim.contrib.eventsBasedPTRouter.stopStopTimes.StopStopTime; -import org.matsim.contrib.eventsBasedPTRouter.stopStopTimes.StopStopTimeCalculator; -import org.matsim.core.router.DefaultRoutingRequest; -import org.matsim.pt.router.TransitRouter; -import org.matsim.pt.transitSchedule.api.TransitSchedule; -import org.matsim.pt.transitSchedule.api.TransitStopFacility; -import org.matsim.utils.objectattributes.attributable.Attributes; - -import com.google.inject.Inject; -import com.google.inject.Singleton; - -@Singleton -public class DeterministicStopStopTimeCalculator implements StopStopTimeCalculator { - private final TransitRouter transitRouter; - private final TransitSchedule schedule; - - @Inject - public DeterministicStopStopTimeCalculator(TransitRouter transitRouter, TransitSchedule schedule) { - this.transitRouter = transitRouter; - this.schedule = schedule; - } - - @Override - public double getStopStopTime(Id stopOId, Id stopDId, double time) { - // ATTENTION! This could be optimized. Basically, we probably don't need to - // route here. However, finding the travel time even on one route is not a - // computationally efficient task, because the same transit stop id may occur - // multiple times on the same route. - - TransitStopFacility originFacility = schedule.getFacilities().get(stopOId); - TransitStopFacility destinationFacility = schedule.getFacilities().get(stopDId); - - List legs = transitRouter.calcRoute(DefaultRoutingRequest.withoutAttributes(originFacility, destinationFacility, time, null)); - return legs.stream().mapToDouble(l -> ((Leg)l).getTravelTime().seconds()).sum(); - } - - @Override - public double getStopStopTimeVariance(Id stopOId, Id stopDId, - double time) { - return 0.0; - } - - @Override - public StopStopTime get() { - return new StopStopTime() { - @Override - public double getStopStopTimeVariance(Id stopOId, Id stopDId, - double time) { - return 0.0; - } - - @Override - public double getStopStopTime(Id stopOId, Id stopDId, - double time) { - return DeterministicStopStopTimeCalculator.this.getStopStopTime(stopOId, stopDId, time); - } - }; - } -} diff --git a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/trafficinfo/deterministic/DeterministicWaitTimeCalculator.java b/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/trafficinfo/deterministic/DeterministicWaitTimeCalculator.java deleted file mode 100644 index d1aa43ce61b..00000000000 --- a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/trafficinfo/deterministic/DeterministicWaitTimeCalculator.java +++ /dev/null @@ -1,84 +0,0 @@ -package org.matsim.contrib.pseudosimulation.trafficinfo.deterministic; - -import java.util.LinkedList; -import java.util.List; - -import org.matsim.api.core.v01.Id; -import org.matsim.contrib.eventsBasedPTRouter.waitTimes.WaitTime; -import org.matsim.contrib.eventsBasedPTRouter.waitTimes.WaitTimeCalculator; -import org.matsim.pt.transitSchedule.api.Departure; -import org.matsim.pt.transitSchedule.api.TransitLine; -import org.matsim.pt.transitSchedule.api.TransitRoute; -import org.matsim.pt.transitSchedule.api.TransitRouteStop; -import org.matsim.pt.transitSchedule.api.TransitSchedule; -import org.matsim.pt.transitSchedule.api.TransitStopFacility; - -import com.google.inject.Inject; -import com.google.inject.Singleton; - -@Singleton -public class DeterministicWaitTimeCalculator implements WaitTimeCalculator { - private final TransitSchedule schedule; - - @Inject - public DeterministicWaitTimeCalculator(TransitSchedule schedule) { - this.schedule = schedule; - } - - @Override - public double getRouteStopWaitTime(Id lineId, Id routeId, Id stopId, - double time) { - TransitRoute route = schedule.getTransitLines().get(lineId).getRoutes().get(routeId); - - // First collect all the offsets on the route for a specific transit stop id. - // Note that a single transit facility may be contained multiple times on a - // route! - List facilityOffsets = new LinkedList<>(); - - for (TransitRouteStop stop : route.getStops()) { - if (stop.getStopFacility().getId().equals(stopId)) { - facilityOffsets.add(stop.getDepartureOffset().seconds()); - } - } - - if (facilityOffsets.size() == 0) { - // The facility is not contained on this route - throw new IllegalStateException(); - } - - // Now loop through all the departures and routes and find the actual stop - // departure that is right after the given time. - - double minimumWaitTime = Double.POSITIVE_INFINITY; - - for (double offset : facilityOffsets) { - for (Departure departure : route.getDepartures().values()) { - double stopDepartureTime = departure.getDepartureTime() + offset; - - while (stopDepartureTime < time) { - // Consistent with TransitRouterNetworkTravelTimeAndDisutility.MIDNIGHT - stopDepartureTime += 24.0 * 3600; - } - - double waitTime = time - stopDepartureTime; - - if (waitTime < minimumWaitTime) { - minimumWaitTime = waitTime; - } - } - } - - return minimumWaitTime; - } - - @Override - public WaitTime get() { - return new WaitTime() { - @Override - public double getRouteStopWaitTime(Id lineId, Id routeId, - Id stopId, double time) { - return DeterministicWaitTimeCalculator.this.getRouteStopWaitTime(lineId, routeId, stopId, time); - } - }; - } -} diff --git a/contribs/pseudosimulation/src/test/java/org/matsim/contrib/pseudosimulation/RunPSimTest.java b/contribs/pseudosimulation/src/test/java/org/matsim/contrib/pseudosimulation/RunPSimTest.java index 994a35e162e..82224f40c4f 100644 --- a/contribs/pseudosimulation/src/test/java/org/matsim/contrib/pseudosimulation/RunPSimTest.java +++ b/contribs/pseudosimulation/src/test/java/org/matsim/contrib/pseudosimulation/RunPSimTest.java @@ -109,7 +109,7 @@ public void install() { Population popActual = PopulationUtils.createPopulation( config ); PopulationUtils.readPopulation( popActual, outDir + "/output_plans.xml.gz" ); new PopulationComparison().compare( popExpected, popActual ) ; - Assert.assertEquals("RunPsim score changed.", 138.90474624352407, psimScore, MatsimTestUtils.EPSILON); + Assert.assertEquals("RunPsim score changed.", 138.88379880881348, psimScore, MatsimTestUtils.EPSILON); // Assert.assertEquals("RunPsim score changed.", 134.54001491094124d, psimScore, MatsimTestUtils.EPSILON); // Assert.assertEquals("RunPsim score changed.", 134.52369453719413d, psimScore, MatsimTestUtils.EPSILON); // Assert.assertEquals("RunPsim score changed.", 132.73129073101293d, psimScore, MatsimTestUtils.EPSILON); From b81aa317c1d56995518631c069c9f435da524e48 Mon Sep 17 00:00:00 2001 From: Marcel Rieser Date: Thu, 12 Oct 2023 11:47:49 +0200 Subject: [PATCH 19/25] use ConfigAliases in CommandLine parser --- matsim/src/main/java/org/matsim/core/config/CommandLine.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/matsim/src/main/java/org/matsim/core/config/CommandLine.java b/matsim/src/main/java/org/matsim/core/config/CommandLine.java index 15f8213a860..f23de634e65 100644 --- a/matsim/src/main/java/org/matsim/core/config/CommandLine.java +++ b/matsim/src/main/java/org/matsim/core/config/CommandLine.java @@ -21,6 +21,7 @@ package org.matsim.core.config; +import java.util.ArrayDeque; import java.util.Arrays; import java.util.Collection; import java.util.Collections; @@ -140,6 +141,8 @@ public class CommandLine { final private boolean positionalArgumentsAllowed; final private boolean allowAnyOption; + private final ConfigAliases configAliases = new ConfigAliases(); + // Configuration part /** @@ -555,6 +558,8 @@ private void processConfigOption(Config config, String option, String remainder) String module = remainder.substring(0, separatorIndex); String newRemainder = remainder.substring(separatorIndex + 1); + module = this.configAliases.resolveAlias(module, new ArrayDeque<>()); + if (config.getModules().containsKey(module)) { processParameter(option, module, config.getModules().get(module), newRemainder); } else { From 5b3a3f47bfd366e5ca770f570bcf385a8d2e75ae Mon Sep 17 00:00:00 2001 From: Marcel Rieser Date: Thu, 12 Oct 2023 12:03:48 +0200 Subject: [PATCH 20/25] rename accessor-methods in Config for renamed ConfigGroups --- .../java/org/matsim/benchmark/Benchmark.java | 2 +- ...ityComputationNairobiLandUseLocalCopy.java | 38 +-- ...essibilityComputationShutdownListener.java | 2 +- .../AccessibilityFromEvents.java | 4 +- .../accessibility/AccessibilityModule.java | 10 +- .../accessibility/AccessibilityUtils.java | 8 +- ...ccessibilityExpContributionCalculator.java | 8 +- ...ccessibilityExpContributionCalculator.java | 4 +- ...orAccessibilityContributionCalculator.java | 2 +- ...erAccessibilityContributionCalculator.java | 2 +- .../run/RunAccessibilityExample.java | 6 +- .../utils/GnuplotScriptWriter.java | 76 ++--- .../run/AccessibilityIntegrationTest.java | 34 +- .../run/TinyAccessibilityTest.java | 9 +- .../run/TinyMultimodalAccessibilityTest.java | 6 +- .../contrib/accidents/AccidentWriter.java | 26 +- .../accidents/runExample/RunAccidents.java | 34 +- .../org/matsim/contrib/accidents/RunTest.java | 50 +-- .../contrib/accidents/RunTestEquil.java | 52 +-- .../christoph/ActivitiesAnalyzer.java | 104 +++--- .../analysis/christoph/TripsAnalyzer.java | 86 ++--- .../analysis/kai/RunKNEventsAnalyzer.java | 38 +-- .../RunEventsToTravelDiaries.java | 2 +- .../matsim/application/ApplicationUtils.java | 5 +- .../matsim/application/MATSimApplication.java | 16 +- .../emissions/AirPollutionAnalysis.java | 4 +- .../AirPollutionByVehicleCategory.java | 4 +- .../analysis/noise/NoiseAnalysis.java | 4 +- .../DetermineAverageTruckLoad.java | 7 +- .../ExtractRelevantFreightTrips.java | 2 +- .../FreightDemandGeneration.java | 30 +- .../FreightDemandGenerationUtils.java | 2 +- ...rateSmallScaleCommercialTrafficDemand.java | 28 +- .../application/MATSimApplicationTest.java | 18 +- .../analysis/LogFileAnalysisTest.java | 6 +- .../RunTaxiPTIntermodalExample.java | 4 +- .../av/robotaxi/run/RunDrtAndTaxiExample.java | 2 +- .../matsim/contrib/bicycle/BicycleModule.java | 2 +- .../bicycle/run/RunBicycleExample.java | 26 +- .../contrib/bicycle/run/BicycleTest.java | 136 ++++---- .../cadyts/general/CadytsBuilderImpl.java | 32 +- .../cadyts/general/CadytsPlanChanger.java | 6 +- .../contrib/cadyts/general/CadytsScoring.java | 2 +- .../cadyts/run/RunCadyts4CarExample.java | 2 +- .../contrib/cadyts/car/CadytsCarIT.java | 24 +- .../cadyts/car/CadytsCarWithPtScenarioIT.java | 4 +- .../matsim/contrib/cadyts/pt/CadytsPtIT.java | 58 ++-- .../control/listeners/CarsharingListener.java | 2 +- .../runExample/RunCarsharingIT.java | 16 +- .../DefaultCommercialJobGenerator.java | 4 +- .../RunJointDemandCarToggleJspritExample.java | 18 +- .../examples/RunJointDemandCarExample.java | 18 +- .../examples/RunJointDemandDRTExample.java | 22 +- .../CommercialTrafficIntegrationTest.java | 2 +- .../IsTheRightCustomerScoredTest.java | 4 +- .../common/timeprofile/ProfileWriter.java | 4 +- .../RandomizingTransitRouterIT.java | 16 +- .../always/BetaTravelTest66IT.java | 16 +- .../integration/always/BetaTravelTest6IT.java | 16 +- .../DecongestionControlerListener.java | 32 +- .../decongestion/DecongestionRunExample.java | 44 +-- .../DecongestionRunExampleFromConfig.java | 34 +- .../TollTimeDistanceTravelDisutility.java | 20 +- .../tollSetting/DecongestionTollingP_MCP.java | 74 ++--- .../DecongestionPricingTestIT.java | 304 +++++++++--------- .../DiscreteModeChoiceConfigurator.java | 4 +- .../modules/DiscreteModeChoiceModule.java | 4 +- .../examples/TestSiouxFalls.java | 12 +- .../DrtCompanionControlerCreator.java | 4 +- .../dashboards/DrtDashboardProvider.java | 2 +- .../edrt/run/EDrtControlerCreator.java | 2 +- .../contrib/drt/extension/fiss/FISS.java | 2 +- .../ShiftAnalysisControlerListener.java | 2 +- .../analysis/ShiftHistogramListener.java | 2 +- ...ftEfficiencyAnalysisControlerListener.java | 2 +- .../run/PreplannedDrtControlerCreator.java | 2 +- .../run/RunPreplannedDrtExample.java | 2 +- .../drt/extension/DrtTestScenario.java | 16 +- .../RunDrtWithCompanionExampleIT.java | 6 +- .../extension/dashboards/DashboardTests.java | 6 +- .../extension/fiss/RunFissDrtScenarioIT.java | 24 +- .../eshifts/run/RunEShiftDrtScenarioIT.java | 24 +- .../run/RunMultiHubShiftDrtScenarioIT.java | 24 +- .../shifts/run/RunShiftDrtScenarioIT.java | 24 +- .../DrtAnalysisControlerListener.java | 4 +- .../contrib/drt/run/DrtControlerCreator.java | 2 +- .../matsim/contrib/drt/run/DrtModeModule.java | 6 +- .../contrib/drt/run/DrtModeQSimModule.java | 2 +- .../run/examples/RunMultiModeDrtExample.java | 2 +- .../run/examples/RunOneSharedTaxiExample.java | 4 +- .../insertion/DrtPoolingParameterTest.java | 5 +- .../drt/run/examples/RunDrtExampleIT.java | 44 +-- .../examples/onetaxi/RunOneTaxiExample.java | 2 +- .../RunOneTaxiOneTruckExample.java | 2 +- .../examples/onetruck/RunOneTruckExample.java | 2 +- .../contrib/dvrp/run/DvrpConfigGroup.java | 2 +- .../random/RunRandomDynAgentExample.java | 6 +- .../RunOneTaxiWithPrebookingExampleIT.java | 4 +- .../contrib/dvrp/router/DiversionTest.java | 8 +- .../emissions/PositionEmissionsModule.java | 2 +- .../example/CreateEmissionConfig.java | 6 +- .../RunAverageEmissionToolOfflineExample.java | 8 +- ...RunDetailedEmissionToolOfflineExample.java | 7 +- .../emissions/TestPositionEmissionModule.java | 24 +- ...unAverageEmissionToolOfflineExampleIT.java | 9 +- ...nDetailedEmissionToolOfflineExampleIT.java | 13 +- ...EmissionToolOnlineExampleIT_vehTypeV1.java | 4 +- ...eExampleIT_vehTypeV1FallbackToAverage.java | 4 +- ...EmissionToolOnlineExampleIT_vehTypeV2.java | 4 +- ...eExampleIT_vehTypeV2FallbackToAverage.java | 4 +- .../contrib/ev/example/RunEvExample.java | 5 +- .../RunEvExampleWithLTHConsumptionModel.java | 5 +- ...OccupancyTimeProfileCollectorProvider.java | 2 +- ...emperatureChangeModuleIntegrationTest.java | 2 +- .../freight/controler/CarrierModule.java | 2 +- .../usecases/analysis/CarrierScoreStats.java | 4 +- .../usecases/chessboard/RunChessboard.java | 6 +- .../RunPassengerAlongWithCarriers.java | 6 +- .../RunPassengerPlansFromScratch.java | 20 +- .../freight/carrier/CarrierModuleTest.java | 16 +- .../EquilWithCarrierWithPersonsIT.java | 16 +- ...istanceConstraintFromVehiclesFileTest.java | 20 +- .../jsprit/DistanceConstraintTest.java | 24 +- .../RunPassengerAlongWithCarriersIT.java | 6 +- .../freight/utils/FreightUtilsTest.java | 8 +- .../ReceiverControlerListener.java | 2 +- .../freightreceiver/ReceiverScoreStats.java | 12 +- ...iverTriggersCarrierReplanningListener.java | 2 +- .../OrderFrequencyStrategyManager.java | 4 +- .../ServiceTimeStrategyManagerProvider.java | 4 +- .../TimeWindowStrategyManagerFactory.java | 2 +- .../ReceiverChessboardScenario.java | 14 +- ...iverChessboardWithEqualProportionCost.java | 4 +- ...eceiverChessboardWithFixedCarrierCost.java | 4 +- .../contrib/hybridsim/run/RunExample.java | 14 +- .../modechoice/ModeChoiceWeightScheduler.java | 4 +- .../modechoice/commands/AnalyzeCarChoice.java | 4 +- .../commands/GenerateChoiceSet.java | 4 +- .../modechoice/commands/StrategyOptions.java | 8 +- .../ModeChoiceWeightSchedulerTest.java | 6 +- .../org/matsim/modechoice/TestScenario.java | 24 +- .../estimators/ComplexEstimatorTest.java | 2 +- .../SelectSingleTripModeStrategyTest.java | 6 +- .../modechoice/search/TopKMinMaxTest.java | 2 +- .../BestReplyLocationChoicePlanAlgorithm.java | 26 +- .../BestReplyLocationChoicePlanStrategy.java | 5 +- .../DCScoringFunctionFactory.java | 22 +- .../DestinationChoiceContext.java | 4 +- .../LocationChoicePlanStrategy.java | 4 +- .../contrib/locationchoice/Initializer.java | 8 +- .../locationchoice/LocationChoiceIT.java | 18 +- .../frozenepsilons/BestReplyIT.java | 10 +- .../FrozenEpsilonLocaChoiceIT.java | 50 +-- .../router/BackwardFastMultiNodeTest.java | 122 +++---- .../matsim/core/router/FastMultiNodeTest.java | 122 +++---- .../MatrixBasedPtRouterIT.java | 40 +-- .../matrixbasedptrouter/PtMatrixTest.java | 112 +++---- .../RunConfigurableMinibusExample.java | 23 +- .../org/matsim/contrib/minibus/hook/PBox.java | 2 +- .../minibus/hook/PControlerListener.java | 6 +- .../contrib/minibus/stats/Line2GexfPStat.java | 2 +- .../contrib/minibus/stats/PStatsOverview.java | 4 +- .../minibus/integration/PControlerTestIT.java | 25 +- .../integration/SubsidyContextTestIT.java | 70 ++-- .../minibus/integration/SubsidyTestIT.java | 36 +-- .../contrib/multimodal/MultiModalModule.java | 4 +- .../util/MultiModalTravelTimeFactory.java | 2 +- .../MultiModalControlerListenerTest.java | 34 +- .../multimodal/MultiModalTripRouterTest.java | 12 +- .../pt/MultiModalPTCombinationTest.java | 20 +- .../router/util/BikeTravelTimeTest.java | 20 +- .../router/util/WalkTravelTimeTest.java | 14 +- .../multimodal/simengine/StuckAgentTest.java | 20 +- .../contrib/noise/NoiseCalculationOnline.java | 20 +- .../noise/NoiseOfflineCalculation.java | 10 +- .../contrib/noise/NoiseTimeTracker.java | 32 +- ...llTimeDistanceTravelDisutilityFactory.java | 2 +- .../NoiseOfflineCalculationExample.java | 28 +- .../examples/NoiseOnlineControlerExample.java | 28 +- .../contrib/noise/NoiseConfigGroupIT.java | 44 +-- .../org/matsim/contrib/noise/NoiseIT.java | 74 ++--- .../contrib/noise/NoiseOnlineExampleIT.java | 30 +- .../otfvis/OTFVisFileWriterModule.java | 2 +- .../org/matsim/contrib/otfvis/OTFVisIT.java | 16 +- .../T2_RunControlerWithMovieOutput.java | 6 +- .../PC2/scoring/ParkingScoreManager.java | 2 +- .../run/RunParkingChoiceExample.java | 8 +- .../parkingcost/module/ParkingCostModule.java | 2 +- .../parkingproxy/run/RunWithParkingProxy.java | 6 +- .../RunParkingSearchExample.java | 14 +- .../ZoneParkingOccupationListener.java | 72 ++--- .../parkingsearch/manager/WalkLegFactory.java | 4 +- .../VehicleTeleportationToNearbyParking.java | 18 +- .../run/RunParkingChoiceExampleIT.java | 8 +- .../run/RunParkingSearchScenarioIT.java | 10 +- .../ChoiceGenerationControler.java | 6 +- .../pseudosimulation/MobSimSwitcher.java | 4 +- .../contrib/pseudosimulation/RunPSim.java | 6 +- .../distributed/MasterControler.java | 16 +- .../distributed/SlaveControler.java | 36 +-- .../scorestats/SlaveScoreStats.java | 8 +- .../listeners/controler/GenomeAnalysis.java | 4 +- .../listeners/controler/SlaveScoreWriter.java | 4 +- .../mobsim/SwitchingMobsimProvider.java | 4 +- ...lanStrategyTranslationAndRegistration.java | 2 +- .../contrib/pseudosimulation/RunPSimTest.java | 22 +- .../contrib/railsim/RunRailsimExample.java | 2 +- .../RailsimLinkStateControlerListener.java | 2 +- .../RailsimTrainStateControlerListener.java | 2 +- .../integration/RailsimIntegrationTest.java | 16 +- .../railsim/integration/SnzActivities.java | 14 +- .../RoadPricingModuleDefaults.java | 2 +- .../RoadPricingTravelDisutilityFactory.java | 2 +- .../TravelDisutilityIncludingToll.java | 8 +- .../run/RunRoadPricingFromCode.java | 8 +- .../RunRoadPricingUsingTollFactorExample.java | 2 +- .../roadpricing/AvoidTolledRouteTest.java | 52 +-- .../contrib/roadpricing/ModuleTest.java | 4 +- .../PlansCalcRouteWithTollOrNotTest.java | 16 +- .../roadpricing/RoadPricingControlerIT.java | 30 +- .../TollTravelCostCalculatorTest.java | 14 +- .../matsim/mobsim/qsim/SBBQSimModuleTest.java | 4 +- .../SBBTransitQSimEngineIntegrationTest.java | 8 +- .../examples/RunCarsharing.java | 14 +- .../examples/RunParisVelib.java | 16 +- .../examples/RunTeleportationBikesharing.java | 18 +- .../matsim/contrib/shared_mobility/RunIT.java | 14 +- .../RunAdaptiveSignalsExample.java | 40 +-- .../RunSignalSystemsExample.java | 18 +- .../RunSignalSystemsExampleWithHoles.java | 40 +-- .../VisualizeSignalScenario.java | 18 +- .../VisualizeSignalScenarioWithLanes.java | 8 +- .../RunSimpleResponsiveSignalExample.java | 20 +- .../SimpleResponsiveSignal.java | 2 +- .../analysis/SignalEvents2ViaCSVWriter.java | 6 +- .../signals/builder/SignalsModule.java | 14 +- .../RunSignalSystemsExampleTest.java | 10 +- .../contrib/signals/builder/Fixture.java | 6 +- .../builder/TravelTimeFourWaysTest.java | 20 +- .../builder/TravelTimeOneWayTestIT.java | 16 +- ...aultPlanbasedSignalSystemControllerIT.java | 22 +- .../controller/laemmerFix/LaemmerIT.java | 6 +- .../signals/controller/sylvia/SylviaIT.java | 20 +- .../UnprotectedLeftTurnLogicTest.java | 22 +- .../signals/integration/SignalSystemsIT.java | 126 ++++---- .../InvertedNetworksSignalsIT.java | 20 +- .../SignalsAndLanesOsmNetworkReaderTest.java | 4 +- .../signals/oneagent/ControlerTest.java | 29 +- .../contrib/signals/oneagent/Fixture.java | 6 +- .../SimulatedAnnealingAnalysis.java | 2 +- .../SimulatedAnnealingIT.java | 8 +- .../simwrapper/SimWrapperModuleTest.java | 7 +- .../org/matsim/simwrapper/TestScenario.java | 12 +- .../simwrapper/dashboard/DashboardTests.java | 3 +- .../listeners/JointPlansDumping.java | 4 +- .../strategies/CoalitionExpBetaFactory.java | 2 +- .../strategies/GroupSelectExpBetaFactory.java | 2 +- ...GroupWhoIsTheBossSelectExpBetaFactory.java | 2 +- ...eMoneyEventsForUtilityOfBeingTogether.java | 4 +- ...lWithJointModesScoringFunctionFactory.java | 2 +- .../analysis/CourtesyHistogramListener.java | 2 +- .../GroupMinLossSelectExpBetaFactory.java | 4 +- .../GroupMinSelectExpBetaFactory.java | 2 +- .../GroupTimeAllocationMutatorFactory.java | 4 +- .../GroupWeightedSelectExpBetaFactory.java | 4 +- .../strategies/ParetoExpBetaFactory.java | 4 +- .../contrib/etaxi/run/RunETaxiBenchmark.java | 12 +- .../contrib/etaxi/run/RunETaxiScenario.java | 2 +- .../taxi/benchmark/RunTaxiBenchmark.java | 10 +- .../run/examples/RunMultiModeTaxiExample.java | 2 +- .../taxi/run/examples/RunTaxiExample.java | 2 +- .../taxi/optimizer/TaxiOptimizerTests.java | 6 +- .../taxi/run/RunTaxiScenarioTestIT.java | 4 +- .../RunFreightAnalysisEventBased.java | 4 +- .../contrib/vsp/scenario/SnzActivities.java | 14 +- .../ModalShareControlerListener.java | 4 +- .../ModalTravelTimeControlerListener.java | 4 +- .../SimpleTripAnalyzer.java | 36 +-- .../userBenefits/UserBenefitsCalculator.java | 4 +- .../andreas/mzilske/bvg09/DataPrepare.java | 12 +- .../pt/queuesim/GreedyUmlaufBuilderImpl.java | 32 +- .../BuildingEnergyRunnerMain.java | 40 +-- .../linkOccupancy/RunEquil.java | 8 +- .../marginals/ModalDistanceCadytsBuilder.java | 4 +- .../vsp/congestion/RunSimpleExample.java | 10 +- .../CongestionAnalysisEventHandler.java | 136 ++++---- .../analysis/CongestionEventsWriter.java | 42 +-- ...inalCongestionPricingContolerListener.java | 32 +- ...ageCongestionPricingControlerListener.java | 24 +- ...inalCongestionPricingContolerListener.java | 22 +- ...ancedMarginalCongestionPricingHandler.java | 144 ++++----- .../handlers/CongestionHandlerBaseImpl.java | 62 ++-- .../MarginalCongestionPricingHandler.java | 22 +- .../vsp/congestion/handlers/TollHandler.java | 102 +++--- .../CommuterDemandWriter.java | 6 +- .../playground/vsp/ev/RunUrbanEVExample.java | 6 +- .../vsp/ev/UrbanEVTripsPlanner.java | 6 +- .../SplitActivityTypesBasedOnDuration.java | 4 +- .../vsp/parkAndRide/example/PRRunner.java | 4 +- .../playground/vsp/pt/fare/PtFareModule.java | 4 +- ...dTransitRouterTravelTimeAndDisutility.java | 12 +- ...oringParametersFromPersonAttributesIT.java | 8 +- .../drtAndPt/PtAlongALine2Test.java | 56 ++-- .../drtAndPt/PtAlongALineTest.java | 42 +-- .../java/playground/vsp/TestScenario.java | 4 +- .../ModalDistanceAndCountsCadytsIT.java | 22 +- ...odalDistanceCadytsMultipleDistancesIT.java | 20 +- .../ModalDistanceCadytsSingleDistanceIT.java | 22 +- .../marginals/TripEventHandlerTest.java | 10 +- .../AdvancedMarginalCongestionPricingIT.java | 32 +- ...tionHandlerFlowSpillbackQueueQsimTest.java | 10 +- .../MarginalCongestionHandlerV3Test.java | 4 +- .../vsp/ev/CreateUrbanEVTestScenario.java | 12 +- .../ev/TransferFinalSocToNextIterTest.java | 4 +- .../java/playground/vsp/ev/UrbanEVTests.java | 4 +- ...rarchicalFLowEfficiencyCalculatorTest.java | 6 +- .../vsp/pt/fare/PtTripFareEstimatorTest.java | 2 +- .../vsp/pt/ptdisturbances/EditTripsTest.java | 22 +- .../IndividualRaptorParametersForPerson.java | 2 +- .../matsim/routing/pt/raptor/RaptorUtils.java | 4 +- ...IterationTravelStatsControlerListener.java | 6 +- .../matsim/analysis/TravelDistanceStats.java | 2 +- .../java/org/matsim/core/config/Config.java | 10 +- .../org/matsim/core/config/ConfigUtils.java | 4 +- .../ConfigConsistencyCheckerImpl.java | 24 +- .../VspConfigConsistencyCheckerImpl.java | 36 +-- .../config/groups/ControllerConfigGroup.java | 2 +- .../config/groups/ScoringConfigGroup.java | 2 +- .../core/controler/AbstractController.java | 20 +- .../org/matsim/core/controler/Controler.java | 2 +- .../controler/OutputDirectoryHierarchy.java | 2 +- .../core/controler/PrepareForSimImpl.java | 2 +- .../corelisteners/DumpDataAtEndImpl.java | 2 +- .../core/events/EventsManagerModule.java | 6 +- .../core/events/ParallelEventsManager.java | 2 +- .../events/ParallelEventsManagerImpl.java | 6 +- .../core/mobsim/DefaultMobsimModule.java | 6 +- .../core/mobsim/hermes/HermesConfigGroup.java | 3 +- .../qsim/DefaultTeleportationEngine.java | 2 +- .../io/PopulationReaderMatsimV5.java | 8 +- .../io/PopulationReaderMatsimV6.java | 8 +- .../replanning/StrategyManagerModule.java | 2 +- .../annealing/ReplanningAnnealer.java | 32 +- .../replanning/modules/ExternalModule.java | 11 +- .../DefaultPlanStrategiesModule.java | 12 +- .../router/LeastCostPathCalculatorModule.java | 6 +- .../NetworkRoutingInclAccessEgressModule.java | 4 +- .../matsim/core/router/TripRouterModule.java | 8 +- ...ngTimeDistanceTravelDisutilityFactory.java | 4 +- .../TravelDisutilityModule.java | 2 +- .../core/scenario/ScenarioLoaderImpl.java | 4 +- .../ScoringFunctionsForPopulation.java | 2 +- .../scoring/functions/ScoringParameters.java | 4 +- .../SubpopulationScoringParameters.java | 2 +- .../TravelTimeCalculatorModule.java | 5 +- .../facilities/FacilitiesFromPopulation.java | 2 +- .../DependencyGraphControlerListener.java | 2 +- .../pt/ReconstructingUmlaufBuilder.java | 2 +- .../pt/counts/PtCountControlerListener.java | 6 +- .../matsim/pt/router/TransitRouterConfig.java | 2 +- .../pt/router/TransitRouterImplFactory.java | 4 +- .../java/org/matsim/run/Events2Snapshot.java | 2 +- .../main/java/org/matsim/run/InitRoutes.java | 2 +- .../main/java/org/matsim/run/RunMatsim.java | 16 +- .../src/main/java/org/matsim/run/gui/Gui.java | 2 +- .../SnapshotWritersModule.java | 6 +- .../ExampleWithinDayController.java | 2 +- .../controller/ExecutedPlansServiceImpl.java | 2 +- .../WithinDayTravelTimeModule.java | 2 +- .../pt/raptor/RaptorStopFinderTest.java | 4 +- .../raptor/SwissRailRaptorIntermodalTest.java | 34 +- .../pt/raptor/SwissRailRaptorModuleTest.java | 58 ++-- .../pt/raptor/SwissRailRaptorTest.java | 32 +- ...ationTravelStatsControlerListenerTest.java | 34 +- .../LinkStatsControlerListenerTest.java | 76 ++--- .../analysis/OutputTravelStatsTest.java | 6 +- .../core/config/ConfigReaderMatsimV2Test.java | 10 +- .../ConfigConsistencyCheckerImplTest.java | 18 +- .../groups/ReplanningConfigGroupTest.java | 4 +- .../config/groups/RoutingConfigGroupTest.java | 22 +- .../config/groups/ScoringConfigGroupTest.java | 18 +- .../core/controler/AbstractModuleTest.java | 2 +- .../core/controler/ControlerEventsTest.java | 6 +- .../matsim/core/controler/ControlerIT.java | 218 ++++++------- .../ControlerMobsimIntegrationTest.java | 26 +- .../controler/MatsimServicesImplTest.java | 22 +- .../core/controler/MobsimListenerTest.java | 20 +- .../core/controler/NewControlerTest.java | 4 +- .../controler/OverrideCarTraveltimeTest.java | 6 +- .../core/controler/PrepareForSimImplTest.java | 207 ++++++------ .../core/controler/TerminationTest.java | 14 +- .../TransitControlerIntegrationTest.java | 14 +- .../corelisteners/ListenersInjectionTest.java | 4 +- .../corelisteners/PlansDumpingIT.java | 24 +- .../mobsim/hermes/HermesRoundaboutTest.java | 20 +- .../mobsim/hermes/StorageCapacityTest.java | 2 +- .../mobsim/qsim/AbstractQSimModuleTest.java | 16 +- .../mobsim/qsim/AgentNotificationTest.java | 2 +- .../qsim/NetsimRoutingConsistencyTest.java | 6 +- .../core/mobsim/qsim/NodeTransitionTest.java | 12 +- .../qsim/QSimEventsIntegrationTest.java | 8 +- ...TeleportationEngineWDistanceCheckTest.java | 10 +- .../core/mobsim/qsim/VehicleSourceTest.java | 16 +- .../DeparturesOnSameLinkSameTimeTest.java | 34 +- .../FlowEfficiencyCalculatorTest.java | 6 +- .../LinkSpeedCalculatorIntegrationTest.java | 2 +- .../qnetsimengine/QSimComponentsTest.java | 24 +- ...onfigurableQNetworkFactoryExampleTest.java | 8 +- .../SimulatedLaneFlowCapacityTest.java | 8 +- .../qnetsimengine/SpeedCalculatorTest.java | 2 +- .../qnetsimengine/VehicleHandlerTest.java | 8 +- .../network/io/NetworkReprojectionIOTest.java | 8 +- .../io/PopulationReprojectionIOIT.java | 8 +- .../routes/RouteFactoryIntegrationTest.java | 16 +- .../annealing/ReplanningAnnealerTest.java | 30 +- .../modules/ExternalModuleTest.java | 6 +- .../selectors/ExpBetaPlanSelectorTest.java | 14 +- .../selectors/PathSizeLogitSelectorTest.java | 8 +- ...eterministicMultithreadedReplanningIT.java | 30 +- .../strategies/InnovationSwitchOffTest.java | 22 +- .../router/FallbackRoutingModuleTest.java | 6 +- ...workRoutingInclAccessEgressModuleTest.java | 34 +- .../core/router/NetworkRoutingModuleTest.java | 12 +- .../PseudoTransitRoutingModuleTest.java | 8 +- .../org/matsim/core/router/RoutingIT.java | 2 +- .../router/TripRouterFactoryImplTest.java | 8 +- .../core/router/TripRouterModuleTest.java | 2 +- ...izingTimeDistanceTravelDisutilityTest.java | 4 +- .../core/router/old/PlanRouterTest.java | 8 +- .../core/scoring/EventsToScoreTest.java | 10 +- ...ScoringFunctionsForPopulationStressIT.java | 18 +- .../CharyparNagelScoringFunctionTest.java | 92 +++--- .../CharyparNagelWithSubpopulationsTest.java | 2 +- .../TravelTimeCalculatorModuleTest.java | 2 +- .../core/utils/misc/ConfigUtilsTest.java | 2 +- .../utils/timing/TimeInterpretationTest.java | 6 +- .../counts/CountsControlerListenerTest.java | 88 ++--- .../counts/CountsReprojectionIOTest.java | 5 +- .../java/org/matsim/examples/EquilTest.java | 2 +- .../examples/OnePercentBerlin10sIT.java | 6 +- .../org/matsim/examples/PtTutorialIT.java | 24 +- .../matsim/examples/simple/PtScoringTest.java | 24 +- .../ActivityFacilitiesSourceTest.java | 28 +- .../ActivityWithOnlyFacilityIdTest.java | 4 +- .../FacilitiesReprojectionIOTest.java | 8 +- .../integration/EquilTwoAgentsTest.java | 8 +- .../integration/SimulateAndScoreTest.java | 28 +- .../InvertedNetworkRoutingIT.java | 20 +- .../InvertedNetworkRoutingTestFixture.java | 12 +- .../integration/invertednetworks/LanesIT.java | 8 +- .../NonAlternatingPlanElementsIT.java | 50 +-- .../pt/TransitIntegrationTest.java | 14 +- .../ChangeTripModeIntegrationTest.java | 2 +- .../integration/replanning/ReRoutingIT.java | 22 +- .../replanning/ResumableRunsIT.java | 22 +- .../matsim/modules/ScoreStatsModuleTest.java | 6 +- .../analysis/TransitLoadIntegrationTest.java | 10 +- ...ransitRouterNetworkTravelTimeCostTest.java | 20 +- .../router/TransitRouterCustomDataTest.java | 51 ++- .../pt/router/TransitRouterImplTest.java | 50 +-- .../pt/router/TransitRouterModuleTest.java | 14 +- ...ransitRouterNetworkTravelTimeCostTest.java | 20 +- .../TransitScheduleReprojectionIOTest.java | 28 +- .../org/matsim/testcases/MatsimTestUtils.java | 19 +- .../ExampleWithinDayControllerTest.java | 4 +- .../ExperiencedPlansWriterTest.java | 16 +- .../tools/ActivityReplanningMapTest.java | 14 +- .../tools/LinkReplanningMapTest.java | 6 +- .../WithinDayTravelTimeTest.java | 16 +- ...TravelTimeWithNetworkChangeEventsTest.java | 14 +- .../withinday/utils/EditRoutesTest.java | 24 +- 471 files changed, 3968 insertions(+), 4028 deletions(-) diff --git a/benchmark/src/main/java/org/matsim/benchmark/Benchmark.java b/benchmark/src/main/java/org/matsim/benchmark/Benchmark.java index 9c11ff9f623..addf157f821 100644 --- a/benchmark/src/main/java/org/matsim/benchmark/Benchmark.java +++ b/benchmark/src/main/java/org/matsim/benchmark/Benchmark.java @@ -32,7 +32,7 @@ public class Benchmark { public static void main(String[] args) throws IOException { Config config = ConfigUtils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("benchmark"), "config.xml")); Controler ctl = new Controler(config); - ctl.getConfig().controler().setCreateGraphs(false); + ctl.getConfig().controller().setCreateGraphs(false); ctl.run(); } diff --git a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/AccessibilityComputationNairobiLandUseLocalCopy.java b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/AccessibilityComputationNairobiLandUseLocalCopy.java index ef0f7fdc022..91e6e1c72ca 100644 --- a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/AccessibilityComputationNairobiLandUseLocalCopy.java +++ b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/AccessibilityComputationNairobiLandUseLocalCopy.java @@ -39,26 +39,26 @@ */ class AccessibilityComputationNairobiLandUseLocalCopy { public static final Logger LOG = LogManager.getLogger(AccessibilityComputationNairobiLandUseLocalCopy.class); - + public static void main(String[] args) { int tileSize_m = 500; boolean push2Geoserver = false; // Set true for run on server boolean createQGisOutput = true; // Set false for run on server - + final Config config = ConfigUtils.createConfig(new AccessibilityConfigGroup()); - + Envelope envelope = new Envelope(246000, 271000, 9853000, 9863000); // Central part of Nairobi String scenarioCRS = "EPSG:21037"; // EPSG:21037 = Arc 1960 / UTM zone 37S, for Nairobi, Kenya - + config.network().setInputFile("../nairobi/data/nairobi/input/2015-10-15_network.xml"); config.facilities().setInputFile("../nairobi/data/land_use/Nairobi_LU_2010/facilities.xml"); String runId = "ke_nairobi_landuse_hexagons_" + tileSize_m; - config.controler().setOutputDirectory("../nairobi/data/nairobi/output/" + runId + "_lcpt_par4_car_tr-7_500/"); - config.controler().setRunId(runId); - - config.controler().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); - config.controler().setLastIteration(0); - + config.controller().setOutputDirectory("../nairobi/data/nairobi/output/" + runId + "_lcpt_par4_car_tr-7_500/"); + config.controller().setRunId(runId); + + config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); + config.controller().setLastIteration(0); + AccessibilityConfigGroup acg = ConfigUtils.addOrGetModule(config, AccessibilityConfigGroup.class); acg.setAreaOfAccessibilityComputation(AreaOfAccesssibilityComputation.fromBoundingBoxHexagons); acg.setEnvelope(envelope); @@ -69,17 +69,17 @@ public static void main(String[] args) { acg.setOutputCrs(scenarioCRS); //acg.setUseParallelization(false); - + ConfigUtils.setVspDefaults(config); - + final Scenario scenario = ScenarioUtils.loadScenario(config); - + // final List activityTypes = Arrays.asList(new String[]{"educational", "commercial", "industrial", "recreational", "water_body"}); final List activityTypes = Arrays.asList(new String[]{"educational"}); final ActivityFacilities densityFacilities = AccessibilityUtils.createFacilityForEachLink(Labels.DENSITIY, scenario.getNetwork()); - + final Controler controler = new Controler(scenario); - + for (String activityType : activityTypes) { AccessibilityModule module = new AccessibilityModule(); module.setConsideredActivityType(activityType); @@ -88,17 +88,17 @@ public static void main(String[] args) { module.setCreateQGisOutput(createQGisOutput); controler.addOverridingModule(module); } - + controler.run(); - + if (createQGisOutput) { final Integer range = 9; // In the current implementation, this must always be 9 final Double lowerBound = -3.5; // (upperBound - lowerBound) ideally nicely divisible by (range - 2) final Double upperBound = 3.5; final int populationThreshold = (int) (10 / (1000/tileSize_m * 1000/tileSize_m)); // People per km^2 or roads (?) - + String osName = System.getProperty("os.name"); - String workingDirectory = config.controler().getOutputDirectory(); + String workingDirectory = config.controller().getOutputDirectory(); for (String actType : activityTypes) { String actSpecificWorkingDirectory = workingDirectory + actType + "/"; for (Modes4Accessibility mode : acg.getIsComputingMode()) { diff --git a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/AccessibilityComputationShutdownListener.java b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/AccessibilityComputationShutdownListener.java index d0c887adcc3..39637e1228f 100644 --- a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/AccessibilityComputationShutdownListener.java +++ b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/AccessibilityComputationShutdownListener.java @@ -68,7 +68,7 @@ public AccessibilityComputationShutdownListener(Scenario scenario, ActivityFacil this.outputDirectory = outputDirectory; this.acg = ConfigUtils.addOrGetModule(scenario.getConfig(), AccessibilityConfigGroup.GROUP_NAME, AccessibilityConfigGroup.class); - this.cnScoringGroup = scenario.getConfig().planCalcScore(); + this.cnScoringGroup = scenario.getConfig().scoring(); if (cnScoringGroup.getOrCreateModeParams(TransportMode.car).getMarginalUtilityOfDistance() != 0.) { LOG.error("Marginal utility of distance for car different from zero, but not used in accessibility computations"); diff --git a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/AccessibilityFromEvents.java b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/AccessibilityFromEvents.java index 476471ebd8c..b200e3a46f0 100644 --- a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/AccessibilityFromEvents.java +++ b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/AccessibilityFromEvents.java @@ -58,7 +58,7 @@ private AccessibilityFromEvents( Scenario scenario, String eventsFile, List map = new LinkedHashMap<>( ) ; EventsManager events = EventsUtils.createEventsManager(); - for( String mode : scenario.getConfig().plansCalcRoute().getNetworkModes() ){ + for( String mode : scenario.getConfig().routing().getNetworkModes() ){ TravelTimeCalculator.Builder builder = new TravelTimeCalculator.Builder( scenario.getNetwork() ); builder.setCalculateLinkTravelTimes( true ); builder.setCalculateLinkToLinkTravelTimes( false ); @@ -74,7 +74,7 @@ public void run() { install( new ScenarioByInstanceModule( scenario ) ) ; install( new TripRouterModule() ) ; install( new TimeInterpretationModule() ); - for( String mode : getConfig().plansCalcRoute().getNetworkModes() ){ + for( String mode : getConfig().routing().getNetworkModes() ){ addTravelTimeBinding( mode ).toInstance( map.get(mode) ); } install( new TravelDisutilityModule() ) ; diff --git a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/AccessibilityModule.java b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/AccessibilityModule.java index 19c98283c02..c4677dd3fd3 100644 --- a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/AccessibilityModule.java +++ b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/AccessibilityModule.java @@ -139,7 +139,7 @@ public ControlerListener get() { } AccessibilityUtils.assignAdditionalFacilitiesDataToMeasurePoint(measuringPoints, measurePointGeometryMap, additionalFacs); - String outputDirectory = scenario.getConfig().controler().getOutputDirectory() + "/" + activityType; + String outputDirectory = scenario.getConfig().controller().getOutputDirectory() + "/" + activityType; AccessibilityComputationShutdownListener accessibilityShutdownListener = new AccessibilityComputationShutdownListener(scenario, measuringPoints, opportunities, outputDirectory); // for (Modes4Accessibility mode : acg.getIsComputingMode()) { @@ -150,14 +150,14 @@ public ControlerListener get() { final TravelDisutilityFactory travelDisutilityFactory = travelDisutilityFactories.get(TransportMode.car); Gbl.assertNotNull(travelDisutilityFactory); calculator = new NetworkModeAccessibilityExpContributionCalculator(mode, new FreeSpeedTravelTime(), travelDisutilityFactory, scenario); - } else if ( config.plansCalcRoute().getNetworkModes().contains( mode ) ) { + } else if ( config.routing().getNetworkModes().contains( mode ) ) { final TravelTime nwModeTravelTime = travelTimes.get(mode); Gbl.assertNotNull(nwModeTravelTime); final TravelDisutilityFactory nwModeTravelDisutility = travelDisutilityFactories.get(mode); Gbl.assertNotNull( nwModeTravelDisutility ); calculator = new NetworkModeAccessibilityExpContributionCalculator(mode, nwModeTravelTime, nwModeTravelDisutility, scenario); } else if ( TransportMode.pt.equals( mode ) ){ - calculator = new SwissRailRaptorAccessibilityContributionCalculator( mode, config.planCalcScore(), scenario ); + calculator = new SwissRailRaptorAccessibilityContributionCalculator( mode, config.scoring(), scenario ); } else if ( Modes4Accessibility.matrixBasedPt.name().equals( mode ) ) { throw new RuntimeException("currently not supported because implementation not consistent with guice grapher. kai, sep'19") ; // calculator = new LeastCostPathCalculatorAccessibilityContributionCalculator( @@ -175,7 +175,7 @@ public ControlerListener get() { if ( travelDisutilityFactory==null ) { throw new RuntimeException("mode=" + mode + "; travelDisutilityFactory is null!") ; } - calculator = new TripRouterAccessibilityContributionCalculator(mode, tripRouter, config.planCalcScore(), scenario, + calculator = new TripRouterAccessibilityContributionCalculator(mode, tripRouter, config.scoring(), scenario, travelTime, travelDisutilityFactory ); } @@ -195,7 +195,7 @@ public ControlerListener get() { } Set additionalFacInfo = additionalFacs.keySet(); accessibilityShutdownListener.addFacilityDataExchangeListener(new GeoserverUpdater(acg.getOutputCrs(), - config.controler().getRunId() + "_" + activityType, measurePointGeometryMap, additionalFacInfo, + config.controller().getRunId() + "_" + activityType, measurePointGeometryMap, additionalFacInfo, outputDirectory, pushing2Geoserver, createQGisOutput)); } diff --git a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/AccessibilityUtils.java b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/AccessibilityUtils.java index ffbecca870f..db9adc47ccd 100644 --- a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/AccessibilityUtils.java +++ b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/AccessibilityUtils.java @@ -65,7 +65,7 @@ public static final Map, AggregationObject> aggregat // yyyy this method ignores the "capacities" of the facilities. kai, mar'14 // for now, we decided not to add "capacities" as it is not needed for current projects. dz, feb'16 - double walkSpeed_m_h = config.plansCalcRoute().getTeleportedModeSpeeds().get(TransportMode.walk) * 3600.; + double walkSpeed_m_h = config.routing().getTeleportedModeSpeeds().get(TransportMode.walk) * 3600.; AccessibilityConfigGroup acg = ConfigUtils.addOrGetModule(config, AccessibilityConfigGroup.GROUP_NAME, AccessibilityConfigGroup.class); LOG.info("Aggregating " + opportunities.getFacilities().size() + " opportunities with same nearest node..."); @@ -76,11 +76,11 @@ public static final Map, AggregationObject> aggregat double distance_m = NetworkUtils.getEuclideanDistance(opportunity.getCoord(), nearestNode.getCoord()); // in MATSim this is [utils/h]: cnScoringGroup.getTravelingWalk_utils_hr() - cnScoringGroup.getPerforming_utils_hr() - double walkBetaTT_utils_h = config.planCalcScore().getModes().get(TransportMode.walk).getMarginalUtilityOfTraveling() - - config.planCalcScore().getPerforming_utils_hr(); // default values: -12 = (-6.) - (6.) + double walkBetaTT_utils_h = config.scoring().getModes().get(TransportMode.walk).getMarginalUtilityOfTraveling() + - config.scoring().getPerforming_utils_hr(); // default values: -12 = (-6.) - (6.) double VjkWalkTravelTime = walkBetaTT_utils_h * (distance_m / walkSpeed_m_h); - double expVjk = Math.exp(config.planCalcScore().getBrainExpBeta() * VjkWalkTravelTime); + double expVjk = Math.exp(config.scoring().getBrainExpBeta() * VjkWalkTravelTime); // add Vjk to sum AggregationObject jco = opportunityClusterMap.get(nearestNode.getId()); // Why "jco"? diff --git a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/ConstantSpeedAccessibilityExpContributionCalculator.java b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/ConstantSpeedAccessibilityExpContributionCalculator.java index e950dac5b72..90179912f8d 100644 --- a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/ConstantSpeedAccessibilityExpContributionCalculator.java +++ b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/ConstantSpeedAccessibilityExpContributionCalculator.java @@ -77,7 +77,7 @@ public ConstantSpeedAccessibilityExpContributionCalculator(final String mode, fi this.scenario = scenario; this.config = scenario.getConfig(); - final ScoringConfigGroup scoringConfigGroup = config.planCalcScore() ; + final ScoringConfigGroup scoringConfigGroup = config.scoring() ; if (scoringConfigGroup.getOrCreateModeParams(mode).getMonetaryDistanceRate() != 0.) { LOG.error("Monetary distance cost rate for " + mode + " different from zero, but not used in accessibility computations"); @@ -85,10 +85,10 @@ public ConstantSpeedAccessibilityExpContributionCalculator(final String mode, fi logitScaleParameter = scoringConfigGroup.getBrainExpBeta(); - if (config.plansCalcRoute().getTeleportedModeSpeeds().get(mode) == null) { + if (config.routing().getTeleportedModeSpeeds().get(mode) == null) { LOG.error("No teleported mode speed for mode " + mode + " set."); } - this.modeSpeed_m_h = config.plansCalcRoute().getTeleportedModeSpeeds().get(mode) * 3600.; + this.modeSpeed_m_h = config.routing().getTeleportedModeSpeeds().get(mode) * 3600.; final ScoringConfigGroup.ModeParams modeParams = scoringConfigGroup.getOrCreateModeParams(mode); betaModeTT = modeParams.getMarginalUtilityOfTraveling() - scoringConfigGroup.getPerforming_utils_hr(); @@ -97,7 +97,7 @@ public ConstantSpeedAccessibilityExpContributionCalculator(final String mode, fi betaWalkTT = scoringConfigGroup.getModes().get(TransportMode.walk).getMarginalUtilityOfTraveling() - scoringConfigGroup.getPerforming_utils_hr(); betaWalkTD = scoringConfigGroup.getModes().get(TransportMode.walk).getMarginalUtilityOfDistance(); - this.walkSpeed_m_h = config.plansCalcRoute().getTeleportedModeSpeeds().get(TransportMode.walk) * 3600; + this.walkSpeed_m_h = config.routing().getTeleportedModeSpeeds().get(TransportMode.walk) * 3600; } diff --git a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/NetworkModeAccessibilityExpContributionCalculator.java b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/NetworkModeAccessibilityExpContributionCalculator.java index 957fa637748..ff5aee3d9fa 100644 --- a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/NetworkModeAccessibilityExpContributionCalculator.java +++ b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/NetworkModeAccessibilityExpContributionCalculator.java @@ -68,7 +68,7 @@ public NetworkModeAccessibilityExpContributionCalculator(String mode, final Trav Gbl.assertNotNull(travelDisutilityFactory); this.travelDisutility = travelDisutilityFactory.createTravelDisutility(travelTime); - scoringConfigGroup = scenario.getConfig().planCalcScore(); + scoringConfigGroup = scenario.getConfig().scoring(); networkConfigGroup = scenario.getConfig().network(); RoadPricingScheme scheme = (RoadPricingScheme) scenario.getScenarioElement( RoadPricingScheme.ELEMENT_NAME ); @@ -80,7 +80,7 @@ public NetworkModeAccessibilityExpContributionCalculator(String mode, final Trav betaWalkTT = scoringConfigGroup.getModes().get(TransportMode.walk).getMarginalUtilityOfTraveling() - scoringConfigGroup.getPerforming_utils_hr(); - this.walkSpeed_m_s = scenario.getConfig().plansCalcRoute().getTeleportedModeSpeeds().get(TransportMode.walk); + this.walkSpeed_m_s = scenario.getConfig().routing().getTeleportedModeSpeeds().get(TransportMode.walk); } diff --git a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/SwissRailRaptorAccessibilityContributionCalculator.java b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/SwissRailRaptorAccessibilityContributionCalculator.java index 2b13f5899b1..6fcd4466276 100644 --- a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/SwissRailRaptorAccessibilityContributionCalculator.java +++ b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/SwissRailRaptorAccessibilityContributionCalculator.java @@ -74,7 +74,7 @@ public SwissRailRaptorAccessibilityContributionCalculator(String mode, ScoringCo this.betaWalkTT = scoringConfigGroup.getModes().get(TransportMode.walk).getMarginalUtilityOfTraveling() - scoringConfigGroup.getPerforming_utils_hr(); - this.walkSpeed_m_h = scenario.getConfig().plansCalcRoute().getTeleportedModeSpeeds().get(TransportMode.walk) * 3600.; + this.walkSpeed_m_h = scenario.getConfig().routing().getTeleportedModeSpeeds().get(TransportMode.walk) * 3600.; } diff --git a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/TripRouterAccessibilityContributionCalculator.java b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/TripRouterAccessibilityContributionCalculator.java index 6941fb93087..2f027d9863c 100644 --- a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/TripRouterAccessibilityContributionCalculator.java +++ b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/TripRouterAccessibilityContributionCalculator.java @@ -90,7 +90,7 @@ public TripRouterAccessibilityContributionCalculator(String mode, TripRouter tri betaWalkTT = scoringConfigGroup.getModes().get(TransportMode.walk).getMarginalUtilityOfTraveling() - scoringConfigGroup.getPerforming_utils_hr(); - this.walkSpeed_m_s = scenario.getConfig().plansCalcRoute().getTeleportedModeSpeeds().get(TransportMode.walk); + this.walkSpeed_m_s = scenario.getConfig().routing().getTeleportedModeSpeeds().get(TransportMode.walk); this.travelTime = travelTime; this.travelDisutilityFactory = travelDisutilityFactory; diff --git a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/run/RunAccessibilityExample.java b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/run/RunAccessibilityExample.java index 53d94a2c1de..7db337954bd 100644 --- a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/run/RunAccessibilityExample.java +++ b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/run/RunAccessibilityExample.java @@ -46,7 +46,7 @@ public static void main(String[] args) { throw new RuntimeException("No config.xml file provided. The config file needs to reference a network file and a facilities file.") ; } Config config = ConfigUtils.loadConfig(args[0]); - config.controler().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); + config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); AccessibilityConfigGroup accConfig = ConfigUtils.addOrGetModule(config, AccessibilityConfigGroup.class ) ; accConfig.setComputingAccessibilityForMode(Modes4Accessibility.freespeed, true); @@ -54,11 +54,11 @@ public static void main(String[] args) { run(scenario); // The run method is extracted so that a test can operate on it. } - + public static void run(final Scenario scenario) { List activityTypes = AccessibilityUtils.collectAllFacilityOptionTypes(scenario); LOG.info("The following activity types were found: " + activityTypes); - + Controler controler = new Controler(scenario); for (final String actType : activityTypes) { // Add an overriding module for each activity type. final AccessibilityModule module = new AccessibilityModule(); diff --git a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/utils/GnuplotScriptWriter.java b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/utils/GnuplotScriptWriter.java index d9c1c029634..797211edc2b 100644 --- a/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/utils/GnuplotScriptWriter.java +++ b/contribs/accessibility/src/main/java/org/matsim/contrib/accessibility/utils/GnuplotScriptWriter.java @@ -34,7 +34,7 @@ */ public final class GnuplotScriptWriter { private static final Logger log = LogManager.getLogger( GnuplotScriptWriter.class ) ; - + private GnuplotScriptWriter() {} // do not instantiate public static void createGnuplotScript(Config config, List activityTypes) { @@ -49,37 +49,37 @@ public static void createGnuplotScript(Config config, List activityTypes log.error("skipping everything except freespeed for debugging purposes; remove in production code. dz, nov'14") ; continue ; } - + // the following might be made configurable if this is ever re-used: Boolean doPopulationWeightedPlot = true ; Boolean doNonPopulationWeightedPlot = true ; - - + + if (doPopulationWeightedPlot == false && doNonPopulationWeightedPlot == false) { throw new RuntimeException("At least one plot (pop-weighted or non-pop-weighted) needs to be activated."); } - + // produce gnuplot scripts try { - BufferedWriter writer = IOUtils.getBufferedWriter( config.controler().getOutputDirectory() + "/" + actType + BufferedWriter writer = IOUtils.getBufferedWriter( config.controller().getOutputDirectory() + "/" + actType + "/" + mode + "/t.gpl" ) ; // pm3d is an splot style for drawing palette-mapped 3d and 4d data as color/gray maps and surfaces (docu p.134) // To use pm3d coloring to generate a two-dimensional plot rather than a 3D surface, use set view map // or set pm3d map (p.135) writer.write("set pm3d map\n"); - + // flush { begin | center | end } writer.write("set pm3d flush begin\n") ; - + // corners2color { mean|geomean|median|min|max|c1|c2|c3|c4 } writer.write("set pm3d corners2color c1\n"); - + // The set style data command changes the default plotting style for data plots (docu p.148) // There are many plotting styles available in gnuplot. They are listed alphabetically below. The commands // set style data and set style function change the default plotting style for subsequent plot and splot // commands. (docu p.42) writer.write("set style data pm3d\n"); - + // Palette is a color storage for use by pm3d, filled color contours or polygons, color histograms, color gradient // background, and whatever it is or it will be implemented (docu p.137) // Gray-to-rgb mapping can be manually set by use of palette defined: A color gradient is defined and used @@ -87,86 +87,86 @@ public static void createGnuplotScript(Config config, List activityTypes // space [0,1]x[0,1]x[0,1]. You must specify the gray values and the corresponding RGB values between which // linear interpolation will be done (docu p.139) writer.write("set palette defined ( 0. '#ff0000', 0.82 '#ff0000', 0.86 '#00ff00', 0.9 '#0000ff', 1.0 '#0000ff' )\n"); - + // The set zrange command sets the range that will be displayed on the z axis. The zrange is used only by // splot and is ignored by plot (docu p.166) writer.write("#set zrange [-40:10]\n"); - + // The set cbrange command sets the range of values which are colored using the current palette by styles // with pm3d, with image and with palette. Values outside of the color range use color of the nearest // extreme (docu p.167) writer.write("#set cbrange [-0:10]\n"); - + // gnuplot supports many different graphics devices. Use set terminal to tell gnuplot what kind of output // to generate (docu p.152) // This terminal produces files in the Adobe Portable Document Format (PDF), useable for printing or display // with tools like Acrobat Reader (docu p.206) //writer.write("set term pdf size 25cm,20cm\n"); writer.write("set term pdf font 'Helvetica,6' size 25cm,20cm\n"); - + // The set view command sets the viewing angle for splots. It controls how the 3D coordinates of the plot are // mapped into the 2D screen space. It provides controls for both rotation and scaling of the plotted data, but // supports orthographic projections only (docu p.156) writer.write("#set view 45,30;\n"); writer.write("\n") ; - + // see docu p.137 writer.write("# set palette model HSV functions gray, 1, 1\n"); writer.write("\n"); - + // New user-defined variables and functions of one through twelve variables may be declared and used anywhere, // including on the plot command itself (docu p.30) // define minimum and maximum functions writer.write("min(a,b) = (a < b) ? a : b\n"); writer.write("max(a,b) = (a < b) ? b : a\n"); - + // define two variables writer.write("accmin=3 ; # accessibilities below this are red\n"); writer.write("accmax=9 ; # accessibilities above this are blue. max is around 12\n"); - + // define a function to determine the shade of gray. gray(acc) will have a value from 0 through 1 // Acc values equal to or below accmin lead to 0; acc values equal to or above accmax lead to 1 writer.write("gray(acc) = 2.*min( 1, max(0 , (acc-accmin)/(accmax-accmin) ) ) ;\n") ; writer.write("# I have no idea why this needs to be multiplied by 2. kai, feb'14\n") ; writer.write("\n") ; - + // consider population density // define two variables writer.write("densmax=1000 ; # 2726 is the maximum value in NMB\n") ; writer.write("maxwhite = 240 ; # 255 means that we go all the way to full white\n") ; - + while (doPopulationWeightedPlot == true || doNonPopulationWeightedPlot == true) { // define a function that gets the higher the smaller the population density // maxwhite*1 for pop dens = 0; maxwhite*0 for pop dens higher than densmax if (doPopulationWeightedPlot == true) { writer.write("val(dens) = max(0,maxwhite*(densmax-dens)/densmax) ;\n") ; - + // By default, screens are displayed to the standard output. The set output command redirects the display // to the specified file or device (docu p.132) writer.write("set out 'accessibility-pop-weighted.pdf'\n"); - + // The set title command produces a plot title that is centered at the top of the plot. set title is a special // case of set label (docu p.155) //writer.write("set title 'accessibility to " + actType + " by " + mode + " (population-weighted)'\n") ; - + doPopulationWeightedPlot = false; - + } else if (doNonPopulationWeightedPlot == true) { writer.write("val(dens) = 0. ; # unset this comment to get the non-pop-weighted version (for paper)\n"); writer.write("set out 'accessibility.pdf'\n"); //writer.write("set title 'accessibility to " + actType + " by " + mode + " (non-population-weighted)'\n") ; - + doNonPopulationWeightedPlot = false; } writer.write("\n") ; - + // define three color functions // so far not clear to me where the functions come from, dz mai14 writer.write("blue(acc,dens) = min(255, val(dens)+255*max(0,1.-2.*gray(acc)) ) ;\n") ; writer.write("green(acc,dens) = min(255, val(dens)+255*max(0,min(2.*gray(acc),2.-2.*gray(acc))) ) ;\n") ; writer.write("red(acc,dens) = min(255, val(dens)+255*max(0,2.*gray(acc)-1) ) ;\n") ; writer.write("\n") ; - + // define color function based on accessibility and population density // int(x) = integer part of x, truncated toward zero (docu p.26) // Example: rgb(r,g,b) = 65536 * int(r) + 256 * int(g) + int(b) (docu p.35) @@ -175,8 +175,8 @@ public static void createGnuplotScript(Config config, List activityTypes writer.write("\n") ; writer.write("unset colorbox ; # useless with lc rgb variable\n") ; writer.write("\n") ; // end new - - // plot csv file based on three values; first two are coordinates; third takes into account accessibility and + + // plot csv file based on three values; first two are coordinates; third takes into account accessibility and // population density and is calculated based on above-defined rgb formula // The "lc rgbcolor variable" tells the program to read RGB color information for each line in the data file. // This requires a corresponding additional column in the using specifier. The extra column is interpreted as a @@ -186,27 +186,27 @@ public static void createGnuplotScript(Config config, List activityTypes // writer.write("splot \"accessibilities.csv\" u 1:2:(rgb($3,$8)) lc rgb variable\n"); // writer.write("splot \"accessibilities.csv\" u 1:2:(rgb($3,$8)) notitle lc rgb variable\n"); } - + writer.close(); } catch (Exception ee ) { - ee.printStackTrace(); + ee.printStackTrace(); throw new RuntimeException( "writing t.gpl did not work") ; } - - + + // start running gnuplot with above-created script - + // If working on a Windows system, it is important that the environment variable PATH includes the gnuplot folder // so that gnuplot can be run from the folder where the data is stored (otherwise the relative paths won't work) String cmd = "gnuplot t.gpl"; - + // Doesn't work if root of directory is not passed - String stdoutFileName = config.controler().getOutputDirectory() + actType + "/" + mode + "/gnuplot.log"; + String stdoutFileName = config.controller().getOutputDirectory() + actType + "/" + mode + "/gnuplot.log"; // String stdoutFileName = config.controler().getOutputDirectory() + "gnuplot.log"; int timeout = 99999; - + // 4th argument = workingDirectory. Since we are working with relative paths, workingDirectory needs to be passed. - ExeRunner.run(cmd, stdoutFileName, timeout, config.controler().getOutputDirectory() + actType + "/" + mode); + ExeRunner.run(cmd, stdoutFileName, timeout, config.controller().getOutputDirectory() + actType + "/" + mode); } } } diff --git a/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/run/AccessibilityIntegrationTest.java b/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/run/AccessibilityIntegrationTest.java index 6c83fe6db43..b843e1ae3b5 100644 --- a/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/run/AccessibilityIntegrationTest.java +++ b/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/run/AccessibilityIntegrationTest.java @@ -132,14 +132,14 @@ public void testWithBoundingBoxConfigFile() { acg.setUseParallelization(false); ModeParams ptParams = new ModeParams(TransportMode.transit_walk); - config.planCalcScore().addModeParams(ptParams); + config.scoring().addModeParams(ptParams); MatrixBasedPtRouterConfigGroup mbConfig = ConfigUtils.addOrGetModule(config, MatrixBasedPtRouterConfigGroup.class) ; - config.plansCalcRoute().setRoutingRandomness(0.); + config.routing().setRoutingRandomness(0.); final Scenario sc = ScenarioUtils.loadScenario(config); - final PtMatrix ptMatrix = PtMatrix.createPtMatrix(config.plansCalcRoute(), BoundingBox.createBoundingBox(sc.getNetwork()), mbConfig) ; + final PtMatrix ptMatrix = PtMatrix.createPtMatrix(config.routing(), BoundingBox.createBoundingBox(sc.getNetwork()), mbConfig) ; sc.addScenarioElement(PtMatrix.NAME, ptMatrix); Controler controler = new Controler(sc); @@ -172,12 +172,12 @@ public void testWithBoundingBox() { acg.setBoundingBoxLeft(min); acg.setBoundingBoxRight(max); - config.plansCalcRoute().setRoutingRandomness(0.); + config.routing().setRoutingRandomness(0.); final Scenario sc = createTestScenario(config); MatrixBasedPtRouterConfigGroup mbConfig = ConfigUtils.addOrGetModule(config, MatrixBasedPtRouterConfigGroup.class ) ; - final PtMatrix ptMatrix = PtMatrix.createPtMatrix(config.plansCalcRoute(), BoundingBox.createBoundingBox(sc.getNetwork()), mbConfig) ; + final PtMatrix ptMatrix = PtMatrix.createPtMatrix(config.routing(), BoundingBox.createBoundingBox(sc.getNetwork()), mbConfig) ; sc.addScenarioElement(PtMatrix.NAME, ptMatrix); Controler controler = new Controler(sc); @@ -213,11 +213,11 @@ public void testWithBoundingBoxUsingOpportunityWeights() { acg.setUseOpportunityWeights(true); acg.setWeightExponent(2.); - config.plansCalcRoute().setRoutingRandomness(0.); + config.routing().setRoutingRandomness(0.); final Scenario sc = createTestScenarioUsingOpportunityWeights(config) ; MatrixBasedPtRouterConfigGroup mbConfig = ConfigUtils.addOrGetModule(config, MatrixBasedPtRouterConfigGroup.class ) ; - final PtMatrix ptMatrix = PtMatrix.createPtMatrix(config.plansCalcRoute(), BoundingBox.createBoundingBox(sc.getNetwork()), mbConfig) ; + final PtMatrix ptMatrix = PtMatrix.createPtMatrix(config.routing(), BoundingBox.createBoundingBox(sc.getNetwork()), mbConfig) ; sc.addScenarioElement(PtMatrix.NAME, ptMatrix); Controler controler = new Controler(sc); @@ -240,11 +240,11 @@ public void install() { public void testWithExtentDeterminedByNetwork() { final Config config = createTestConfig() ; - config.plansCalcRoute().setRoutingRandomness(0.); + config.routing().setRoutingRandomness(0.); final Scenario sc = createTestScenario(config) ; MatrixBasedPtRouterConfigGroup mbConfig = ConfigUtils.addOrGetModule(config, MatrixBasedPtRouterConfigGroup.class ) ; - final PtMatrix ptMatrix = PtMatrix.createPtMatrix(config.plansCalcRoute(), BoundingBox.createBoundingBox(sc.getNetwork()), mbConfig) ; + final PtMatrix ptMatrix = PtMatrix.createPtMatrix(config.routing(), BoundingBox.createBoundingBox(sc.getNetwork()), mbConfig) ; sc.addScenarioElement(PtMatrix.NAME, ptMatrix); Controler controler = new Controler(sc); @@ -280,11 +280,11 @@ public void testWithExtentDeterminedShapeFile() { // acg.setShapeFileCellBasedAccessibility(url.getPath()); // yyyyyy todo acg.setShapeFileCellBasedAccessibility(f.getAbsolutePath()); - config.plansCalcRoute().setRoutingRandomness(0.); + config.routing().setRoutingRandomness(0.); final Scenario sc = createTestScenario(config) ; MatrixBasedPtRouterConfigGroup mbConfig = ConfigUtils.addOrGetModule(config, MatrixBasedPtRouterConfigGroup.class ) ; - final PtMatrix ptMatrix = PtMatrix.createPtMatrix(config.plansCalcRoute(), BoundingBox.createBoundingBox(sc.getNetwork()), mbConfig) ; + final PtMatrix ptMatrix = PtMatrix.createPtMatrix(config.routing(), BoundingBox.createBoundingBox(sc.getNetwork()), mbConfig) ; sc.addScenarioElement(PtMatrix.NAME, ptMatrix); Controler controler = new Controler(sc); @@ -329,10 +329,10 @@ public void testWithPredefinedMeasuringPoints() { final Scenario sc = createTestScenario(config) ; MatrixBasedPtRouterConfigGroup mbConfig = ConfigUtils.addOrGetModule(config, MatrixBasedPtRouterConfigGroup.class ) ; - final PtMatrix ptMatrix = PtMatrix.createPtMatrix(config.plansCalcRoute(), BoundingBox.createBoundingBox(sc.getNetwork()), mbConfig) ; + final PtMatrix ptMatrix = PtMatrix.createPtMatrix(config.routing(), BoundingBox.createBoundingBox(sc.getNetwork()), mbConfig) ; sc.addScenarioElement(PtMatrix.NAME, ptMatrix); - config.plansCalcRoute().setRoutingRandomness(0.); + config.routing().setRoutingRandomness(0.); Controler controler = new Controler(sc); @@ -409,7 +409,7 @@ private Config createTestConfig() { config.transit().setVehiclesFile(utils.getClassInputDirectory() + "vehicles.xml"); ModeParams ptParams = new ModeParams(TransportMode.transit_walk); - config.planCalcScore().addModeParams(ptParams); + config.scoring().addModeParams(ptParams); MatrixBasedPtRouterConfigGroup mbConfig = new MatrixBasedPtRouterConfigGroup(); mbConfig.setPtStopsInputFile(utils.getClassInputDirectory() + "ptStops.csv"); @@ -419,9 +419,9 @@ private Config createTestConfig() { mbConfig.setUsingTravelTimesAndDistances(true); config.addModule(mbConfig); - config.controler().setLastIteration(0); - config.controler().setOutputDirectory(utils.getOutputDirectory()); - config.controler().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); + config.controller().setLastIteration(0); + config.controller().setOutputDirectory(utils.getOutputDirectory()); + config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); return config; } diff --git a/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/run/TinyAccessibilityTest.java b/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/run/TinyAccessibilityTest.java index bb5bcc2d5e7..29283b26ede 100644 --- a/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/run/TinyAccessibilityTest.java +++ b/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/run/TinyAccessibilityTest.java @@ -24,7 +24,6 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.Assert; -import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.matsim.api.core.v01.Coord; @@ -122,11 +121,11 @@ private Config createTestConfig() { acg.setComputingAccessibilityForMode(Modes4Accessibility.freespeed, true); acg.setComputingAccessibilityForMode(Modes4Accessibility.car, true); - config.controler().setLastIteration(0); - config.controler().setOutputDirectory(utils.getOutputDirectory()); - config.controler().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); + config.controller().setLastIteration(0); + config.controller().setOutputDirectory(utils.getOutputDirectory()); + config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); - config.plansCalcRoute().setRoutingRandomness(0.); + config.routing().setRoutingRandomness(0.); return config; } diff --git a/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/run/TinyMultimodalAccessibilityTest.java b/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/run/TinyMultimodalAccessibilityTest.java index c2abfc8df95..bde5a98c612 100644 --- a/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/run/TinyMultimodalAccessibilityTest.java +++ b/contribs/accessibility/src/test/java/org/matsim/contrib/accessibility/run/TinyMultimodalAccessibilityTest.java @@ -105,9 +105,9 @@ private Config createTestConfig() { acg.setComputingAccessibilityForMode(Modes4Accessibility.pt, true); acg.setUseParallelization(false); - config.controler().setLastIteration(0); - config.controler().setOutputDirectory(utils.getOutputDirectory()); - config.controler().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); + config.controller().setLastIteration(0); + config.controller().setOutputDirectory(utils.getOutputDirectory()); + config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); return config; } diff --git a/contribs/accidents/src/main/java/org/matsim/contrib/accidents/AccidentWriter.java b/contribs/accidents/src/main/java/org/matsim/contrib/accidents/AccidentWriter.java index 7476fab2e96..8f0b09a8ae2 100644 --- a/contribs/accidents/src/main/java/org/matsim/contrib/accidents/AccidentWriter.java +++ b/contribs/accidents/src/main/java/org/matsim/contrib/accidents/AccidentWriter.java @@ -41,14 +41,14 @@ class AccidentWriter { private static String convertSecondToHHMMSSString(int nSecondTime) { return LocalTime.MIN.plusSeconds(nSecondTime).toString(); } - + public void write(Scenario scenario, IterationEndsEvent event, Map, AccidentLinkInfo> linkId2info, AnalysisEventHandler analzyer) { AccidentsConfigGroup accidentsCfg = (AccidentsConfigGroup) scenario.getConfig().getModules().get(AccidentsConfigGroup.GROUP_NAME); - + double timeBinSize = scenario.getConfig().travelTimeCalculator().getTraveltimeBinSize(); - + //File with Linkinfo for Tests - File linkInfoFile = new File(scenario.getConfig().controler().getOutputDirectory() + "ITERS/it." + event.getIteration() + "/" + scenario.getConfig().controler().getRunId() + "." + event.getIteration() + ".linkInfo.csv"); + File linkInfoFile = new File(scenario.getConfig().controller().getOutputDirectory() + "ITERS/it." + event.getIteration() + "/" + scenario.getConfig().controller().getRunId() + "." + event.getIteration() + ".linkInfo.csv"); BufferedWriter linkInformation = null; try { linkInformation = new BufferedWriter (new FileWriter(linkInfoFile)); @@ -62,7 +62,7 @@ public void write(Scenario scenario, IterationEndsEvent event, Map, Acc } linkInformation.write("demandPerDay ;"); linkInformation.newLine(); - + for (AccidentLinkInfo info : linkId2info.values()) { double demandPerDay = 0.0; linkInformation.write(info.getLinkId().toString()); @@ -77,15 +77,15 @@ public void write(Scenario scenario, IterationEndsEvent event, Map, Acc linkInformation.write(Double.toString(demand)); linkInformation.write(";"); } - linkInformation.write(Double.toString(demandPerDay)); + linkInformation.write(Double.toString(demandPerDay)); linkInformation.newLine(); } linkInformation.close(); } catch (IOException e3) { e3.printStackTrace(); } - - File accidentCostsBVWPFile = new File(scenario.getConfig().controler().getOutputDirectory() + "ITERS/it." + event.getIteration() + "/" + scenario.getConfig().controler().getRunId() + "." + event.getIteration() + ".accidentCosts_BVWP.csv"); + + File accidentCostsBVWPFile = new File(scenario.getConfig().controller().getOutputDirectory() + "ITERS/it." + event.getIteration() + "/" + scenario.getConfig().controller().getRunId() + "." + event.getIteration() + ".accidentCosts_BVWP.csv"); BufferedWriter accidentCostsBVWP = null; try { accidentCostsBVWP = new BufferedWriter (new FileWriter(accidentCostsBVWPFile)); @@ -100,7 +100,7 @@ public void write(Scenario scenario, IterationEndsEvent event, Map, Acc accidentCostsBVWP.write("Costs per Day [EUR] ;"); accidentCostsBVWP.write("Costs per Year [EUR] ;"); accidentCostsBVWP.newLine(); - + } catch (IOException e1) { e1.printStackTrace(); } @@ -109,7 +109,7 @@ public void write(Scenario scenario, IterationEndsEvent event, Map, Acc nf.setMaximumFractionDigits(2); nf.setGroupingUsed(false); - for (AccidentLinkInfo info : linkId2info.values()) { + for (AccidentLinkInfo info : linkId2info.values()) { double accidentCostsPerDay_BVWP = 0.0; double accidentCostsPerYear_BVWP = 0.0; @@ -123,12 +123,12 @@ public void write(Scenario scenario, IterationEndsEvent event, Map, Acc } catch (IOException e1) { e1.printStackTrace(); } - + for (double endTime = timeBinSize ; endTime <= scenario.getConfig().travelTimeCalculator().getMaxTime(); endTime = endTime + timeBinSize ) { - + double time = (endTime - timeBinSize/2.); int timeBinNr = (int) (time / timeBinSize); - + if (linkComputationMethod.toString().equals( AccidentsConfigGroup.AccidentsComputationMethod.BVWP.toString() )){ accidentCostsPerDay_BVWP += info.getTimeSpecificInfo().get(timeBinNr).getAccidentCosts(); try { diff --git a/contribs/accidents/src/main/java/org/matsim/contrib/accidents/runExample/RunAccidents.java b/contribs/accidents/src/main/java/org/matsim/contrib/accidents/runExample/RunAccidents.java index b9fe07dc88c..a25d3512e71 100644 --- a/contribs/accidents/src/main/java/org/matsim/contrib/accidents/runExample/RunAccidents.java +++ b/contribs/accidents/src/main/java/org/matsim/contrib/accidents/runExample/RunAccidents.java @@ -44,44 +44,44 @@ public class RunAccidents { private static final Logger log = LogManager.getLogger(RunAccidents.class); - - public static void main(String[] args) throws IOException { + + public static void main(String[] args) throws IOException { RunAccidents main = new RunAccidents(); main.run(); } private void run() throws MalformedURLException, IOException { log.info("Loading scenario..."); - + String configFile = "path/to/configFile.xml"; - + Config config = ConfigUtils.loadConfig(configFile ); - + AccidentsConfigGroup accidentsSettings = ConfigUtils.addOrGetModule(config, AccidentsConfigGroup.class); accidentsSettings.setEnableAccidentsModule(true); - + final Scenario scenario = ScenarioUtils.loadScenario(config); - + // Preprocess network AccidentsNetworkModification networkModification = new AccidentsNetworkModification(scenario); - + String[] tunnelLinks = readCSVFile("tunnelLinksCSVfile"); String[] planfreeLinks = readCSVFile("planfreeLinksCSVfile"); - + networkModification.setLinkAttributsBasedOnOSMFile("osmlandUseFile", "EPSG:31468" , tunnelLinks, planfreeLinks ); - + Controler controler = new Controler(scenario); controler.addOverridingModule(new AccidentsModule()); - - controler.getConfig().controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists); + + controler.getConfig().controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists); controler.run(); } - + private String[] readCSVFile(String csvFile) { ArrayList> links = new ArrayList<>(); BufferedReader br = IOUtils.getBufferedReader(csvFile); - + String line = null; try { line = br.readLine(); @@ -92,7 +92,7 @@ private String[] readCSVFile(String csvFile) { try { int countWarning = 0; while ((line = br.readLine()) != null) { - + String[] columns = line.split(";"); Id linkId = null; for (int column = 0; column < columns.length; column++) { @@ -105,7 +105,7 @@ private String[] readCSVFile(String csvFile) { log.warn("This message is only given once."); } countWarning++; - } + } } log.info("Adding link ID " + linkId); links.add(linkId); @@ -113,7 +113,7 @@ private String[] readCSVFile(String csvFile) { } catch (IOException e) { e.printStackTrace(); } - + String[] linkIDsArray = (String[]) links.toArray(); return linkIDsArray ; } diff --git a/contribs/accidents/src/test/java/org/matsim/contrib/accidents/RunTest.java b/contribs/accidents/src/test/java/org/matsim/contrib/accidents/RunTest.java index 3fa83d471d3..b98c144164f 100644 --- a/contribs/accidents/src/test/java/org/matsim/contrib/accidents/RunTest.java +++ b/contribs/accidents/src/test/java/org/matsim/contrib/accidents/RunTest.java @@ -19,57 +19,57 @@ /** * @author ikaddoura, mmayobre - * - * + * + * */ public class RunTest { @Rule public MatsimTestUtils utils = new MatsimTestUtils(); - + @Test public void test1() { String configFile = utils.getPackageInputDirectory() + "/trial_scenario/trial_scenario_config.xml"; String outputDirectory = utils.getOutputDirectory(); String runId = "run1"; - + Config config = ConfigUtils.loadConfig(configFile); - config.controler().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); - - config.controler().setOutputDirectory(outputDirectory); - config.controler().setRunId(runId); - + config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); + + config.controller().setOutputDirectory(outputDirectory); + config.controller().setRunId(runId); + AccidentsConfigGroup accidentsSettings = ConfigUtils.addOrGetModule(config, AccidentsConfigGroup.class); accidentsSettings.setEnableAccidentsModule(true); - + final Scenario scenario = ScenarioUtils.loadScenario(config); - + // pre-process network for (Link link : scenario.getNetwork().getLinks().values()) { link.getAttributes().putAttribute(accidentsSettings.getAccidentsComputationMethodAttributeName(), AccidentsComputationMethod.BVWP.toString()); - + int numberOfLanesBVWP; if (link.getNumberOfLanes() > 4){ numberOfLanesBVWP = 4; } else { numberOfLanesBVWP = (int) link.getNumberOfLanes(); } - + if (link.getFreespeed() > 16.) { link.getAttributes().putAttribute( AccidentsConfigGroup.BVWP_ROAD_TYPE_ATTRIBUTE_NAME, "1,0," + numberOfLanesBVWP); } else { link.getAttributes().putAttribute( AccidentsConfigGroup.BVWP_ROAD_TYPE_ATTRIBUTE_NAME, "1,2," + numberOfLanesBVWP); - } + } } - + Controler controler = new Controler(scenario); - + controler.addOverridingModule(new AccidentsModule() ); - + controler.run(); - + BufferedReader br = IOUtils.getBufferedReader(outputDirectory + "ITERS/it.0/run1.0.accidentCosts_BVWP.csv"); - + String line = null; try { line = br.readLine(); @@ -80,27 +80,27 @@ public void test1() { try { int lineCounter = 0; while ((line = br.readLine()) != null) { - + String[] columns = line.split(";"); for (int column = 0; column < columns.length; column++) { - + if (lineCounter == 0 && column == 25) { double accidentCosts = Double.valueOf(columns[column]); Assert.assertEquals("wrong accident costs", 10.38, accidentCosts , MatsimTestUtils.EPSILON); } - + if (lineCounter == 1 && column == 25) { double accidentCosts = Double.valueOf(columns[column]); Assert.assertEquals("wrong accident costs", 16.68, accidentCosts , MatsimTestUtils.EPSILON); } - + } - + lineCounter++; } } catch (IOException e) { e.printStackTrace(); } - + } } diff --git a/contribs/accidents/src/test/java/org/matsim/contrib/accidents/RunTestEquil.java b/contribs/accidents/src/test/java/org/matsim/contrib/accidents/RunTestEquil.java index 3cd2bf28fe2..d537b8c40e4 100644 --- a/contribs/accidents/src/test/java/org/matsim/contrib/accidents/RunTestEquil.java +++ b/contribs/accidents/src/test/java/org/matsim/contrib/accidents/RunTestEquil.java @@ -20,54 +20,54 @@ public class RunTestEquil { @Rule public MatsimTestUtils utils = new MatsimTestUtils(); - - @Test + + @Test public void test1() { String configFile = utils.getPackageInputDirectory() + "/equil_scenario/config.xml"; String outputDirectory = utils.getOutputDirectory(); String runId = "run1"; - + Config config = ConfigUtils.loadConfig( configFile ); - config.controler().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); - - config.controler().setOutputDirectory( outputDirectory ); - config.controler().setRunId( runId ); - config.controler().setLastIteration(0); - + config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); + + config.controller().setOutputDirectory( outputDirectory ); + config.controller().setRunId( runId ); + config.controller().setLastIteration(0); + AccidentsConfigGroup accidentsSettings = ConfigUtils.addOrGetModule(config, AccidentsConfigGroup.class); accidentsSettings.setEnableAccidentsModule(true); - + final Scenario scenario = ScenarioUtils.loadScenario(config); Controler controler = new Controler (scenario); controler.addOverridingModule(new AccidentsModule() ); - - scenario.getNetwork().getLinks().get(Id.createLinkId("6")).setFreespeed(10); + + scenario.getNetwork().getLinks().get(Id.createLinkId("6")).setFreespeed(10); scenario.getNetwork().getLinks().get(Id.createLinkId("6")).setNumberOfLanes(3); - scenario.getNetwork().getLinks().get(Id.createLinkId("15")).setFreespeed(10); + scenario.getNetwork().getLinks().get(Id.createLinkId("15")).setFreespeed(10); scenario.getNetwork().getLinks().get(Id.createLinkId("15")).setNumberOfLanes(2); - + // pre-process network for (Link link : scenario.getNetwork().getLinks().values()) { link.getAttributes().putAttribute(accidentsSettings.getAccidentsComputationMethodAttributeName(), AccidentsComputationMethod.BVWP.toString()); - + int numberOfLanesBVWP; if (link.getNumberOfLanes() > 4){ numberOfLanesBVWP = 4; } else { numberOfLanesBVWP = (int) link.getNumberOfLanes(); } - + if (link.getFreespeed() > 16.) { link.getAttributes().putAttribute( AccidentsConfigGroup.BVWP_ROAD_TYPE_ATTRIBUTE_NAME, "1,0," + numberOfLanesBVWP); } else { link.getAttributes().putAttribute( AccidentsConfigGroup.BVWP_ROAD_TYPE_ATTRIBUTE_NAME, "1,2," + numberOfLanesBVWP); - } + } } - + controler.run(); - + BufferedReader br = IOUtils.getBufferedReader(outputDirectory + "ITERS/it.0/run1.0.accidentCosts_BVWP.csv"); - + String line = null; try { line = br.readLine(); @@ -78,10 +78,10 @@ public void test1() { try { int lineCounter = 0; while ((line = br.readLine()) != null) { - + String[] columns = line.split(";"); for (int column = 0; column < columns.length; column++) { - + // link 22 if (lineCounter == 1 && column == 121) { double accidentCosts = Double.valueOf(columns[column]); @@ -98,7 +98,7 @@ public void test1() { double accidentCostsManualCalculation = (agents * lengthKM * 61.785) / 1000. * 10; Assert.assertEquals("wrong accident costs", accidentCostsManualCalculation, accidentCosts , 0.01); } - + // link 6 if (lineCounter == 16 && column == 121) { double accidentCosts = Double.valueOf(columns[column]); @@ -106,8 +106,8 @@ public void test1() { int lengthKM = 10; double accidentCostsManualCalculation = (agents * lengthKM * 34.735) / 1000. * 10; Assert.assertEquals("wrong accident costs", accidentCostsManualCalculation, accidentCosts , 0.01); - } - + } + // link 15 if (lineCounter == 6 && column == 121) { double accidentCosts = Double.valueOf(columns[column]); @@ -117,7 +117,7 @@ public void test1() { Assert.assertEquals("wrong accident costs", accidentCostsManualCalculation, accidentCosts , 0.01); } } - + lineCounter++; } } catch (IOException e) { diff --git a/contribs/analysis/src/main/java/org/matsim/contrib/analysis/christoph/ActivitiesAnalyzer.java b/contribs/analysis/src/main/java/org/matsim/contrib/analysis/christoph/ActivitiesAnalyzer.java index 39c5b49040b..f78d2eaa421 100644 --- a/contribs/analysis/src/main/java/org/matsim/contrib/analysis/christoph/ActivitiesAnalyzer.java +++ b/contribs/analysis/src/main/java/org/matsim/contrib/analysis/christoph/ActivitiesAnalyzer.java @@ -54,21 +54,21 @@ * * @author cdobler */ -public class ActivitiesAnalyzer implements ActivityStartEventHandler, ActivityEndEventHandler, +public class ActivitiesAnalyzer implements ActivityStartEventHandler, ActivityEndEventHandler, StartupListener, BeforeMobsimListener, IterationEndsListener { public static String defaultActivitiesFileName = "activityCounts"; - + private final boolean autoConfig; - + private double endTime = 30*3600; - + private String activitiesFileName = defaultActivitiesFileName; private final Set observedAgents; private boolean createGraphs; private final Map> activityCountData = new TreeMap>(); private final LinkedList overallCount = new LinkedList(); - + /** * This is how most people will probably will use this class. * It has to be created an registered as ControlerListener. @@ -76,56 +76,56 @@ public class ActivitiesAnalyzer implements ActivityStartEventHandler, ActivityEn * get paths to output files, ...). */ public ActivitiesAnalyzer() { - + this.autoConfig = true; this.createGraphs = true; this.observedAgents = null; - + reset(0); } - + public ActivitiesAnalyzer(String activitiesFileName, Set activityTypes, boolean createGraphs) { this(activitiesFileName, activityTypes, null, createGraphs); } - + public ActivitiesAnalyzer(String activitiesFileName, Set activityTypes, Set observedAgents, boolean createGraphs) { - + this.autoConfig = false; - + this.activitiesFileName = activitiesFileName; this.createGraphs = createGraphs; - + // use all activity defined in the set for (String activityType : activityTypes) { this.activityCountData.put(activityType, new LinkedList()); } - + if (observedAgents != null) { // make a copy to prevent people changing the set over the iterations - this.observedAgents = new HashSet(observedAgents); + this.observedAgents = new HashSet(observedAgents); } else this.observedAgents = null; - + reset(0); } - + public void setCreateGraphs(boolean createGraphs) { this.createGraphs = createGraphs; } - + public void setEndTime(double endTime) { this.endTime = endTime; } - + @Override public void handleEvent(ActivityEndEvent event) { - + if (observedAgents != null && !observedAgents.contains(event.getPersonId())) return; - + LinkedList list = this.activityCountData.get(event.getActType()); - + // ignore not observed activity types if (list == null) return; - + changeCount(event.getTime(), list, -1); changeCount(event.getTime(), this.overallCount, -1); } @@ -133,22 +133,22 @@ public void handleEvent(ActivityEndEvent event) { @Override public void handleEvent(ActivityStartEvent event) { - + if (observedAgents != null && !observedAgents.contains(event.getPersonId())) return; - + LinkedList list = this.activityCountData.get(event.getActType()); // ignore not observed activity types if (list == null) return; - + changeCount(event.getTime(), list, 1); changeCount(event.getTime(), this.overallCount, 1); } - + private void changeCount(double time, LinkedList list, int delta) { - + ActivityData activityData = list.getLast(); - + /* * If there is already another entry for the same time step, re-use it. * Otherwise create a new one. @@ -159,7 +159,7 @@ private void changeCount(double time, LinkedList list, int delta) list.add(new ActivityData(time, activityData.activityCount + delta)); } } - + @Override public void reset(final int iter) { for (List list : this.activityCountData.values()) { @@ -169,40 +169,40 @@ public void reset(final int iter) { this.overallCount.clear(); this.overallCount.add(new ActivityData(0.0, 0)); } - + @Override public void notifyStartup(StartupEvent event) { - + MatsimServices controler = event.getServices(); - + if (autoConfig) { // use all activity types defined in the config - Set activityTypes = new TreeSet(event.getServices().getConfig().planCalcScore().getActivityTypes()); + Set activityTypes = new TreeSet(event.getServices().getConfig().scoring().getActivityTypes()); for (String activityType : activityTypes) { this.activityCountData.put(activityType, new LinkedList()); } - + controler.getEvents().addHandler(this); } } - + @Override public void notifyBeforeMobsim(BeforeMobsimEvent event) { - + ActivityData overallActivityData = this.overallCount.getLast(); for (Person person : event.getServices().getScenario().getPopulation().getPersons().values()) { - + if (this.observedAgents != null && !this.observedAgents.contains(person.getId())) continue; - + Plan plan = person.getSelectedPlan(); Activity firstActivity = (Activity) plan.getPlanElements().get(0); LinkedList list = activityCountData.get(firstActivity.getType()); - + // ignore not observed activity types if (list == null) continue; - + ActivityData activityData = list.getLast(); activityData.activityCount += 1; overallActivityData.activityCount += 1; @@ -211,19 +211,19 @@ public void notifyBeforeMobsim(BeforeMobsimEvent event) { @Override public void notifyIterationEnds(IterationEndsEvent event) { - + OutputDirectoryHierarchy outputDirectoryHierarchy = event.getServices().getControlerIO(); - + try { for (String activityType : this.activityCountData.keySet()) { String fileName = outputDirectoryHierarchy.getIterationFilename(event.getIteration(), this.activitiesFileName + "_" + activityType + ".txt"); BufferedWriter activitiesWriter = IOUtils.getBufferedWriter(fileName); - + activitiesWriter.write("TIME"); activitiesWriter.write("\t"); activitiesWriter.write(activityType.toUpperCase()); activitiesWriter.write("\n"); - + List list = this.activityCountData.get(activityType); for (ActivityData activityData : list) { activitiesWriter.write(String.valueOf(activityData.time)); @@ -231,18 +231,18 @@ public void notifyIterationEnds(IterationEndsEvent event) { activitiesWriter.write(String.valueOf(activityData.activityCount)); activitiesWriter.write("\n"); } - + activitiesWriter.flush(); activitiesWriter.close(); } } catch (IOException e) { throw new UncheckedIOException(e); } - + if (this.createGraphs) { // create chart when data of more than one iteration is available. XYLineChart chart; - + /* * number of performed activities */ @@ -250,7 +250,7 @@ public void notifyIterationEnds(IterationEndsEvent event) { for (String activityType : this.activityCountData.keySet()) { List list = this.activityCountData.get(activityType); int length = list.size(); - + double[] times = new double[length * 2 - 1]; double[] counts = new double[length * 2 - 1]; Iterator iter = list.iterator(); @@ -287,13 +287,13 @@ public void notifyIterationEnds(IterationEndsEvent event) { i += 2; } chart.addSeries("overall", times, counts); - + NumberAxis domainAxis = (NumberAxis) chart.getChart().getXYPlot().getDomainAxis(); domainAxis.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 11)); domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); domainAxis.setAutoRange(false); domainAxis.setRange(0, endTime / 3600.0); - + chart.addMatsimLogo(); String fileName = outputDirectoryHierarchy.getIterationFilename(event.getIteration(), this.activitiesFileName + ".png"); chart.saveAsPng(fileName, 800, 600); @@ -301,7 +301,7 @@ public void notifyIterationEnds(IterationEndsEvent event) { } private static class ActivityData { - + public final double time; public int activityCount; @@ -311,4 +311,4 @@ public ActivityData(double time, int activityCount) { } } -} \ No newline at end of file +} diff --git a/contribs/analysis/src/main/java/org/matsim/contrib/analysis/christoph/TripsAnalyzer.java b/contribs/analysis/src/main/java/org/matsim/contrib/analysis/christoph/TripsAnalyzer.java index e5ad1a32205..02c4ddd82f8 100644 --- a/contribs/analysis/src/main/java/org/matsim/contrib/analysis/christoph/TripsAnalyzer.java +++ b/contribs/analysis/src/main/java/org/matsim/contrib/analysis/christoph/TripsAnalyzer.java @@ -53,7 +53,7 @@ * - average leg travel time over all modes * - number of trips per mode * - number of trips over all modes - * + * * @author cdobler */ public class TripsAnalyzer implements PersonDepartureEventHandler, PersonArrivalEventHandler, @@ -63,23 +63,23 @@ public class TripsAnalyzer implements PersonDepartureEventHandler, PersonArrival public static String defaultDurationsFileName = "tripDurations"; private final boolean autoConfig; - + private final Set sortedModes = new TreeSet(); private final Set observedAgents; private final Map departureTimes = new HashMap(); private final Map> legTravelTimes = new HashMap>(); - + private String tripsFileName; private String durationsFileName; private boolean createGraphs; - + private BufferedWriter tripsWriter; private BufferedWriter durationWriter; - + private double[][] tripsHistory; private double[][] durationHistory; private int minIteration; - + /** * This is how most people will probably will use this class. * It has to be created an registered as ControlerListener. @@ -87,47 +87,47 @@ public class TripsAnalyzer implements PersonDepartureEventHandler, PersonArrival * get paths to output files, ...). */ public TripsAnalyzer() { - + this.autoConfig = true; this.createGraphs = true; - + // modes which are analyzed by default this.sortedModes.add(TransportMode.bike); this.sortedModes.add(TransportMode.car); this.sortedModes.add(TransportMode.pt); this.sortedModes.add(TransportMode.ride); this.sortedModes.add(TransportMode.walk); - + this.observedAgents = null; } - + public TripsAnalyzer(String tripsFileName, String durationsFileName, Set modes, boolean createGraphs) { this(tripsFileName, durationsFileName, modes, null, createGraphs); } - + public TripsAnalyzer(String tripsFileName, String durationsFileName, Set modes, Set observedAgents, boolean createGraphs) { this.autoConfig = false; - + this.tripsFileName = tripsFileName; this.durationsFileName = durationsFileName; this.sortedModes.addAll(modes); if (observedAgents != null) { // make a copy to prevent people changing the set over the iterations - this.observedAgents = new HashSet(observedAgents); + this.observedAgents = new HashSet(observedAgents); } else this.observedAgents = null; this.createGraphs = createGraphs; } - + public void setCreateGraphs(boolean createGraphs) { this.createGraphs = createGraphs; } - + public Set getModes() { return this.sortedModes; } - + @Override public void reset(int iteration) { for(List modeTravelTime : legTravelTimes.values()) { @@ -137,12 +137,12 @@ public void reset(int iteration) { @Override public void handleEvent(PersonArrivalEvent event) { - + if (observedAgents != null && !observedAgents.contains(event.getPersonId())) return; - + Double departureTime = departureTimes.remove(event.getPersonId()); if (departureTime == null) throw new RuntimeException("No departure time for agent " + event.getPersonId() + " was found!"); - + double travelTime = event.getTime() - departureTime; String mode = event.getLegMode(); List modeTravelTimes = legTravelTimes.get(mode); @@ -159,16 +159,16 @@ public void handleEvent(PersonDepartureEvent event) { public void notifyStartup(final StartupEvent event) { MatsimServices controler = event.getServices(); - this.minIteration = controler.getConfig().controler().getFirstIteration(); - int maxIter = controler.getConfig().controler().getLastIteration(); + this.minIteration = controler.getConfig().controller().getFirstIteration(); + int maxIter = controler.getConfig().controller().getLastIteration(); int iterations = maxIter - this.minIteration; this.tripsHistory = new double[this.sortedModes.size() + 1][iterations + 1]; - this.durationHistory = new double[this.sortedModes.size() + 1][iterations + 1]; - + this.durationHistory = new double[this.sortedModes.size() + 1][iterations + 1]; + if (autoConfig) { this.tripsFileName = event.getServices().getControlerIO().getOutputFilename(defaultTripsFileName); this.durationsFileName = event.getServices().getControlerIO().getOutputFilename(defaultDurationsFileName); - + controler.getEvents().addHandler(this); } @@ -183,7 +183,7 @@ public void notifyStartup(final StartupEvent event) { this.tripsWriter.write(mode.toUpperCase()); this.durationWriter.write("\t"); this.durationWriter.write(mode.toUpperCase()); - + this.legTravelTimes.put(mode, new LinkedList()); } this.tripsWriter.write("\t"); @@ -192,12 +192,12 @@ public void notifyStartup(final StartupEvent event) { this.durationWriter.write("\t"); this.durationWriter.write("OVERALL"); this.durationWriter.write("\n"); - + } catch (IOException e) { throw new UncheckedIOException(e); } } - + @Override public void notifyIterationEnds(IterationEndsEvent event) { try { @@ -205,7 +205,7 @@ public void notifyIterationEnds(IterationEndsEvent event) { this.tripsWriter.write(String.valueOf(iteration)); this.durationWriter.write(String.valueOf(iteration)); int index = iteration - this.minIteration; - + int i = 0; int overallTrips = 0; double overallTravelTime = 0.0; @@ -213,7 +213,7 @@ public void notifyIterationEnds(IterationEndsEvent event) { List modeTravelTimes = legTravelTimes.get(mode); double sumTravelTimes = 0.0; for (double travelTime : modeTravelTimes) sumTravelTimes += travelTime; - + int modeTrips = modeTravelTimes.size(); overallTrips += modeTrips; overallTravelTime += sumTravelTimes; @@ -221,19 +221,19 @@ public void notifyIterationEnds(IterationEndsEvent event) { double averageTravelTime = sumTravelTimes / modeTrips; this.tripsHistory[i][index] = modeTrips; this.durationHistory[i][index] = averageTravelTime; - + this.tripsWriter.write("\t"); this.tripsWriter.write(String.valueOf(modeTrips)); this.durationWriter.write("\t"); this.durationWriter.write(String.valueOf(averageTravelTime)); - + i++; } - + double averageTravelTime = overallTravelTime / overallTrips; this.tripsHistory[sortedModes.size()][index] = overallTrips; this.durationHistory[sortedModes.size()][index] = averageTravelTime; - + this.tripsWriter.write("\t"); this.tripsWriter.write(String.valueOf(overallTrips)); this.tripsWriter.write("\n"); @@ -250,26 +250,26 @@ public void notifyIterationEnds(IterationEndsEvent event) { } catch (IOException e) { throw new RuntimeException(e); } - + if (this.createGraphs && event.getIteration() != this.minIteration) { int index = event.getIteration() - this.minIteration; // create chart when data of more than one iteration is available. XYLineChart chart; - + double[] iterations = new double[index + 1]; for (int i = 0; i <= index; i++) { iterations[i] = i + this.minIteration; } double[] values = new double[index + 1]; - + int i; - + /* * average leg duration */ chart = new XYLineChart("Average Leg Travel Times Statistics", "iteration", "time"); - + i = 0; for (String mode : sortedModes) { System.arraycopy(this.durationHistory[i], 0, values, 0, index + 1); @@ -278,15 +278,15 @@ public void notifyIterationEnds(IterationEndsEvent event) { } System.arraycopy(this.durationHistory[i], 0, values, 0, index + 1); chart.addSeries("overall", iterations, values); - + chart.addMatsimLogo(); chart.saveAsPng(this.durationsFileName + ".png", 800, 600); - + /* * number of trips */ chart = new XYLineChart("Number of Trips per Mode Statistics", "iteration", "number of trips"); - + i = 0; for (String mode : sortedModes) { System.arraycopy(this.tripsHistory[i], 0, values, 0, index + 1); @@ -295,7 +295,7 @@ public void notifyIterationEnds(IterationEndsEvent event) { } System.arraycopy(this.tripsHistory[i], 0, values, 0, index + 1); chart.addSeries("overall", iterations, values); - + chart.addMatsimLogo(); chart.saveAsPng(this.tripsFileName + ".png", 800, 600); } @@ -306,7 +306,7 @@ public void notifyShutdown(ShutdownEvent event) { try { if (this.tripsWriter != null) { this.tripsWriter.flush(); - this.tripsWriter.close(); + this.tripsWriter.close(); } if (this.durationWriter != null) { this.durationWriter.flush(); diff --git a/contribs/analysis/src/main/java/org/matsim/contrib/analysis/kai/RunKNEventsAnalyzer.java b/contribs/analysis/src/main/java/org/matsim/contrib/analysis/kai/RunKNEventsAnalyzer.java index 205cf58ba3b..462943c36f4 100644 --- a/contribs/analysis/src/main/java/org/matsim/contrib/analysis/kai/RunKNEventsAnalyzer.java +++ b/contribs/analysis/src/main/java/org/matsim/contrib/analysis/kai/RunKNEventsAnalyzer.java @@ -37,70 +37,70 @@ public class RunKNEventsAnalyzer { public static void main(String[] args) { - + if ( args.length < 3 ) { System.out.println("Usage: cmd eventsFile popFile netFile [popAttrFile] [tollFile] [futureTollFile]. Aborting ..." ) ; System.exit(-1); } - + String eventsFilename = args[0] ; String populationFilename = args[1] ; String networkFilename = args[2] ; - + String popAttrFilename = null ; if ( args.length > 3 && args[3]!=null ) { popAttrFilename = args[3] ; } - + String tollFilename = null ; if ( args.length > 4 && args[4]!=null ) { tollFilename = args[4] ; } - + String otherLinksFilename = null ; if ( args.length > 5 && args[5]!=null ) { otherLinksFilename = args[5] ; } - + // === Config config = ConfigUtils.createConfig() ; - + String[] modes ={"car","commercial"}; config.qsim().setMainModes( Arrays.asList(modes) ); - config.plansCalcRoute().setNetworkModes(Arrays.asList(modes)); - + config.routing().setNetworkModes(Arrays.asList(modes)); + config.network().setInputFile( networkFilename ); config.plans().setInputFile( populationFilename ); config.plans().setInputPersonAttributeFile( popAttrFilename ); ConfigUtils.addOrGetModule(config, RoadPricingConfigGroup.GROUP_NAME, RoadPricingConfigGroup.class).setTollLinksFile(tollFilename); // === - + Scenario scenario = ScenarioUtils.loadScenario(config) ; // ((ScenarioImpl)scenario).createVehicleContainer() ; // GautengControler_subpopulations.createVehiclePerPerson(scenario); - + // === - + EventsManager events = new EventsManagerImpl() ; - + Vehicle2DriverEventHandler vehicle2Driver = new Vehicle2DriverEventHandler(); events.addHandler(vehicle2Driver); - + final KNAnalysisEventsHandler.Builder builder = new KNAnalysisEventsHandler.Builder(scenario) ; builder.setOtherTollLinkFile( otherLinksFilename ); final KNAnalysisEventsHandler calcLegTimes = builder.build(); - + events.addHandler( calcLegTimes ); - + new MatsimEventsReader(events).readFile(eventsFilename) ; - -// String myDate = date.getYear() + "-" + date.getMonthOfYear() + "-" + date.getDayOfMonth() + "-" + + +// String myDate = date.getYear() + "-" + date.getMonthOfYear() + "-" + date.getDayOfMonth() + "-" + // date.getHourOfDay() + "h" + minute ; String myDate = "" ; - + calcLegTimes.writeStats(myDate + "_stats_"); } diff --git a/contribs/analysis/src/main/java/org/matsim/contrib/travelsummary/events2traveldiaries/RunEventsToTravelDiaries.java b/contribs/analysis/src/main/java/org/matsim/contrib/travelsummary/events2traveldiaries/RunEventsToTravelDiaries.java index 403f4d0bdb5..436cb4c800f 100644 --- a/contribs/analysis/src/main/java/org/matsim/contrib/travelsummary/events2traveldiaries/RunEventsToTravelDiaries.java +++ b/contribs/analysis/src/main/java/org/matsim/contrib/travelsummary/events2traveldiaries/RunEventsToTravelDiaries.java @@ -51,7 +51,7 @@ public static void main(String[] args) { printHelp(); try { config = ConfigUtils.loadConfig(args[0]); - outputDirectory = config.controler().getOutputDirectory(); + outputDirectory = config.controller().getOutputDirectory(); eventsFileName = args[1]; diff --git a/contribs/application/src/main/java/org/matsim/application/ApplicationUtils.java b/contribs/application/src/main/java/org/matsim/application/ApplicationUtils.java index ff3b129cd80..89086cb00d3 100644 --- a/contribs/application/src/main/java/org/matsim/application/ApplicationUtils.java +++ b/contribs/application/src/main/java/org/matsim/application/ApplicationUtils.java @@ -6,7 +6,6 @@ import org.matsim.application.options.CrsOptions; import org.matsim.application.options.InputOptions; import org.matsim.application.options.OutputOptions; -import org.matsim.application.options.ShpOptions; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; import org.matsim.core.scenario.ScenarioUtils; @@ -129,8 +128,8 @@ public static Scenario loadScenario(String runId, Path runDirectory, CrsOptions Config config = ConfigUtils.createConfig(); config.global().setCoordinateSystem(crs.getInputCRS()); - config.controler().setOutputDirectory(runDirectory.toString()); - config.controler().setRunId(resolvedRunId); + config.controller().setOutputDirectory(runDirectory.toString()); + config.controller().setRunId(resolvedRunId); config.plans().setInputFile(populationFile.toString()); config.network().setInputFile(networkFile.toString()); diff --git a/contribs/application/src/main/java/org/matsim/application/MATSimApplication.java b/contribs/application/src/main/java/org/matsim/application/MATSimApplication.java index e1aae294638..ad5923311de 100644 --- a/contribs/application/src/main/java/org/matsim/application/MATSimApplication.java +++ b/contribs/application/src/main/java/org/matsim/application/MATSimApplication.java @@ -177,13 +177,13 @@ public Integer call() throws Exception { } if (iterations > -1) - config.controler().setLastIteration(iterations); + config.controller().setLastIteration(iterations); if (output != null) - config.controler().setOutputDirectory(output.toString()); + config.controller().setOutputDirectory(output.toString()); if (runId != null) - config.controler().setRunId(runId); + config.controller().setRunId(runId); final Scenario scenario = createScenario(config); @@ -199,7 +199,7 @@ public Integer call() throws Exception { if (post != PostProcessOption.disabled) { - List commands = preparePostProcessing(Path.of(config.controler().getOutputDirectory()), config.controler().getRunId()); + List commands = preparePostProcessing(Path.of(config.controller().getOutputDirectory()), config.controller().getRunId()); for (MATSimAppCommand command : commands) { @@ -370,14 +370,14 @@ protected final void addRunOption(Config config, String option, Object value) { else postfix = "-" + option + "_" + value; - String outputDir = config.controler().getOutputDirectory(); + String outputDir = config.controller().getOutputDirectory(); if (outputDir.endsWith("/")) { - config.controler().setOutputDirectory(outputDir.substring(0, outputDir.length() - 1) + postfix + "/"); + config.controller().setOutputDirectory(outputDir.substring(0, outputDir.length() - 1) + postfix + "/"); } else - config.controler().setOutputDirectory(outputDir + postfix); + config.controller().setOutputDirectory(outputDir + postfix); // dot should not be part of run id - config.controler().setRunId(config.controler().getRunId() + postfix.replace(".", "")); + config.controller().setRunId(config.controller().getRunId() + postfix.replace(".", "")); } /** diff --git a/contribs/application/src/main/java/org/matsim/application/analysis/emissions/AirPollutionAnalysis.java b/contribs/application/src/main/java/org/matsim/application/analysis/emissions/AirPollutionAnalysis.java index f273c87adfe..eca4eee1e0b 100644 --- a/contribs/application/src/main/java/org/matsim/application/analysis/emissions/AirPollutionAnalysis.java +++ b/contribs/application/src/main/java/org/matsim/application/analysis/emissions/AirPollutionAnalysis.java @@ -142,8 +142,8 @@ private Config prepareConfig() { config.transit().setTransitScheduleFile(ApplicationUtils.matchInput("transitSchedule", input.getRunDirectory()).toAbsolutePath().toString()); config.transit().setVehiclesFile(ApplicationUtils.matchInput("transitVehicles", input.getRunDirectory()).toAbsolutePath().toString()); config.plans().setInputFile(null); - config.parallelEventHandling().setNumberOfThreads(null); - config.parallelEventHandling().setEstimatedNumberOfEvents(null); + config.eventsManager().setNumberOfThreads(null); + config.eventsManager().setEstimatedNumberOfEvents(null); config.global().setNumberOfThreads(1); return config; diff --git a/contribs/application/src/main/java/org/matsim/application/analysis/emissions/AirPollutionByVehicleCategory.java b/contribs/application/src/main/java/org/matsim/application/analysis/emissions/AirPollutionByVehicleCategory.java index 7b02f55fa53..20bf17af5c6 100644 --- a/contribs/application/src/main/java/org/matsim/application/analysis/emissions/AirPollutionByVehicleCategory.java +++ b/contribs/application/src/main/java/org/matsim/application/analysis/emissions/AirPollutionByVehicleCategory.java @@ -135,8 +135,8 @@ public Integer call() throws Exception { config.transit().setVehiclesFile(globFile(runDirectory, runId, "transitVehicles")); config.global().setCoordinateSystem(crs.getInputCRS()); config.plans().setInputFile(null); - config.parallelEventHandling().setNumberOfThreads(null); - config.parallelEventHandling().setEstimatedNumberOfEvents(null); + config.eventsManager().setNumberOfThreads(null); + config.eventsManager().setEstimatedNumberOfEvents(null); config.global().setNumberOfThreads(1); EmissionsConfigGroup eConfig = ConfigUtils.addOrGetModule(config, EmissionsConfigGroup.class); diff --git a/contribs/application/src/main/java/org/matsim/application/analysis/noise/NoiseAnalysis.java b/contribs/application/src/main/java/org/matsim/application/analysis/noise/NoiseAnalysis.java index 964ce79c6a8..3e99b052194 100644 --- a/contribs/application/src/main/java/org/matsim/application/analysis/noise/NoiseAnalysis.java +++ b/contribs/application/src/main/java/org/matsim/application/analysis/noise/NoiseAnalysis.java @@ -71,7 +71,7 @@ public Integer call() throws Exception { if (!runDirectory.endsWith("/")) runDirectory = runDirectory + "/"; config.global().setCoordinateSystem(crs.getInputCRS()); - config.controler().setRunId(runId); + config.controller().setRunId(runId); if (!runId.equals("")) { config.network().setInputFile(runDirectory + runId + ".output_network.xml.gz"); config.plans().setInputFile(runDirectory + runId + ".output_plans.xml.gz"); @@ -79,7 +79,7 @@ public Integer call() throws Exception { config.network().setInputFile(runDirectory + "output_network.xml.gz"); config.plans().setInputFile(runDirectory + "output_plans.xml.gz"); } - config.controler().setOutputDirectory(runDirectory); + config.controller().setOutputDirectory(runDirectory); // adjust the default noise parameters NoiseConfigGroup noiseParameters = ConfigUtils.addOrGetModule(config, NoiseConfigGroup.class); diff --git a/contribs/application/src/main/java/org/matsim/application/prepare/freight/optimization/DetermineAverageTruckLoad.java b/contribs/application/src/main/java/org/matsim/application/prepare/freight/optimization/DetermineAverageTruckLoad.java index 6dd30f93606..8318bef7292 100644 --- a/contribs/application/src/main/java/org/matsim/application/prepare/freight/optimization/DetermineAverageTruckLoad.java +++ b/contribs/application/src/main/java/org/matsim/application/prepare/freight/optimization/DetermineAverageTruckLoad.java @@ -6,8 +6,6 @@ import org.apache.commons.csv.CSVRecord; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.checkerframework.checker.units.qual.C; -import org.locationtech.jts.geom.Geometry; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Identifiable; @@ -16,7 +14,6 @@ import org.matsim.api.core.v01.network.Network; import org.matsim.application.MATSimAppCommand; import org.matsim.application.options.CrsOptions; -import org.matsim.application.options.ShpOptions; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; import org.matsim.core.network.NetworkUtils; @@ -28,7 +25,6 @@ import org.matsim.core.trafficmonitoring.FreeSpeedTravelTime; import org.matsim.core.utils.geometry.CoordUtils; import org.matsim.core.utils.geometry.CoordinateTransformation; -import org.matsim.core.utils.geometry.geotools.MGC; import org.matsim.core.utils.geometry.transformations.TransformationFactory; import org.matsim.core.utils.gis.ShapeFileReader; import org.opengis.feature.simple.SimpleFeature; @@ -37,7 +33,6 @@ import java.io.FileWriter; import java.io.IOException; import java.net.URI; -import java.net.URL; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; @@ -342,7 +337,7 @@ private boolean checkIfTripIsRelevant(String mode, String from, String to, Strin private LeastCostPathCalculator createRouter(Network network) { Config config = ConfigUtils.createConfig(); - config.plansCalcRoute().setRoutingRandomness(0); + config.routing().setRoutingRandomness(0); TravelTime travelTime = new FreeSpeedTravelTime(); TravelDisutility travelDisutility = new RandomizingTimeDistanceTravelDisutilityFactory (TransportMode.car, config).createTravelDisutility(travelTime); diff --git a/contribs/application/src/main/java/org/matsim/application/prepare/freight/tripExtraction/ExtractRelevantFreightTrips.java b/contribs/application/src/main/java/org/matsim/application/prepare/freight/tripExtraction/ExtractRelevantFreightTrips.java index 870cd1be48f..196e114634c 100644 --- a/contribs/application/src/main/java/org/matsim/application/prepare/freight/tripExtraction/ExtractRelevantFreightTrips.java +++ b/contribs/application/src/main/java/org/matsim/application/prepare/freight/tripExtraction/ExtractRelevantFreightTrips.java @@ -82,7 +82,7 @@ public Integer call() throws Exception { config.network().setInputFile(networkPath.toString()); Scenario outputScenario = ScenarioUtils.loadScenario(config); config.plans().setInputFile(freightDataDirectory.toString()); - config.plansCalcRoute().setRoutingRandomness(0); + config.routing().setRoutingRandomness(0); Scenario scenario = ScenarioUtils.loadScenario(config); Network network = scenario.getNetwork(); Population originalPlans = scenario.getPopulation(); diff --git a/contribs/application/src/main/java/org/matsim/freightDemandGeneration/FreightDemandGeneration.java b/contribs/application/src/main/java/org/matsim/freightDemandGeneration/FreightDemandGeneration.java index 43ea72bde8b..8f6c2e87446 100644 --- a/contribs/application/src/main/java/org/matsim/freightDemandGeneration/FreightDemandGeneration.java +++ b/contribs/application/src/main/java/org/matsim/freightDemandGeneration/FreightDemandGeneration.java @@ -232,12 +232,12 @@ public Integer call() throws IOException, InvalidAttributeValueException, Execut private Config prepareConfig(int lastMATSimIteration, String coordinateSystem) { Config config = ConfigUtils.createConfig(); // ScenarioUtils.loadScenario(config); - config.controler().setOutputDirectory(outputLocation.toString()); - config.controler().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); - new OutputDirectoryHierarchy(config.controler().getOutputDirectory(), config.controler().getRunId(), - config.controler().getOverwriteFileSetting(), ControllerConfigGroup.CompressionType.gzip); - config.controler().setOverwriteFileSetting(OverwriteFileSetting.overwriteExistingFiles); - config.controler().setLastIteration(lastMATSimIteration); + config.controller().setOutputDirectory(outputLocation.toString()); + config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); + new OutputDirectoryHierarchy(config.controller().getOutputDirectory(), config.controller().getRunId(), + config.controller().getOverwriteFileSetting(), ControllerConfigGroup.CompressionType.gzip); + config.controller().setOverwriteFileSetting(OverwriteFileSetting.overwriteExistingFiles); + config.controller().setLastIteration(lastMATSimIteration); config.global().setRandomSeed(4177); config.global().setCoordinateSystem(coordinateSystem); FreightConfigGroup freightConfigGroup = ConfigUtils.addOrGetModule(config, FreightConfigGroup.class); @@ -462,29 +462,29 @@ private static void solveSelectedSolution(OptionsOfVRPSolutions selectedSolution case runJspritAndMATSim -> { // solves the VRP with jsprit and runs MATSim afterwards new CarrierPlanWriter((Carriers) controler.getScenario().getScenarioElement("carriers")) - .write(config.controler().getOutputDirectory() + "/output_carriersNoPlans.xml"); + .write(config.controller().getOutputDirectory() + "/output_carriersNoPlans.xml"); runJsprit(controler, false); controler.run(); new CarrierPlanWriter((Carriers) controler.getScenario().getScenarioElement("carriers")) - .write(config.controler().getOutputDirectory() + "/output_carriersWithPlans.xml"); + .write(config.controller().getOutputDirectory() + "/output_carriersWithPlans.xml"); } case runJspritAndMATSimWithDistanceConstraint -> { // solves the VRP with jsprit by using the distance constraint and runs MATSim // afterwards new CarrierPlanWriter((Carriers) controler.getScenario().getScenarioElement("carriers")) - .write(config.controler().getOutputDirectory() + "/output_carriersNoPlans.xml"); + .write(config.controller().getOutputDirectory() + "/output_carriersNoPlans.xml"); runJsprit(controler, true); controler.run(); new CarrierPlanWriter((Carriers) controler.getScenario().getScenarioElement("carriers")) - .write(config.controler().getOutputDirectory() + "/output_carriersWithPlans.xml"); + .write(config.controller().getOutputDirectory() + "/output_carriersWithPlans.xml"); } case runJsprit -> { // solves only the VRP with jsprit new CarrierPlanWriter((Carriers) controler.getScenario().getScenarioElement("carriers")) - .write(config.controler().getOutputDirectory() + "/output_carriersNoPlans.xml"); + .write(config.controller().getOutputDirectory() + "/output_carriersNoPlans.xml"); runJsprit(controler, false); new CarrierPlanWriter((Carriers) controler.getScenario().getScenarioElement("carriers")) - .write(config.controler().getOutputDirectory() + "/output_carriersWithPlans.xml"); + .write(config.controller().getOutputDirectory() + "/output_carriersWithPlans.xml"); log.warn( "##Finished with the jsprit solution. If you also want to run MATSim, please change case of optionsOfVRPSolutions"); System.exit(0); @@ -492,10 +492,10 @@ private static void solveSelectedSolution(OptionsOfVRPSolutions selectedSolution case runJspritWithDistanceConstraint -> { // solves only the VRP with jsprit by using the distance constraint new CarrierPlanWriter((Carriers) controler.getScenario().getScenarioElement("carriers")) - .write(config.controler().getOutputDirectory() + "/output_carriersNoPlans.xml"); + .write(config.controller().getOutputDirectory() + "/output_carriersNoPlans.xml"); runJsprit(controler, true); new CarrierPlanWriter((Carriers) controler.getScenario().getScenarioElement("carriers")) - .write(config.controler().getOutputDirectory() + "/output_carriersWithPlans.xml"); + .write(config.controller().getOutputDirectory() + "/output_carriersWithPlans.xml"); log.warn( "##Finished with the jsprit solution. If you also want to run MATSim, please change case of optionsOfVRPSolutions"); System.exit(0); @@ -504,7 +504,7 @@ private static void solveSelectedSolution(OptionsOfVRPSolutions selectedSolution // creates no solution of the VRP and only writes the carrier file with the // generated carriers and demands new CarrierPlanWriter((Carriers) controler.getScenario().getScenarioElement("carriers")) - .write(config.controler().getOutputDirectory() + "/output_carriersNoPlans.xml"); + .write(config.controller().getOutputDirectory() + "/output_carriersNoPlans.xml"); log.warn( "##Finished without solution of the VRP. If you also want to run jsprit and/or MATSim, please change case of optionsOfVRPSolutions"); System.exit(0); diff --git a/contribs/application/src/main/java/org/matsim/freightDemandGeneration/FreightDemandGenerationUtils.java b/contribs/application/src/main/java/org/matsim/freightDemandGeneration/FreightDemandGenerationUtils.java index 6c4a09703c4..82be3284375 100644 --- a/contribs/application/src/main/java/org/matsim/freightDemandGeneration/FreightDemandGenerationUtils.java +++ b/contribs/application/src/main/java/org/matsim/freightDemandGeneration/FreightDemandGenerationUtils.java @@ -99,7 +99,7 @@ static void preparePopulation(Population population, double sampleSizeInputPopul static void createDemandLocationsFile(Controler controler) { Network network = controler.getScenario().getNetwork(); - File file = new File(controler.getConfig().controler().getOutputDirectory() + "/outputFacilitiesFile.tsv"); + File file = new File(controler.getConfig().controller().getOutputDirectory() + "/outputFacilitiesFile.tsv"); try (FileWriter writer = new FileWriter(file, true)) { writer.write("id x y type ServiceLocation pickupLocation deliveryLocation\n"); diff --git a/contribs/application/src/main/java/org/matsim/smallScaleCommercialTrafficGeneration/GenerateSmallScaleCommercialTrafficDemand.java b/contribs/application/src/main/java/org/matsim/smallScaleCommercialTrafficGeneration/GenerateSmallScaleCommercialTrafficDemand.java index 6fbe89f6541..1ef1365d510 100644 --- a/contribs/application/src/main/java/org/matsim/smallScaleCommercialTrafficGeneration/GenerateSmallScaleCommercialTrafficDemand.java +++ b/contribs/application/src/main/java/org/matsim/smallScaleCommercialTrafficGeneration/GenerateSmallScaleCommercialTrafficDemand.java @@ -172,7 +172,7 @@ public Integer call() throws Exception { Config config = readAndCheckConfig(configPath, modelName, sampleName, output); - output = Path.of(config.controler().getOutputDirectory()); + output = Path.of(config.controller().getOutputDirectory()); Scenario scenario = ScenarioUtils.loadScenario(config); NetworkUtils.runNetworkCleaner(scenario.getNetwork()); // e.g. for vulkaneifel network @@ -236,23 +236,23 @@ public Integer call() throws Exception { } default -> throw new RuntimeException("No traffic type selected."); } - if (config.controler().getRunId() == null) + if (config.controller().getRunId() == null) new CarrierPlanWriter(FreightUtils.addOrGetCarriers(scenario)) - .write(scenario.getConfig().controler().getOutputDirectory() + "/output_CarrierDemand.xml"); + .write(scenario.getConfig().controller().getOutputDirectory() + "/output_CarrierDemand.xml"); else new CarrierPlanWriter(FreightUtils.addOrGetCarriers(scenario)) - .write(scenario.getConfig().controler().getOutputDirectory() + "/" - + scenario.getConfig().controler().getRunId() + ".output_CarrierDemand.xml"); + .write(scenario.getConfig().controller().getOutputDirectory() + "/" + + scenario.getConfig().controller().getRunId() + ".output_CarrierDemand.xml"); solveSeparatedVRPs(scenario, regionLinksMap); } } - if (config.controler().getRunId() == null) + if (config.controller().getRunId() == null) new CarrierPlanWriter(FreightUtils.addOrGetCarriers(scenario)).write( - scenario.getConfig().controler().getOutputDirectory() + "/output_CarrierDemandWithPlans.xml"); + scenario.getConfig().controller().getOutputDirectory() + "/output_CarrierDemandWithPlans.xml"); else new CarrierPlanWriter(FreightUtils.addOrGetCarriers(scenario)) .write( - scenario.getConfig().controler().getOutputDirectory() + "/" + scenario.getConfig().controler().getRunId() + ".output_CarrierDemandWithPlans.xml"); + scenario.getConfig().controller().getOutputDirectory() + "/" + scenario.getConfig().controller().getRunId() + ".output_CarrierDemandWithPlans.xml"); Controler controler = prepareControler(scenario); controler.run(); SmallScaleCommercialTrafficUtils.createPlansBasedOnCarrierPlans(controler.getScenario(), @@ -433,15 +433,15 @@ private Config readAndCheckConfig(Path configPath, String modelName, String samp Config config = ConfigUtils.loadConfig(configPath.toString()); if (output == null || output.toString().isEmpty()) - config.controler().setOutputDirectory(Path.of(config.controler().getOutputDirectory()).resolve(modelName) + config.controller().setOutputDirectory(Path.of(config.controller().getOutputDirectory()).resolve(modelName) .resolve(usedSmallScaleCommercialTrafficType.toString() + "_" + sampleName + "pct" + "_" + java.time.LocalDate.now() + "_" + java.time.LocalTime.now().toSecondOfDay() + "_" + resistanceFactor) .toString()); else - config.controler().setOutputDirectory(output.toString()); - new OutputDirectoryHierarchy(config.controler().getOutputDirectory(), config.controler().getRunId(), - config.controler().getOverwriteFileSetting(), ControllerConfigGroup.CompressionType.gzip); - new File(Path.of(config.controler().getOutputDirectory()).resolve("calculatedData").toString()).mkdir(); + config.controller().setOutputDirectory(output.toString()); + new OutputDirectoryHierarchy(config.controller().getOutputDirectory(), config.controller().getRunId(), + config.controller().getOverwriteFileSetting(), ControllerConfigGroup.CompressionType.gzip); + new File(Path.of(config.controller().getOutputDirectory()).resolve("calculatedData").toString()).mkdir(); rnd = new Random(config.global().getRandomSeed()); if (config.network().getInputFile() == null) throw new Exception("No network file in config"); @@ -449,7 +449,7 @@ private Config readAndCheckConfig(Path configPath, String modelName, String samp throw new Exception("No network CRS is set in config"); if (config.global().getCoordinateSystem() == null) throw new Exception("No global CRS is set in config"); - if (config.controler().getOutputDirectory() == null) + if (config.controller().getOutputDirectory() == null) throw new Exception("No output directory was set"); return config; diff --git a/contribs/application/src/test/java/org/matsim/application/MATSimApplicationTest.java b/contribs/application/src/test/java/org/matsim/application/MATSimApplicationTest.java index 8de8410b64c..9be98d76122 100644 --- a/contribs/application/src/test/java/org/matsim/application/MATSimApplicationTest.java +++ b/contribs/application/src/test/java/org/matsim/application/MATSimApplicationTest.java @@ -47,7 +47,7 @@ public void config() { Config config = controler.getConfig(); - assertThat(config.controler().getRunId()).isEqualTo("Test123"); + assertThat(config.controller().getRunId()).isEqualTo("Test123"); assertThat(config.global().getNumberOfThreads()).isEqualTo(4); assertThat(config.plans().getInputCRS()).isEqualTo("EPSG:1234"); @@ -60,10 +60,10 @@ public void yaml() { Controler controler = MATSimApplication.prepare(TestScenario.class, ConfigUtils.createConfig(), "--yaml", yml.toString()); - assertThat(controler.getConfig().controler().getRunId()) + assertThat(controler.getConfig().controller().getRunId()) .isEqualTo("567"); - ScoringConfigGroup score = controler.getConfig().planCalcScore(); + ScoringConfigGroup score = controler.getConfig().scoring(); ScoringConfigGroup.ScoringParameterSet params = score.getScoringParameters(null); @@ -81,12 +81,12 @@ public void sample() { Controler controler = MATSimApplication.prepare(TestScenario.class, ConfigUtils.createConfig(), "--10pct"); - assertThat(controler.getConfig().controler().getRunId()) + assertThat(controler.getConfig().controller().getRunId()) .isEqualTo("run-10pct"); controler = MATSimApplication.prepare(TestScenario.class, ConfigUtils.createConfig()); - assertThat(controler.getConfig().controler().getRunId()) + assertThat(controler.getConfig().controller().getRunId()) .isEqualTo("run-25pct"); } @@ -166,9 +166,9 @@ public void run() { Config config = ConfigUtils.createConfig(); Path out = Path.of(utils.getOutputDirectory()).resolve("out"); - config.controler().setOutputDirectory(out.toString()); - config.controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists); - config.controler().setLastIteration(1); + config.controller().setOutputDirectory(out.toString()); + config.controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists); + config.controller().setLastIteration(1); int ret = MATSimApplication.execute(TestScenario.class, config); @@ -197,7 +197,7 @@ public TestScenario() { @Override protected Config prepareConfig(Config config) { - config.controler().setRunId(sample.adjustName("run-25pct")); + config.controller().setRunId(sample.adjustName("run-25pct")); return config; } diff --git a/contribs/application/src/test/java/org/matsim/application/analysis/LogFileAnalysisTest.java b/contribs/application/src/test/java/org/matsim/application/analysis/LogFileAnalysisTest.java index 13c79e7877e..4b1c121aa72 100644 --- a/contribs/application/src/test/java/org/matsim/application/analysis/LogFileAnalysisTest.java +++ b/contribs/application/src/test/java/org/matsim/application/analysis/LogFileAnalysisTest.java @@ -24,15 +24,15 @@ public void output() throws IOException { Config config = ConfigUtils.createConfig(); - config.controler().setOutputDirectory(utils.getOutputDirectory()); - config.controler().setLastIteration(2); + config.controller().setOutputDirectory(utils.getOutputDirectory()); + config.controller().setLastIteration(2); int execute = MATSimApplication.execute(MATSimApplicationTest.TestScenario.class, config); Assertions.assertThat(execute) .isEqualTo(0); - Path out = Path.of(config.controler().getOutputDirectory()); + Path out = Path.of(config.controller().getOutputDirectory()); new LogFileAnalysis().execute( "--input", ApplicationUtils.matchInput("logfile.log", out).toString(), "--output-memory-stats", out.resolve("mem_stats.csv").toString(), diff --git a/contribs/av/src/main/java/org/matsim/contrib/av/intermodal/RunTaxiPTIntermodalExample.java b/contribs/av/src/main/java/org/matsim/contrib/av/intermodal/RunTaxiPTIntermodalExample.java index 5ae03a13b0f..9aaecbc61b2 100644 --- a/contribs/av/src/main/java/org/matsim/contrib/av/intermodal/RunTaxiPTIntermodalExample.java +++ b/contribs/av/src/main/java/org/matsim/contrib/av/intermodal/RunTaxiPTIntermodalExample.java @@ -54,8 +54,8 @@ public class RunTaxiPTIntermodalExample { public void run(URL configUrl, boolean OTFVis) { Config config = ConfigUtils.loadConfig(configUrl, new MultiModeTaxiConfigGroup(), new DvrpConfigGroup()); - config.controler().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); - config.plansCalcRoute().setAccessEgressType(RoutingConfigGroup.AccessEgressType.accessEgressModeToLink); + config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); + config.routing().setAccessEgressType(RoutingConfigGroup.AccessEgressType.accessEgressModeToLink); SwissRailRaptorConfigGroup srrConfig = new SwissRailRaptorConfigGroup(); diff --git a/contribs/av/src/main/java/org/matsim/contrib/av/robotaxi/run/RunDrtAndTaxiExample.java b/contribs/av/src/main/java/org/matsim/contrib/av/robotaxi/run/RunDrtAndTaxiExample.java index 5f1646efe1a..5c95006afa8 100644 --- a/contribs/av/src/main/java/org/matsim/contrib/av/robotaxi/run/RunDrtAndTaxiExample.java +++ b/contribs/av/src/main/java/org/matsim/contrib/av/robotaxi/run/RunDrtAndTaxiExample.java @@ -48,7 +48,7 @@ public static void run(URL configUrl, boolean otfvis) { new DvrpConfigGroup(), new OTFVisConfigGroup()); Scenario scenario = DrtControlerCreator.createScenarioWithDrtRouteFactory(config); ScenarioUtils.loadScenario(scenario); - config.controler() + config.controller() .setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles); Controler controler = new Controler(scenario); controler.addOverridingModule(new MultiModeDrtModule()); diff --git a/contribs/bicycle/src/main/java/org/matsim/contrib/bicycle/BicycleModule.java b/contribs/bicycle/src/main/java/org/matsim/contrib/bicycle/BicycleModule.java index 15b2d7f42a9..7bf5a766bf4 100644 --- a/contribs/bicycle/src/main/java/org/matsim/contrib/bicycle/BicycleModule.java +++ b/contribs/bicycle/src/main/java/org/matsim/contrib/bicycle/BicycleModule.java @@ -86,7 +86,7 @@ static class ConsistencyCheck implements StartupListener { LOG.warn("There is an inconsistency in the specified maximum velocity for " + bicycleConfigGroup.getBicycleMode() + ":" + " Maximum speed specified in the 'bicycle' config group (used for routing): " + bicycleConfigGroup.getMaxBicycleSpeedForRouting() + " vs." + " maximum speed specified for the vehicle type (used in mobsim): " + mobsimSpeed); - if (scenario.getConfig().plansCalcRoute().getRoutingRandomness() == 0.) { + if (scenario.getConfig().routing().getRoutingRandomness() == 0.) { throw new RuntimeException("The recommended way to deal with the inconsistency between routing and scoring/mobsim is to have a randomized router. Aborting... "); } } diff --git a/contribs/bicycle/src/main/java/org/matsim/contrib/bicycle/run/RunBicycleExample.java b/contribs/bicycle/src/main/java/org/matsim/contrib/bicycle/run/RunBicycleExample.java index 37590cad7bd..af6d9d58927 100644 --- a/contribs/bicycle/src/main/java/org/matsim/contrib/bicycle/run/RunBicycleExample.java +++ b/contribs/bicycle/src/main/java/org/matsim/contrib/bicycle/run/RunBicycleExample.java @@ -71,14 +71,14 @@ public static void main(String[] args) { throw new RuntimeException("More than one argument was provided. There is no procedure for this situation. Thus aborting!" + " Provide either (1) only a suitable config file or (2) no argument at all to run example with given example of resources folder."); } - config.controler().setLastIteration(100); // Modify if motorized interaction is used + config.controller().setLastIteration(100); // Modify if motorized interaction is used boolean considerMotorizedInteraction = false; new RunBicycleExample().run(config ); } static void fillConfigWithBicycleStandardValues(Config config) { - config.controler().setWriteEventsInterval(1); + config.controller().setWriteEventsInterval(1); BicycleConfigGroup bicycleConfigGroup = ConfigUtils.addOrGetModule( config, BicycleConfigGroup.class ); bicycleConfigGroup.setMarginalUtilityOfInfrastructure_m(-0.0002); @@ -97,23 +97,23 @@ static void fillConfigWithBicycleStandardValues(Config config) { config.qsim().setMainModes(mainModeList); - config.strategy().setMaxAgentPlanMemorySize(5); - config.strategy().addStrategySettings( new StrategySettings().setStrategyName("ChangeExpBeta" ).setWeight(0.8 ) ); - config.strategy().addStrategySettings( new StrategySettings().setStrategyName("ReRoute" ).setWeight(0.2 ) ); + config.replanning().setMaxAgentPlanMemorySize(5); + config.replanning().addStrategySettings( new StrategySettings().setStrategyName("ChangeExpBeta" ).setWeight(0.8 ) ); + config.replanning().addStrategySettings( new StrategySettings().setStrategyName("ReRoute" ).setWeight(0.2 ) ); - config.planCalcScore().addActivityParams( new ActivityParams("home").setTypicalDuration(12*60*60 ) ); - config.planCalcScore().addActivityParams( new ActivityParams("work").setTypicalDuration(8*60*60 ) ); + config.scoring().addActivityParams( new ActivityParams("home").setTypicalDuration(12*60*60 ) ); + config.scoring().addActivityParams( new ActivityParams("work").setTypicalDuration(8*60*60 ) ); - config.planCalcScore().addModeParams( new ModeParams("bicycle").setConstant(0. ).setMarginalUtilityOfDistance(-0.0004 ).setMarginalUtilityOfTraveling(-6.0 ).setMonetaryDistanceRate(0. ) ); + config.scoring().addModeParams( new ModeParams("bicycle").setConstant(0. ).setMarginalUtilityOfDistance(-0.0004 ).setMarginalUtilityOfTraveling(-6.0 ).setMonetaryDistanceRate(0. ) ); - config.plansCalcRoute().setNetworkModes(mainModeList); + config.routing().setNetworkModes(mainModeList); } public void run(Config config ) { config.global().setNumberOfThreads(1); - config.controler().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); + config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); - config.plansCalcRoute().setRoutingRandomness(3.); + config.routing().setRoutingRandomness(3.); BicycleConfigGroup bicycleConfigGroup = ConfigUtils.addOrGetModule( config, BicycleConfigGroup.class ); @@ -137,9 +137,9 @@ public void run(Config config ) { } public void runWithOwnScoring(Config config, boolean considerMotorizedInteraction) { config.global().setNumberOfThreads(1); - config.controler().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); + config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); - config.plansCalcRoute().setRoutingRandomness(3.); + config.routing().setRoutingRandomness(3.); if (considerMotorizedInteraction) { BicycleConfigGroup bicycleConfigGroup = ConfigUtils.addOrGetModule( config, BicycleConfigGroup.class ); diff --git a/contribs/bicycle/src/test/java/org/matsim/contrib/bicycle/run/BicycleTest.java b/contribs/bicycle/src/test/java/org/matsim/contrib/bicycle/run/BicycleTest.java index a5aa5735779..0f2dea83a91 100644 --- a/contribs/bicycle/src/test/java/org/matsim/contrib/bicycle/run/BicycleTest.java +++ b/contribs/bicycle/src/test/java/org/matsim/contrib/bicycle/run/BicycleTest.java @@ -86,10 +86,10 @@ public void testNormal() { // Normal network config.network().setInputFile("network_normal.xml"); config.plans().setInputFile("population_1200.xml"); - config.controler().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); - config.controler().setOutputDirectory(utils.getOutputDirectory()); - config.controler().setLastIteration(0); - config.controler().setCreateGraphs(false); + config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); + config.controller().setOutputDirectory(utils.getOutputDirectory()); + config.controller().setLastIteration(0); + config.controller().setCreateGraphs(false); new RunBicycleExample().run(config ); @@ -122,10 +122,10 @@ public void testCobblestone() { config.plans().setInputFile("population_1200.xml"); - config.controler().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); - config.controler().setOutputDirectory(utils.getOutputDirectory()); - config.controler().setLastIteration(0); - config.controler().setCreateGraphs(false); + config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); + config.controller().setOutputDirectory(utils.getOutputDirectory()); + config.controller().setLastIteration(0); + config.controller().setCreateGraphs(false); new RunBicycleExample().run(config ); { @@ -153,10 +153,10 @@ public void testPedestrian() { // Links 4-8 and 13-17 are pedestrian zones config.network().setInputFile("network_pedestrian.xml"); config.plans().setInputFile("population_1200.xml"); - config.controler().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); - config.controler().setOutputDirectory(utils.getOutputDirectory()); - config.controler().setLastIteration(0); - config.controler().setCreateGraphs(false); + config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); + config.controller().setOutputDirectory(utils.getOutputDirectory()); + config.controller().setLastIteration(0); + config.controller().setCreateGraphs(false); new RunBicycleExample().run(config ); @@ -182,10 +182,10 @@ public void testLane() { // Links 2-4/8-10 and 11-13/17-19 have cycle lanes (cycleway=lane) config.network().setInputFile("network_lane.xml"); config.plans().setInputFile("population_1200.xml"); - config.controler().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); - config.controler().setOutputDirectory(utils.getOutputDirectory()); - config.controler().setLastIteration(0); - config.controler().setCreateGraphs(false); + config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); + config.controller().setOutputDirectory(utils.getOutputDirectory()); + config.controller().setLastIteration(0); + config.controller().setCreateGraphs(false); new RunBicycleExample().run(config ); @@ -211,10 +211,10 @@ public void testGradient() { // Nodes 5-8 have a z-coordinate > 0, i.e. the links leading to those nodes have a slope config.network().setInputFile("network_gradient.xml"); config.plans().setInputFile("population_1200.xml"); - config.controler().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); - config.controler().setOutputDirectory(utils.getOutputDirectory()); - config.controler().setLastIteration(0); - config.controler().setCreateGraphs(false); + config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); + config.controller().setOutputDirectory(utils.getOutputDirectory()); + config.controller().setLastIteration(0); + config.controller().setCreateGraphs(false); new RunBicycleExample().run(config ); @@ -241,10 +241,10 @@ public void testGradientLane() { // and links 4-5 and 13-14 have cycle lanes config.network().setInputFile("network_gradient_lane.xml"); config.plans().setInputFile("population_1200.xml"); - config.controler().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); - config.controler().setOutputDirectory(utils.getOutputDirectory()); - config.controler().setLastIteration(0); - config.controler().setCreateGraphs(false); + config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); + config.controller().setOutputDirectory(utils.getOutputDirectory()); + config.controller().setLastIteration(0); + config.controller().setCreateGraphs(false); new RunBicycleExample().run(config ); @@ -270,13 +270,13 @@ public void testNormal10It() { // Normal network config.network().setInputFile("network_normal.xml"); config.plans().setInputFile("population_1200.xml"); - config.controler().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); - config.controler().setOutputDirectory(utils.getOutputDirectory()); + config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); + config.controller().setOutputDirectory(utils.getOutputDirectory()); // 10 iterations - config.controler().setLastIteration(10); - config.controler().setWriteEventsInterval(10); - config.controler().setWritePlansInterval(10); - config.controler().setCreateGraphs(false); + config.controller().setLastIteration(10); + config.controller().setWriteEventsInterval(10); + config.controller().setWritePlansInterval(10); + config.controller().setCreateGraphs(false); new RunBicycleExample().run(config ); @@ -345,9 +345,9 @@ public void testNormal10It() { // the following comes from inlining RunBicycleExample, which we need since we need to modify scenario data: config.global().setNumberOfThreads(1 ); - config.controler().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists ); + config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists ); - config.plansCalcRoute().setRoutingRandomness(3. ); + config.routing().setRoutingRandomness(3. ); final String bicycle = bicycleConfigGroup.getBicycleMode(); @@ -444,10 +444,10 @@ public void testInfrastructureSpeedFactor() { Config config = ConfigUtils.createConfig(utils.getClassInputDirectory() ); config.addModule(new BicycleConfigGroup()); - config.controler().setWriteEventsInterval(0); - config.controler().setWritePlansInterval(0); - config.controler().setCreateGraphs(false); - config.controler().setDumpDataAtEnd(false); + config.controller().setWriteEventsInterval(0); + config.controller().setWritePlansInterval(0); + config.controller().setCreateGraphs(false); + config.controller().setDumpDataAtEnd(false); config.qsim().setStartTime(6. * 3600.); config.qsim().setEndTime(10. * 3600.); @@ -456,43 +456,43 @@ public void testInfrastructureSpeedFactor() { mainModeList.add(TransportMode.car); config.qsim().setMainModes(mainModeList); - config.strategy().setMaxAgentPlanMemorySize(5); + config.replanning().setMaxAgentPlanMemorySize(5); { StrategySettings strategySettings = new StrategySettings(); strategySettings.setStrategyName("ChangeExpBeta"); strategySettings.setWeight(1.0); - config.strategy().addStrategySettings(strategySettings); + config.replanning().addStrategySettings(strategySettings); } ActivityParams homeActivity = new ActivityParams("home"); homeActivity.setTypicalDuration(12*60*60); - config.planCalcScore().addActivityParams(homeActivity); + config.scoring().addActivityParams(homeActivity); ActivityParams workActivity = new ActivityParams("work"); workActivity.setTypicalDuration(8*60*60); - config.planCalcScore().addActivityParams(workActivity); + config.scoring().addActivityParams(workActivity); ModeParams bicycle = new ModeParams( bicycleMode ); bicycle.setConstant(0.); bicycle.setMarginalUtilityOfDistance(-0.0004); // util/m bicycle.setMarginalUtilityOfTraveling(-6.0); // util/h bicycle.setMonetaryDistanceRate(0.); - config.planCalcScore().addModeParams(bicycle); + config.scoring().addModeParams(bicycle); - config.plansCalcRoute().setNetworkModes(mainModeList); + config.routing().setNetworkModes(mainModeList); // link 2 has infrastructure speed factor = 1.0, all other links 0.01 config.network().setInputFile("network_infrastructure-speed-factor.xml"); config.plans().setInputFile("population_4.xml"); - config.controler().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); - config.controler().setOutputDirectory(utils.getOutputDirectory()); - config.controler().setLastIteration(0); + config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); + config.controller().setOutputDirectory(utils.getOutputDirectory()); + config.controller().setLastIteration(0); config.global().setNumberOfThreads(1); - config.controler().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); + config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); - config.plansCalcRoute().setRoutingRandomness(3.); + config.routing().setRoutingRandomness(3.); // --- @@ -539,10 +539,10 @@ public void testInfrastructureSpeedFactorDistanceMoreRelevantThanTravelTime() { Config config = ConfigUtils.createConfig(utils.getClassInputDirectory() ); BicycleConfigGroup bicycleConfigGroup = ConfigUtils.addOrGetModule( config, BicycleConfigGroup.class ); - config.controler().setWriteEventsInterval(0); - config.controler().setWritePlansInterval(0); - config.controler().setCreateGraphs(false); - config.controler().setDumpDataAtEnd(false); + config.controller().setWriteEventsInterval(0); + config.controller().setWritePlansInterval(0); + config.controller().setCreateGraphs(false); + config.controller().setDumpDataAtEnd(false); config.qsim().setStartTime(6. * 3600.); config.qsim().setEndTime(14. * 3600.); @@ -551,41 +551,41 @@ public void testInfrastructureSpeedFactorDistanceMoreRelevantThanTravelTime() { mainModeList.add(TransportMode.car); config.qsim().setMainModes(mainModeList); - config.strategy().setMaxAgentPlanMemorySize(5); + config.replanning().setMaxAgentPlanMemorySize(5); { StrategySettings strategySettings = new StrategySettings(); strategySettings.setStrategyName("ChangeExpBeta"); strategySettings.setWeight(1.0); - config.strategy().addStrategySettings(strategySettings); + config.replanning().addStrategySettings(strategySettings); } ActivityParams homeActivity = new ActivityParams("home"); homeActivity.setTypicalDuration(12*60*60); - config.planCalcScore().addActivityParams(homeActivity); + config.scoring().addActivityParams(homeActivity); ActivityParams workActivity = new ActivityParams("work"); workActivity.setTypicalDuration(8*60*60); - config.planCalcScore().addActivityParams(workActivity); + config.scoring().addActivityParams(workActivity); ModeParams bicycle = new ModeParams("bicycle"); bicycle.setConstant(0.); bicycle.setMarginalUtilityOfDistance(-999999); // util/m bicycle.setMarginalUtilityOfTraveling(-6.0); // util/h bicycle.setMonetaryDistanceRate(0.); - config.planCalcScore().addModeParams(bicycle); + config.scoring().addModeParams(bicycle); - config.plansCalcRoute().setNetworkModes(mainModeList); + config.routing().setNetworkModes(mainModeList); // link 2 has infrastructure speed factor = 1.0, all other links 0.01 config.network().setInputFile("network_infrastructure-speed-factor.xml"); config.plans().setInputFile("population_4.xml"); - config.controler().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); - config.controler().setOutputDirectory(utils.getOutputDirectory()); - config.controler().setLastIteration(0); + config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); + config.controller().setOutputDirectory(utils.getOutputDirectory()); + config.controller().setLastIteration(0); config.global().setNumberOfThreads(1); - config.plansCalcRoute().setRoutingRandomness(3.); + config.routing().setRoutingRandomness(3.); Scenario scenario = ScenarioUtils.loadScenario(config); var vf = scenario.getVehicles().getFactory(); @@ -626,13 +626,13 @@ private Config createConfig( int lastIteration ){ // Normal network config.network().setInputFile( "network_normal.xml" ); config.plans().setInputFile( "population_1200.xml" ); - config.controler().setOverwriteFileSetting( OverwriteFileSetting.deleteDirectoryIfExists ); - config.controler().setOutputDirectory( utils.getOutputDirectory() ); - config.controler().setLastIteration( lastIteration ); - config.controler().setLastIteration( lastIteration ); - config.controler().setWriteEventsInterval( 10 ); - config.controler().setWritePlansInterval( 10 ); - config.controler().setCreateGraphs( false ); + config.controller().setOverwriteFileSetting( OverwriteFileSetting.deleteDirectoryIfExists ); + config.controller().setOutputDirectory( utils.getOutputDirectory() ); + config.controller().setLastIteration( lastIteration ); + config.controller().setLastIteration( lastIteration ); + config.controller().setWriteEventsInterval( 10 ); + config.controller().setWritePlansInterval( 10 ); + config.controller().setCreateGraphs( false ); return config; } diff --git a/contribs/cadytsIntegration/src/main/java/org/matsim/contrib/cadyts/general/CadytsBuilderImpl.java b/contribs/cadytsIntegration/src/main/java/org/matsim/contrib/cadyts/general/CadytsBuilderImpl.java index 5ed2c548e58..12a9ae8bfbc 100644 --- a/contribs/cadytsIntegration/src/main/java/org/matsim/contrib/cadyts/general/CadytsBuilderImpl.java +++ b/contribs/cadytsIntegration/src/main/java/org/matsim/contrib/cadyts/general/CadytsBuilderImpl.java @@ -46,7 +46,7 @@ private CadytsBuilderImpl(){} // do not instantiate public static AnalyticalCalibrator buildCalibratorAndAddMeasurements(final Config config, final Counts occupCounts, LookUpItemFromId lookUp, Class idType) { - + if (occupCounts.getCounts().size() == 0) { log.warn("Counts container is empty."); } @@ -54,7 +54,7 @@ public static AnalyticalCalibrator buildCalibratorAndAddMeasurements(fina CadytsConfigGroup cadytsConfig = ConfigUtils.addOrGetModule(config, CadytsConfigGroup.GROUP_NAME, CadytsConfigGroup.class); AnalyticalCalibrator matsimCalibrator = buildCalibrator(config); - + int multiple = cadytsConfig.getTimeBinSize() / 3600 ; // e.g. "3" when timeBinSize_s = 3*3600 = 10800 // If I remember correctly, the following is trying to get around the fact that the counts time bins are fixed at hourly, but we want to @@ -64,16 +64,16 @@ public static AnalyticalCalibrator buildCalibratorAndAddMeasurements(fina // yyyy However, it seems that some of this did not work: We are using "hourly" counts, and dividing the multi-hour values by // the number of hours. ??????? - + // yyyyyy I am currently of the opinion that the multi-hour version should be decoupled from the counts format. There is a // cadyts file format which allows setting mult-hour measurements, and that seems a lot more direct than trying to use a file // format/data structure which is really not meant for this. kai, dec'13 - + //add counts data into calibrator int numberOfAddedMeasurements = 0 ; for (Map.Entry, Count> entry : occupCounts.getCounts().entrySet()) { // (loop over all counting "items" (usually locations/stations) - + T item = lookUp.getItem(Id.create(entry.getKey(), idType)) ; if ( item==null ) { throw new RuntimeException("item is null; entry=" + entry + " idType=" + idType ) ; @@ -83,7 +83,7 @@ public static AnalyticalCalibrator buildCalibratorAndAddMeasurements(fina double count = -1 ; for (Volume volume : entry.getValue().getVolumes().values()){ // (loop over the different time slots) - + if ( timeBinIndex%multiple == 0 ) { // (i.e. first timeBinIndex belonging to given bin) @@ -95,7 +95,7 @@ public static AnalyticalCalibrator buildCalibratorAndAddMeasurements(fina log.warn( " NOT adding measurement: timeBinIndex: " + timeBinIndex + "; multiple: " + multiple ) ; } else { // (i.e. last timeBinIndex belonging to given bin) - + int endTimeOfBin_s = volume.getHourOfDayStartingWithOne()*3600 - 1 ; if ( !( cadytsConfig.getStartTime() <= startTimeOfBin_s && endTimeOfBin_s <= cadytsConfig.getEndTime()) ) { log.warn( " NOT adding measurement: cadytsConfigStartTime: " + cadytsConfig.getStartTime() + "; startTimeOfBin_s: " + startTimeOfBin_s + @@ -105,7 +105,7 @@ public static AnalyticalCalibrator buildCalibratorAndAddMeasurements(fina // matsimCalibrator.addMeasurement(item, startTimeOfBin_s, endTimeOfBin_s, count/multiple, SingleLinkMeasurement.TYPE.FLOW_VEH_H); matsimCalibrator.addMeasurement(item, startTimeOfBin_s, endTimeOfBin_s, count, SingleLinkMeasurement.TYPE.COUNT_VEH ); - // changed this from FLOW_VEH_H to COUNT_VEH on 30/jul/2012 since this is no longer "hourly". + // changed this from FLOW_VEH_H to COUNT_VEH on 30/jul/2012 since this is no longer "hourly". // kai/manuel, jul'12 // Despite the above comment, I am finding this with FLOW_VEH_H. Why? kai, feb'13 // yyyyyy For the test case, this seems to produce weird results. The expected counts are 1 and 5, the expected result is 0 and 4. @@ -120,7 +120,7 @@ public static AnalyticalCalibrator buildCalibratorAndAddMeasurements(fina if ( numberOfAddedMeasurements==0 ) { log.warn("No measurements were added."); } - + if ( matsimCalibrator.getProportionalAssignment() ) { throw new RuntimeException("Gunnar says that this may not work so do not set to true. kai, sep'14") ; } @@ -129,7 +129,7 @@ public static AnalyticalCalibrator buildCalibratorAndAddMeasurements(fina public static AnalyticalCalibrator buildCalibrator(final Config config) { CadytsConfigGroup cadytsConfig = ConfigUtils.addOrGetModule(config, CadytsConfigGroup.GROUP_NAME, CadytsConfigGroup.class ) ; - + //get timeBinSize_s and validate it if ((Time.MIDNIGHT % cadytsConfig.getTimeBinSize())!= 0 ){ throw new RuntimeException("Cadyts requires a divisor of 86400 as time bin size value ."); @@ -138,10 +138,10 @@ public static AnalyticalCalibrator buildCalibrator(final Config config) { throw new RuntimeException("At this point, time bin sizes need to be multiples of 3600. This is not a restriction " + "of Cadyts, but of the counts file format, which only allows for hourly inputs") ; } - - + + AnalyticalCalibrator matsimCalibrator = new AnalyticalCalibrator<>( - config.controler().getOutputDirectory() + "/cadyts.log", + config.controller().getOutputDirectory() + "/cadyts.log", MatsimRandom.getLocalInstance().nextLong(),cadytsConfig.getTimeBinSize() ) ; @@ -159,9 +159,9 @@ public static AnalyticalCalibrator buildCalibrator(final Config config) { if ( matsimCalibrator.getBruteForce() ) { log.warn("setting bruteForce==true for calibrator, but this won't do anything in the way the cadyts matsim integration is set up. kai, mar'14") ; } - - matsimCalibrator.setStatisticsFile(config.controler().getOutputDirectory() + "/calibration-stats.txt"); + + matsimCalibrator.setStatisticsFile(config.controller().getOutputDirectory() + "/calibration-stats.txt"); return matsimCalibrator; } - + } diff --git a/contribs/cadytsIntegration/src/main/java/org/matsim/contrib/cadyts/general/CadytsPlanChanger.java b/contribs/cadytsIntegration/src/main/java/org/matsim/contrib/cadyts/general/CadytsPlanChanger.java index 4f0be74b8d4..f3a02a0bf4a 100644 --- a/contribs/cadytsIntegration/src/main/java/org/matsim/contrib/cadyts/general/CadytsPlanChanger.java +++ b/contribs/cadytsIntegration/src/main/java/org/matsim/contrib/cadyts/general/CadytsPlanChanger.java @@ -43,9 +43,9 @@ public class CadytsPlanChanger implements PlanSelector { public CadytsPlanChanger(Scenario scenario, CadytsContextI cadytsContext) { this.cadytsContext = cadytsContext; - this.beta = scenario.getConfig().planCalcScore().getBrainExpBeta() ; + this.beta = scenario.getConfig().scoring().getBrainExpBeta() ; } - + @Override public Plan selectPlan(final HasPlansAndId person) { final Plan currentPlan = person.getSelectedPlan(); @@ -90,4 +90,4 @@ public Plan selectPlan(final HasPlansAndId person) { public void setCadytsWeight(double cadytsWeight) { this.cadytsWeight = cadytsWeight; } -} \ No newline at end of file +} diff --git a/contribs/cadytsIntegration/src/main/java/org/matsim/contrib/cadyts/general/CadytsScoring.java b/contribs/cadytsIntegration/src/main/java/org/matsim/contrib/cadyts/general/CadytsScoring.java index a19b191361d..e2841dd19b8 100644 --- a/contribs/cadytsIntegration/src/main/java/org/matsim/contrib/cadyts/general/CadytsScoring.java +++ b/contribs/cadytsIntegration/src/main/java/org/matsim/contrib/cadyts/general/CadytsScoring.java @@ -45,7 +45,7 @@ public CadytsScoring(final Plan plan, Config config, final CadytsContextI con this.plansTranslator = context.getPlansTranslator(); this.matsimCalibrator = context.getCalibrator(); this.plan = plan; - this.beta = config.planCalcScore().getBrainExpBeta(); + this.beta = config.scoring().getBrainExpBeta(); } @Override diff --git a/contribs/cadytsIntegration/src/main/java/org/matsim/contrib/cadyts/run/RunCadyts4CarExample.java b/contribs/cadytsIntegration/src/main/java/org/matsim/contrib/cadyts/run/RunCadyts4CarExample.java index 4ad3a583ad5..1e1e8d5e95e 100644 --- a/contribs/cadytsIntegration/src/main/java/org/matsim/contrib/cadyts/run/RunCadyts4CarExample.java +++ b/contribs/cadytsIntegration/src/main/java/org/matsim/contrib/cadyts/run/RunCadyts4CarExample.java @@ -74,7 +74,7 @@ public ScoringFunction createNewScoringFunction(Person person) { scoringFunctionAccumulator.addScoringFunction(new CharyparNagelAgentStuckScoring(params)); final CadytsScoring scoringFunction = new CadytsScoring<>(person.getSelectedPlan(), config, cadytsContext); - scoringFunction.setWeightOfCadytsCorrection(30. * config.planCalcScore().getBrainExpBeta()) ; + scoringFunction.setWeightOfCadytsCorrection(30. * config.scoring().getBrainExpBeta()) ; scoringFunctionAccumulator.addScoringFunction(scoringFunction ); return scoringFunctionAccumulator; diff --git a/contribs/cadytsIntegration/src/test/java/org/matsim/contrib/cadyts/car/CadytsCarIT.java b/contribs/cadytsIntegration/src/test/java/org/matsim/contrib/cadyts/car/CadytsCarIT.java index 61f6692a87a..6b72ab1b664 100644 --- a/contribs/cadytsIntegration/src/test/java/org/matsim/contrib/cadyts/car/CadytsCarIT.java +++ b/contribs/cadytsIntegration/src/test/java/org/matsim/contrib/cadyts/car/CadytsCarIT.java @@ -89,12 +89,12 @@ public final void testInitialization() { String outputDir = this.utils.getOutputDirectory(); Config config = createTestConfig(inputDir, outputDir); - config.controler().setLastIteration(0); + config.controller().setLastIteration(0); StrategySettings strategySettings = new StrategySettings(Id.create(1, StrategySettings.class)); strategySettings.setStrategyName(CADYTS_STRATEGY_NAME) ; strategySettings.setWeight(1.0) ; - config.strategy().addStrategySettings(strategySettings); + config.replanning().addStrategySettings(strategySettings); CadytsConfigGroup cadytsCar = ConfigUtils.addOrGetModule(config, CadytsConfigGroup.GROUP_NAME, CadytsConfigGroup.class); // cadytsCar.addParam("startTime", "04:00:00"); cadytsCar.setStartTime( 4*3600 ); @@ -164,11 +164,11 @@ public final void testCalibrationAsScoring() throws IOException { final Config config = createTestConfig(inputDir, outputDir); - config.controler().setLastIteration(lastIteration); + config.controller().setLastIteration(lastIteration); - config.planCalcScore().setBrainExpBeta(beta); + config.scoring().setBrainExpBeta(beta); - config.strategy().addStrategySettings( new StrategySettings().setStrategyName( DefaultSelector.ChangeExpBeta ).setWeight( 1.0 ) ); + config.replanning().addStrategySettings( new StrategySettings().setStrategyName( DefaultSelector.ChangeExpBeta ).setWeight( 1.0 ) ); // === @@ -320,22 +320,22 @@ private static Config createTestConfig(String inputDir, String outputDir) { config.global().setRandomSeed(4711) ; config.network().setInputFile(inputDir + "network.xml") ; config.plans().setInputFile(inputDir + "plans5.xml") ; - config.controler().setFirstIteration(1) ; - config.controler().setLastIteration(10) ; - config.controler().setOutputDirectory(outputDir) ; - config.controler().setWriteEventsInterval(1) ; - config.controler().setMobsim(MobsimType.qsim.toString()) ; + config.controller().setFirstIteration(1) ; + config.controller().setLastIteration(10) ; + config.controller().setOutputDirectory(outputDir) ; + config.controller().setWriteEventsInterval(1) ; + config.controller().setMobsim(MobsimType.qsim.toString()) ; config.qsim().setFlowCapFactor(1.) ; config.qsim().setStorageCapFactor(1.) ; config.qsim().setStuckTime(10.) ; config.qsim().setRemoveStuckVehicles(false) ; { ActivityParams params = new ActivityParams("h") ; - config.planCalcScore().addActivityParams(params ) ; + config.scoring().addActivityParams(params ) ; params.setTypicalDuration(12*60*60.) ; }{ ActivityParams params = new ActivityParams("w") ; - config.planCalcScore().addActivityParams(params ) ; + config.scoring().addActivityParams(params ) ; params.setTypicalDuration(8*60*60.) ; } config.counts().setInputFile(inputDir + "counts5.xml"); diff --git a/contribs/cadytsIntegration/src/test/java/org/matsim/contrib/cadyts/car/CadytsCarWithPtScenarioIT.java b/contribs/cadytsIntegration/src/test/java/org/matsim/contrib/cadyts/car/CadytsCarWithPtScenarioIT.java index 538a47ae917..58f3b81fb2f 100644 --- a/contribs/cadytsIntegration/src/test/java/org/matsim/contrib/cadyts/car/CadytsCarWithPtScenarioIT.java +++ b/contribs/cadytsIntegration/src/test/java/org/matsim/contrib/cadyts/car/CadytsCarWithPtScenarioIT.java @@ -25,8 +25,8 @@ public class CadytsCarWithPtScenarioIT { @Test @Ignore public void testCadytsWithPtVehicles() { final Config config = ConfigUtils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("siouxfalls-2014"), "config_default.xml")); - config.controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles); - config.controler().setLastIteration(0); + config.controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles); + config.controller().setLastIteration(0); final Scenario scenario = ScenarioUtils.loadScenario(config); final Counts calibrationCounts = new Counts<>(); final Id testLink = Id.createLinkId("6_1"); diff --git a/contribs/cadytsIntegration/src/test/java/org/matsim/contrib/cadyts/pt/CadytsPtIT.java b/contribs/cadytsIntegration/src/test/java/org/matsim/contrib/cadyts/pt/CadytsPtIT.java index f8e081505b5..9185653ccd5 100644 --- a/contribs/cadytsIntegration/src/test/java/org/matsim/contrib/cadyts/pt/CadytsPtIT.java +++ b/contribs/cadytsIntegration/src/test/java/org/matsim/contrib/cadyts/pt/CadytsPtIT.java @@ -81,11 +81,11 @@ public final void testInitialization() { String inputDir = this.utils.getClassInputDirectory(); Config config = createTestConfig(inputDir, this.utils.getOutputDirectory()); - config.controler().setLastIteration(0); + config.controller().setLastIteration(0); StrategySettings stratSets = new StrategySettings(); stratSets.setStrategyName("ccc") ; stratSets.setWeight(1.) ; - config.strategy().addStrategySettings(stratSets) ; + config.replanning().addStrategySettings(stratSets) ; final Scenario scenario = ScenarioUtils.loadScenario(config) ; final Controler controler = new Controler(scenario); @@ -103,9 +103,9 @@ public PlanStrategy get() { } }); - controler.getConfig().controler().setCreateGraphs(false); - controler.getConfig().controler().setWriteEventsInterval(0); - controler.getConfig().controler().setDumpDataAtEnd(true); + controler.getConfig().controller().setCreateGraphs(false); + controler.getConfig().controller().setWriteEventsInterval(0); + controler.getConfig().controller().setDumpDataAtEnd(true); controler.addOverridingModule(new AbstractModule() { @Override public void install() { @@ -143,19 +143,19 @@ public final void testCalibrationAsScoring() throws IOException { final Config config = createTestConfig(inputDir, outputDir); - config.controler().setLastIteration(lastIteration) ; + config.controller().setLastIteration(lastIteration) ; - config.planCalcScore().setBrainExpBeta(beta) ; + config.scoring().setBrainExpBeta(beta) ; StrategySettings stratSets = new StrategySettings() ; stratSets.setStrategyName("ChangeExpBeta") ; stratSets.setWeight(1.0) ; - config.strategy().addStrategySettings(stratSets) ; + config.replanning().addStrategySettings(stratSets) ; // === final Controler controler = new Controler(config); - controler.getConfig().controler().setCreateGraphs(false); + controler.getConfig().controller().setCreateGraphs(false); controler.addOverridingModule(new CadytsPtModule()); controler.setScoringFunctionFactory(new ScoringFunctionFactory() { @@ -297,22 +297,22 @@ public final void testCalibration() throws IOException { Config config = createTestConfig(inputDir, outputDir) ; - config.controler().setWriteEventsInterval(0) ; - config.controler().setLastIteration(lastIteration) ; + config.controller().setWriteEventsInterval(0) ; + config.controller().setLastIteration(lastIteration) ; // seems to need 15 iterations as "warm-up"; at least the cadyts corrections are much smaller until then. - config.planCalcScore().setBrainExpBeta(beta) ; + config.scoring().setBrainExpBeta(beta) ; StrategySettings stratSets = new StrategySettings(); stratSets.setStrategyName("ccc") ; stratSets.setWeight(1.) ; - config.strategy().addStrategySettings(stratSets) ; + config.replanning().addStrategySettings(stratSets) ; final Scenario scenario = ScenarioUtils.loadScenario(config) ; final Controler controler = new Controler( scenario ); - controler.getConfig().controler().setCreateGraphs(false); - controler.getConfig().controler().setDumpDataAtEnd(true); + controler.getConfig().controller().setCreateGraphs(false); + controler.getConfig().controller().setDumpDataAtEnd(true); controler.addOverridingModule(new CadytsPtModule()); controler.addOverridingModule(new AbstractModule() { @@ -447,16 +447,16 @@ public final void testCalibrationTwo() throws IOException { Config config = createTestConfig(inputDir, this.utils.getOutputDirectory()); - config.controler().setLastIteration(lastIteration) ; - config.controler().setWritePlansInterval(1) ; - config.controler().setWriteEventsInterval(1) ; + config.controller().setLastIteration(lastIteration) ; + config.controller().setWritePlansInterval(1) ; + config.controller().setWriteEventsInterval(1) ; config.ptCounts().setPtCountsInterval(1) ; StrategySettings stratSets = new StrategySettings(); stratSets.setStrategyName("ccc") ; stratSets.setWeight(1.) ; - config.strategy().addStrategySettings(stratSets) ; + config.replanning().addStrategySettings(stratSets) ; CadytsConfigGroup cConfig = (CadytsConfigGroup) config.getModule(CadytsConfigGroup.GROUP_NAME) ; cConfig.setTimeBinSize(7200) ; @@ -482,9 +482,9 @@ public PlanStrategy get() { } }); - controler.getConfig().controler().setCreateGraphs(false); - controler.getConfig().controler().setWriteEventsInterval(0); - controler.getConfig().controler().setDumpDataAtEnd(true); + controler.getConfig().controller().setCreateGraphs(false); + controler.getConfig().controller().setWriteEventsInterval(0); + controler.getConfig().controller().setDumpDataAtEnd(true); controler.run(); // ==================================== @@ -620,11 +620,11 @@ private static Config createTestConfig(String inputDir, String outputDir) { // --- config.transit().setUseTransit(true) ; // --- - config.controler().setFirstIteration(1) ; - config.controler().setLastIteration(10) ; - config.controler().setOutputDirectory(outputDir) ; - config.controler().setWriteEventsInterval(1) ; - config.controler().setMobsim(MobsimType.qsim.toString()) ; + config.controller().setFirstIteration(1) ; + config.controller().setLastIteration(10) ; + config.controller().setOutputDirectory(outputDir) ; + config.controller().setWriteEventsInterval(1) ; + config.controller().setMobsim(MobsimType.qsim.toString()) ; // --- config.qsim().setFlowCapFactor(0.02) ; @@ -640,11 +640,11 @@ private static Config createTestConfig(String inputDir, String outputDir) { // --- { ActivityParams params = new ActivityParams("h") ; - config.planCalcScore().addActivityParams(params ) ; + config.scoring().addActivityParams(params ) ; params.setTypicalDuration(12*60*60.) ; }{ ActivityParams params = new ActivityParams("w") ; - config.planCalcScore().addActivityParams(params ) ; + config.scoring().addActivityParams(params ) ; params.setTypicalDuration(8*60*60.) ; } // --- diff --git a/contribs/carsharing/src/main/java/org/matsim/contrib/carsharing/control/listeners/CarsharingListener.java b/contribs/carsharing/src/main/java/org/matsim/contrib/carsharing/control/listeners/CarsharingListener.java index 3409c505f63..42c2d594c05 100644 --- a/contribs/carsharing/src/main/java/org/matsim/contrib/carsharing/control/listeners/CarsharingListener.java +++ b/contribs/carsharing/src/main/java/org/matsim/contrib/carsharing/control/listeners/CarsharingListener.java @@ -69,7 +69,7 @@ public void notifyIterationEnds(IterationEndsEvent event) { e.printStackTrace(); } - if (event.getIteration() == controler.getConfig().controler().getLastIteration()) { + if (event.getIteration() == controler.getConfig().controller().getLastIteration()) { final BufferedWriter outLinkStats = IOUtils .getBufferedWriter(this.controler.getControlerIO().getOutputFilename("CS.txt")); try { diff --git a/contribs/carsharing/src/test/java/org/matsim/contrib/carsharing/runExample/RunCarsharingIT.java b/contribs/carsharing/src/test/java/org/matsim/contrib/carsharing/runExample/RunCarsharingIT.java index ea7dd5f4dfa..9431005a492 100644 --- a/contribs/carsharing/src/test/java/org/matsim/contrib/carsharing/runExample/RunCarsharingIT.java +++ b/contribs/carsharing/src/test/java/org/matsim/contrib/carsharing/runExample/RunCarsharingIT.java @@ -66,8 +66,8 @@ public final void test() { new CarsharingConfigGroup(), new DvrpConfigGroup()); - config.controler().setOutputDirectory(utils.getOutputDirectory()); - config.controler().setOverwriteFileSetting(OverwriteFileSetting.overwriteExistingFiles); + config.controller().setOutputDirectory(utils.getOutputDirectory()); + config.controller().setOverwriteFileSetting(OverwriteFileSetting.overwriteExistingFiles); config.network().setInputFile("network.xml"); @@ -79,8 +79,8 @@ public final void test() { config.facilities().setInputFile("facilities.xml"); config.facilities().setFacilitiesSource(FacilitiesConfigGroup.FacilitiesSource.fromFile); - config.plansCalcRoute().setAccessEgressType(AccessEgressType.none); // otherwise does not work. kai,feb'16 - config.plansCalcRoute().setRoutingRandomness(0.); + config.routing().setAccessEgressType(AccessEgressType.none); // otherwise does not work. kai,feb'16 + config.routing().setRoutingRandomness(0.); // config.plansCalcRoute().setInsertingAccessEgressWalk(AccessEgressType.directWalk); CarsharingConfigGroup csConfig = (CarsharingConfigGroup) config.getModule(CarsharingConfigGroup.GROUP_NAME); @@ -103,21 +103,21 @@ public final void test() { params.setTeleportedModeSpeed(0.83333333333); // params.setTeleportedModeSpeed( 2.0 ); params.setBeelineDistanceFactor(1.3); - config.plansCalcRoute().addModeRoutingParams(params); + config.routing().addModeRoutingParams(params); } { - config.plansCalcRoute().removeModeRoutingParams(TransportMode.walk); + config.routing().removeModeRoutingParams(TransportMode.walk); TeleportedModeParams params = new TeleportedModeParams(TransportMode.walk); params.setTeleportedModeSpeed(0.83333333333); // params.setTeleportedModeSpeed( 2.0 ); params.setBeelineDistanceFactor(1.3); - config.plansCalcRoute().addModeRoutingParams(params); + config.routing().addModeRoutingParams(params); } // --- Scenario scenario = ScenarioUtils.loadScenario(config); - config.plansCalcRoute().setAccessEgressType(AccessEgressType.accessEgressModeToLink); + config.routing().setAccessEgressType(AccessEgressType.accessEgressModeToLink); // --- diff --git a/contribs/commercialTrafficApplications/src/main/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/DefaultCommercialJobGenerator.java b/contribs/commercialTrafficApplications/src/main/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/DefaultCommercialJobGenerator.java index f38e91f70e4..c9a1becb44f 100644 --- a/contribs/commercialTrafficApplications/src/main/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/DefaultCommercialJobGenerator.java +++ b/contribs/commercialTrafficApplications/src/main/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/DefaultCommercialJobGenerator.java @@ -301,7 +301,7 @@ public void notifyBeforeMobsim(BeforeMobsimEvent event) { createAndAddFreightAgents(this.carriers, this.scenario.getPopulation()); event.getServices().getInjector().getInstance(ScoreCommercialJobs.class).prepareTourArrivalsForDay(); - String dir = event.getServices().getConfig().controler().getOutputDirectory() + "/ITERS/it." + event.getIteration() + "/"; + String dir = event.getServices().getConfig().controller().getOutputDirectory() + "/ITERS/it." + event.getIteration() + "/"; log.info("writing carrier file of iteration " + event.getIteration() + " to " + dir); CarrierPlanWriter planWriter = new CarrierPlanWriter(carriers); planWriter.write(dir + "carriers_it" + event.getIteration() + ".xml"); @@ -415,7 +415,7 @@ private void toggleChangeCommercialJobOperatorStrategy(int currentIteration) { log.info("Toggle " + ChangeCommercialJobOperator.SELECTOR_NAME); } - Collection allStrategies = this.scenario.getConfig().strategy().getStrategySettings(); + Collection allStrategies = this.scenario.getConfig().replanning().getStrategySettings(); for (StrategySettings strategy : allStrategies) { if (strategy.getStrategyName().equals(ChangeCommercialJobOperator.SELECTOR_NAME)) { diff --git a/contribs/commercialTrafficApplications/src/main/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/RunJointDemandCarToggleJspritExample.java b/contribs/commercialTrafficApplications/src/main/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/RunJointDemandCarToggleJspritExample.java index 1e71f4b5373..e2b9e8b9260 100644 --- a/contribs/commercialTrafficApplications/src/main/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/RunJointDemandCarToggleJspritExample.java +++ b/contribs/commercialTrafficApplications/src/main/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/RunJointDemandCarToggleJspritExample.java @@ -91,25 +91,25 @@ private static void prepareConfig(Config config) { ReplanningConfigGroup.StrategySettings changeExpBeta = new ReplanningConfigGroup.StrategySettings(); changeExpBeta.setStrategyName(DefaultPlanStrategiesModule.DefaultSelector.ChangeExpBeta); changeExpBeta.setWeight(0.5); - config.strategy().addStrategySettings(changeExpBeta); + config.replanning().addStrategySettings(changeExpBeta); ReplanningConfigGroup.StrategySettings changeJobOperator = new ReplanningConfigGroup.StrategySettings(); changeJobOperator.setStrategyName(ChangeCommercialJobOperator.SELECTOR_NAME); changeJobOperator.setWeight(0.5); - config.strategy().addStrategySettings(changeJobOperator); + config.replanning().addStrategySettings(changeJobOperator); - config.strategy().setFractionOfIterationsToDisableInnovation(.8); + config.replanning().setFractionOfIterationsToDisableInnovation(.8); ScoringConfigGroup.ActivityParams home = new ScoringConfigGroup.ActivityParams("home"); home.setTypicalDuration(14 * 3600); - config.planCalcScore().addActivityParams(home); + config.scoring().addActivityParams(home); ScoringConfigGroup.ActivityParams work = new ScoringConfigGroup.ActivityParams("work"); work.setTypicalDuration(14 * 3600); work.setOpeningTime(8 * 3600); work.setClosingTime(8 * 3600); - config.planCalcScore().addActivityParams(work); - config.controler().setWriteEventsInterval(5); - config.controler().setOutputDirectory("output/commercialTrafficApplications/jointDemand/RunJointDemandCarToggleJspritExample"); - config.controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists); - config.controler().setLastIteration(5); + config.scoring().addActivityParams(work); + config.controller().setWriteEventsInterval(5); + config.controller().setOutputDirectory("output/commercialTrafficApplications/jointDemand/RunJointDemandCarToggleJspritExample"); + config.controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists); + config.controller().setLastIteration(5); } } diff --git a/contribs/commercialTrafficApplications/src/main/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/examples/RunJointDemandCarExample.java b/contribs/commercialTrafficApplications/src/main/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/examples/RunJointDemandCarExample.java index bc9536aca2a..a8ba7de6f45 100644 --- a/contribs/commercialTrafficApplications/src/main/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/examples/RunJointDemandCarExample.java +++ b/contribs/commercialTrafficApplications/src/main/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/examples/RunJointDemandCarExample.java @@ -93,25 +93,25 @@ private static void prepareConfig(Config config) { ReplanningConfigGroup.StrategySettings changeExpBeta = new ReplanningConfigGroup.StrategySettings(); changeExpBeta.setStrategyName(DefaultPlanStrategiesModule.DefaultSelector.ChangeExpBeta); changeExpBeta.setWeight(0.5); - config.strategy().addStrategySettings(changeExpBeta); + config.replanning().addStrategySettings(changeExpBeta); ReplanningConfigGroup.StrategySettings changeJobOperator = new ReplanningConfigGroup.StrategySettings(); changeJobOperator.setStrategyName(ChangeCommercialJobOperator.SELECTOR_NAME); changeJobOperator.setWeight(0.5); - config.strategy().addStrategySettings(changeJobOperator); + config.replanning().addStrategySettings(changeJobOperator); - config.strategy().setFractionOfIterationsToDisableInnovation(.8); + config.replanning().setFractionOfIterationsToDisableInnovation(.8); ScoringConfigGroup.ActivityParams home = new ScoringConfigGroup.ActivityParams("home"); home.setTypicalDuration(14 * 3600); - config.planCalcScore().addActivityParams(home); + config.scoring().addActivityParams(home); ScoringConfigGroup.ActivityParams work = new ScoringConfigGroup.ActivityParams("work"); work.setTypicalDuration(14 * 3600); work.setOpeningTime(8 * 3600); work.setClosingTime(8 * 3600); - config.planCalcScore().addActivityParams(work); - config.controler().setWriteEventsInterval(5); - config.controler().setOutputDirectory("output/commercialTrafficApplications/jointDemand/RunJointDemandCarExample"); - config.controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists); - config.controler().setLastIteration(5); + config.scoring().addActivityParams(work); + config.controller().setWriteEventsInterval(5); + config.controller().setOutputDirectory("output/commercialTrafficApplications/jointDemand/RunJointDemandCarExample"); + config.controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists); + config.controller().setLastIteration(5); } } diff --git a/contribs/commercialTrafficApplications/src/main/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/examples/RunJointDemandDRTExample.java b/contribs/commercialTrafficApplications/src/main/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/examples/RunJointDemandDRTExample.java index 0d9d61cc72f..30619130f39 100644 --- a/contribs/commercialTrafficApplications/src/main/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/examples/RunJointDemandDRTExample.java +++ b/contribs/commercialTrafficApplications/src/main/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/examples/RunJointDemandDRTExample.java @@ -80,8 +80,8 @@ public static void main(String[] args) throws IOException { public void run(URL configURL){ Config config = loadConfig(configURL); prepareConfig(config); - DrtConfigs.adjustMultiModeDrtConfig(MultiModeDrtConfigGroup.get(config), config.planCalcScore(), - config.plansCalcRoute()); + DrtConfigs.adjustMultiModeDrtConfig(MultiModeDrtConfigGroup.get(config), config.scoring(), + config.routing()); Scenario scenario = DrtControlerCreator.createScenarioWithDrtRouteFactory(config); ScenarioUtils.loadScenario(scenario); @@ -105,30 +105,30 @@ private static void prepareConfig(Config config) { ReplanningConfigGroup.StrategySettings changeExpBeta = new ReplanningConfigGroup.StrategySettings(); changeExpBeta.setStrategyName(DefaultPlanStrategiesModule.DefaultSelector.ChangeExpBeta); changeExpBeta.setWeight(0.5); - config.strategy().addStrategySettings(changeExpBeta); + config.replanning().addStrategySettings(changeExpBeta); ReplanningConfigGroup.StrategySettings changeServiceOperator = new ReplanningConfigGroup.StrategySettings(); changeServiceOperator.setStrategyName(ChangeCommercialJobOperator.SELECTOR_NAME); changeServiceOperator.setWeight(0.5); - config.strategy().addStrategySettings(changeServiceOperator); + config.replanning().addStrategySettings(changeServiceOperator); - config.strategy().setFractionOfIterationsToDisableInnovation(.8); + config.replanning().setFractionOfIterationsToDisableInnovation(.8); ScoringConfigGroup.ActivityParams home = new ScoringConfigGroup.ActivityParams("home"); home.setTypicalDuration(14 * 3600); - config.planCalcScore().addActivityParams(home); + config.scoring().addActivityParams(home); ScoringConfigGroup.ActivityParams work = new ScoringConfigGroup.ActivityParams("work"); work.setTypicalDuration(14 * 3600); work.setOpeningTime(8 * 3600); work.setClosingTime(8 * 3600); - config.planCalcScore().addActivityParams(work); - config.controler().setWriteEventsInterval(1); - config.controler().setOutputDirectory("output/commercialTrafficApplications/jointDemand/RunJointDemandUsingDRTExample"); - config.controler() + config.scoring().addActivityParams(work); + config.controller().setWriteEventsInterval(1); + config.controller().setOutputDirectory("output/commercialTrafficApplications/jointDemand/RunJointDemandUsingDRTExample"); + config.controller() .setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists); config.qsim().setEndTime(26 * 3600); config.qsim().setSimEndtimeInterpretation(QSimConfigGroup.EndtimeInterpretation.onlyUseEndtime); - config.controler().setLastIteration(5); + config.controller().setLastIteration(5); } private static void loadConfigGroups(Config config) { diff --git a/contribs/commercialTrafficApplications/src/test/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/CommercialTrafficIntegrationTest.java b/contribs/commercialTrafficApplications/src/test/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/CommercialTrafficIntegrationTest.java index 2ea7d0a9853..501f4057ae9 100644 --- a/contribs/commercialTrafficApplications/src/test/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/CommercialTrafficIntegrationTest.java +++ b/contribs/commercialTrafficApplications/src/test/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/CommercialTrafficIntegrationTest.java @@ -15,7 +15,7 @@ public class CommercialTrafficIntegrationTest { @Test public void runCommercialTrafficIT() { Config config = ConfigUtils.loadConfig("./scenarios/grid/jointDemand_config.xml"); - config.controler().setLastIteration(5); + config.controller().setLastIteration(5); ConfigUtils.addOrGetModule(config, JointDemandConfigGroup.class); FreightConfigGroup freightConfigGroup = ConfigUtils.addOrGetModule(config, FreightConfigGroup.class); freightConfigGroup.setCarriersFile("jointDemand_carriers_car.xml"); diff --git a/contribs/commercialTrafficApplications/src/test/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/IsTheRightCustomerScoredTest.java b/contribs/commercialTrafficApplications/src/test/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/IsTheRightCustomerScoredTest.java index 3b250c4f855..339caa1695e 100644 --- a/contribs/commercialTrafficApplications/src/test/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/IsTheRightCustomerScoredTest.java +++ b/contribs/commercialTrafficApplications/src/test/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/IsTheRightCustomerScoredTest.java @@ -47,8 +47,8 @@ public class IsTheRightCustomerScoredTest { public void setUp() { Config config = ConfigUtils.loadConfig("./scenarios/grid/jointDemand_config.xml"); - config.controler().setLastIteration(0); - config.controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles); + config.controller().setLastIteration(0); + config.controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles); JointDemandConfigGroup jointDemandConfigGroup = ConfigUtils.addOrGetModule(config, JointDemandConfigGroup.class); jointDemandConfigGroup.setMaxJobScore(MAX_JOB_SCORE); FreightConfigGroup freightConfigGroup = ConfigUtils.addOrGetModule(config, FreightConfigGroup.class); diff --git a/contribs/common/src/main/java/org/matsim/contrib/common/timeprofile/ProfileWriter.java b/contribs/common/src/main/java/org/matsim/contrib/common/timeprofile/ProfileWriter.java index 5f5a9194b7b..768ec3ea404 100644 --- a/contribs/common/src/main/java/org/matsim/contrib/common/timeprofile/ProfileWriter.java +++ b/contribs/common/src/main/java/org/matsim/contrib/common/timeprofile/ProfileWriter.java @@ -87,7 +87,7 @@ public void notifyIterationEnds(IterationEndsEvent event) { } } - if (this.matsimServices.getConfig().controler().isCreateGraphs()) { + if (this.matsimServices.getConfig().controller().isCreateGraphs()) { DefaultTableXYDataset xyDataset = createXYDataset(times, profiles); generateImage(xyDataset, TimeProfileCharts.ChartType.Line); generateImage(xyDataset, TimeProfileCharts.ChartType.StackedArea); @@ -115,7 +115,7 @@ private DefaultTableXYDataset createXYDataset(double[] times, Map(config.planCalcScore())); + PlanStrategyImpl strategy1 = new PlanStrategyImpl(new ExpBetaPlanSelector<>(config.scoring())); manager.addStrategy( strategy1, null, 0.80 ); PlanStrategyImpl strategy2 = new PlanStrategyImpl(new RandomPlanSelector<>()); @@ -317,12 +317,12 @@ private static class TestControlerListener implements StartupListener, Iteration @Override public void notifyStartup(final StartupEvent event) { // do some test to ensure the scenario is correct - double beta_travel = event.getServices().getConfig().planCalcScore().getModes().get(TransportMode.car).getMarginalUtilityOfTraveling(); + double beta_travel = event.getServices().getConfig().scoring().getModes().get(TransportMode.car).getMarginalUtilityOfTraveling(); if ((beta_travel != -6.0) && (beta_travel != -66.0)) { throw new IllegalArgumentException("Unexpected value for beta_travel. Expected -6.0 or -66.0, actual value is " + beta_travel); } - int lastIter = event.getServices().getConfig().controler().getLastIteration(); + int lastIter = event.getServices().getConfig().controller().getLastIteration(); if (lastIter < 100) { throw new IllegalArgumentException("Controler.lastIteration must be at least 100. Current value is " + lastIter); } @@ -360,7 +360,7 @@ public void notifyIterationEnds(final IterationEndsEvent event) { event.getServices().getEvents().removeHandler(this.ttAnalyzer); } if (iteration == 100) { - double beta_travel = event.getServices().getConfig().planCalcScore().getModes().get(TransportMode.car).getMarginalUtilityOfTraveling(); + double beta_travel = event.getServices().getConfig().scoring().getModes().get(TransportMode.car).getMarginalUtilityOfTraveling(); /* *************************************************************** * AUTOMATIC VERIFICATION OF THE TESTS: * diff --git a/contribs/common/src/test/java/org/matsim/integration/always/BetaTravelTest6IT.java b/contribs/common/src/test/java/org/matsim/integration/always/BetaTravelTest6IT.java index 6c9792fb458..9db009cbcf8 100644 --- a/contribs/common/src/test/java/org/matsim/integration/always/BetaTravelTest6IT.java +++ b/contribs/common/src/test/java/org/matsim/integration/always/BetaTravelTest6IT.java @@ -133,7 +133,7 @@ public class BetaTravelTest6IT { @Test public void testBetaTravel_6() { Config config = utils.loadConfig("../../examples/scenarios/equil/config.xml"); // default config ConfigUtils.loadConfig(config, utils.getInputDirectory() + "config.xml"); // specific setting for this test - config.controler().setWritePlansInterval(0); + config.controller().setWritePlansInterval(0); config.plans().setActivityDurationInterpretation( ActivityDurationInterpretation.tryEndTimeThenDuration ); /* * The input plans file is not sorted. After switching from TreeMap to LinkedHashMap @@ -150,9 +150,9 @@ public void install() { } }); controler.addControlerListener(new TestControlerListener()); - controler.getConfig().controler().setCreateGraphs(false); - controler.getConfig().controler().setDumpDataAtEnd(false); - controler.getConfig().controler().setWriteEventsInterval(0); + controler.getConfig().controller().setCreateGraphs(false); + controler.getConfig().controller().setDumpDataAtEnd(false); + controler.getConfig().controller().setWriteEventsInterval(0); controler.run(); } @@ -273,7 +273,7 @@ public StrategyManager get() { StrategyManager manager = new StrategyManager(); manager.setMaxPlansPerAgent(5); - PlanStrategyImpl strategy1 = new PlanStrategyImpl(new ExpBetaPlanSelector(config.planCalcScore())); + PlanStrategyImpl strategy1 = new PlanStrategyImpl(new ExpBetaPlanSelector(config.scoring())); manager.addStrategy( strategy1, null, 0.80 ); PlanStrategyImpl strategy2 = new PlanStrategyImpl(new RandomPlanSelector()); @@ -314,12 +314,12 @@ public TestControlerListener() { @Override public void notifyStartup(final StartupEvent event) { // do some test to ensure the scenario is correct - double beta_travel = event.getServices().getConfig().planCalcScore().getModes().get(TransportMode.car).getMarginalUtilityOfTraveling(); + double beta_travel = event.getServices().getConfig().scoring().getModes().get(TransportMode.car).getMarginalUtilityOfTraveling(); if ((beta_travel != -6.0) && (beta_travel != -66.0)) { throw new IllegalArgumentException("Unexpected value for beta_travel. Expected -6.0 or -66.0, actual value is " + beta_travel); } - int lastIter = event.getServices().getConfig().controler().getLastIteration(); + int lastIter = event.getServices().getConfig().controller().getLastIteration(); if (lastIter < 100) { throw new IllegalArgumentException("Controler.lastIteration must be at least 100. Current value is " + lastIter); } @@ -357,7 +357,7 @@ public void notifyIterationEnds(final IterationEndsEvent event) { event.getServices().getEvents().removeHandler(this.ttAnalyzer); } if (iteration == 100) { - double beta_travel = event.getServices().getConfig().planCalcScore().getModes().get(TransportMode.car).getMarginalUtilityOfTraveling(); + double beta_travel = event.getServices().getConfig().scoring().getModes().get(TransportMode.car).getMarginalUtilityOfTraveling(); /* *************************************************************** * AUTOMATIC VERIFICATION OF THE TESTS: * diff --git a/contribs/decongestion/src/main/java/org/matsim/contrib/decongestion/DecongestionControlerListener.java b/contribs/decongestion/src/main/java/org/matsim/contrib/decongestion/DecongestionControlerListener.java index 656d7e583d0..080d92d0c51 100644 --- a/contribs/decongestion/src/main/java/org/matsim/contrib/decongestion/DecongestionControlerListener.java +++ b/contribs/decongestion/src/main/java/org/matsim/contrib/decongestion/DecongestionControlerListener.java @@ -103,7 +103,7 @@ public void notifyStartup(StartupEvent event) { log.info("decongestion settings: " + congestionInfo.getDecongestionConfigGroup().toString()); - this.outputDirectory = this.congestionInfo.getScenario().getConfig().controler().getOutputDirectory(); + this.outputDirectory = this.congestionInfo.getScenario().getConfig().controller().getOutputDirectory(); if (!outputDirectory.endsWith("/")) { log.info("Adjusting output directory."); outputDirectory = outputDirectory + "/"; @@ -117,13 +117,13 @@ public void notifyAfterMobsim(AfterMobsimEvent event) { computeDelays(event); } - if (event.getIteration() == this.congestionInfo.getScenario().getConfig().controler().getFirstIteration()) { + if (event.getIteration() == this.congestionInfo.getScenario().getConfig().controller().getFirstIteration()) { // skip first iteration } else if (event.getIteration() % this.congestionInfo.getDecongestionConfigGroup().getUpdatePriceInterval() == 0.) { - int totalNumberOfIterations = this.congestionInfo.getScenario().getConfig().controler().getLastIteration() - this.congestionInfo.getScenario().getConfig().controler().getFirstIteration(); - int iterationCounter = event.getIteration() - this.congestionInfo.getScenario().getConfig().controler().getFirstIteration(); + int totalNumberOfIterations = this.congestionInfo.getScenario().getConfig().controller().getLastIteration() - this.congestionInfo.getScenario().getConfig().controller().getFirstIteration(); + int iterationCounter = event.getIteration() - this.congestionInfo.getScenario().getConfig().controller().getFirstIteration(); if (iterationCounter < this.congestionInfo.getDecongestionConfigGroup().getFractionOfIterationsToEndPriceAdjustment() * totalNumberOfIterations && iterationCounter > this.congestionInfo.getDecongestionConfigGroup().getFractionOfIterationsToStartPriceAdjustment() * totalNumberOfIterations) { @@ -136,8 +136,8 @@ public void notifyAfterMobsim(AfterMobsimEvent event) { } if (event.getIteration() % this.congestionInfo.getDecongestionConfigGroup().getWriteOutputIteration() == 0.) { - CongestionInfoWriter.writeDelays(congestionInfo, event.getIteration(), this.outputDirectory + "ITERS/it." + event.getIteration() + "/", this.congestionInfo.getScenario().getConfig().controler().getRunId()); - CongestionInfoWriter.writeTolls(congestionInfo, event.getIteration(), this.outputDirectory + "ITERS/it." + event.getIteration() + "/", this.congestionInfo.getScenario().getConfig().controler().getRunId()); + CongestionInfoWriter.writeDelays(congestionInfo, event.getIteration(), this.outputDirectory + "ITERS/it." + event.getIteration() + "/", this.congestionInfo.getScenario().getConfig().controller().getRunId()); + CongestionInfoWriter.writeTolls(congestionInfo, event.getIteration(), this.outputDirectory + "ITERS/it." + event.getIteration() + "/", this.congestionInfo.getScenario().getConfig().controller().getRunId()); } } @@ -197,7 +197,7 @@ public void notifyIterationEnds(IterationEndsEvent event) { if ( person.getSelectedPlan().getScore()==null ) { throw new RuntimeException( "score is null; don't know how to continue.") ; } - monetizedUserBenefits += person.getSelectedPlan().getScore() / this.congestionInfo.getScenario().getConfig().planCalcScore().getMarginalUtilityOfMoney(); + monetizedUserBenefits += person.getSelectedPlan().getScore() / this.congestionInfo.getScenario().getConfig().scoring().getMarginalUtilityOfMoney(); } this.iteration2userBenefits.put(event.getIteration(), monetizedUserBenefits); @@ -207,35 +207,35 @@ public void notifyIterationEnds(IterationEndsEvent event) { this.iteration2totalTravelTime, this.iteration2userBenefits, outputDirectory, - this.congestionInfo.getScenario().getConfig().controler().getRunId() + this.congestionInfo.getScenario().getConfig().controller().getRunId() ); XYLineChart chart1 = new XYLineChart("Total travel time and total delay", "Iteration", "Hours"); double[] iterations1 = new double[event.getIteration() + 1]; double[] values1a = new double[event.getIteration() + 1]; double[] values1b = new double[event.getIteration() + 1]; - for (int i = this.congestionInfo.getScenario().getConfig().controler().getFirstIteration(); i <= event.getIteration(); i++) { + for (int i = this.congestionInfo.getScenario().getConfig().controller().getFirstIteration(); i <= event.getIteration(); i++) { iterations1[i] = i; values1a[i] = this.iteration2totalDelay.get(i) / 3600.; values1b[i] = this.iteration2totalTravelTime.get(i) / 3600.; } chart1.addSeries("Total delay", iterations1, values1a); chart1.addSeries("Total travel time", iterations1, values1b); - chart1.saveAsPng(outputDirectory + this.congestionInfo.getScenario().getConfig().controler().getRunId() + ".decongestion_travelTime_delay.png", 800, 600); + chart1.saveAsPng(outputDirectory + this.congestionInfo.getScenario().getConfig().controller().getRunId() + ".decongestion_travelTime_delay.png", 800, 600); XYLineChart chart2 = new XYLineChart("user benefits and toll revenues", "Iteration", "Monetary units"); double[] iterations2 = new double[event.getIteration() + 1]; double[] values2b = new double[event.getIteration() + 1]; double[] values2c = new double[event.getIteration() + 1]; - for (int i = this.congestionInfo.getScenario().getConfig().controler().getFirstIteration(); i <= event.getIteration(); i++) { + for (int i = this.congestionInfo.getScenario().getConfig().controller().getFirstIteration(); i <= event.getIteration(); i++) { iterations2[i] = i; values2b[i] = this.iteration2userBenefits.get(i); values2c[i] = this.iteration2totalTollPayments.get(i); } chart2.addSeries("User benefits", iterations2, values2b); chart2.addSeries("Toll payments (decongestion tolls only)", iterations2, values2c); - chart2.saveAsPng(outputDirectory + this.congestionInfo.getScenario().getConfig().controler().getRunId() + ".decongestion_userBenefits_tolls.png", 800, 600); + chart2.saveAsPng(outputDirectory + this.congestionInfo.getScenario().getConfig().controller().getRunId() + ".decongestion_userBenefits_tolls.png", 800, 600); } } @@ -243,9 +243,9 @@ public void notifyIterationEnds(IterationEndsEvent event) { public void notifyIterationStarts(IterationStartsEvent event) { if (congestionInfo.getDecongestionConfigGroup().getUpdatePriceInterval() > 1) { - if (event.getIteration() == this.congestionInfo.getScenario().getConfig().controler().getFirstIteration()) { + if (event.getIteration() == this.congestionInfo.getScenario().getConfig().controller().getFirstIteration()) { - this.nextDisableInnovativeStrategiesIteration = (int) (congestionInfo.getScenario().getConfig().strategy().getFractionOfIterationsToDisableInnovation() * congestionInfo.getDecongestionConfigGroup().getUpdatePriceInterval()); + this.nextDisableInnovativeStrategiesIteration = (int) (congestionInfo.getScenario().getConfig().replanning().getFractionOfIterationsToDisableInnovation() * congestionInfo.getDecongestionConfigGroup().getUpdatePriceInterval()); log.info("next disable innovative strategies iteration: " + this.nextDisableInnovativeStrategiesIteration); if (this.nextDisableInnovativeStrategiesIteration != 0) { @@ -274,7 +274,7 @@ public void notifyIterationStarts(IterationStartsEvent event) { } else if (event.getIteration() == this.nextEnableInnovativeStrategiesIteration) { // set weight back to original value - if (event.getIteration() >= congestionInfo.getScenario().getConfig().strategy().getFractionOfIterationsToDisableInnovation() * (congestionInfo.getScenario().getConfig().controler().getLastIteration() - congestionInfo.getScenario().getConfig().controler().getFirstIteration())) { + if (event.getIteration() >= congestionInfo.getScenario().getConfig().replanning().getFractionOfIterationsToDisableInnovation() * (congestionInfo.getScenario().getConfig().controller().getLastIteration() - congestionInfo.getScenario().getConfig().controller().getFirstIteration())) { log.info("Strategies are switched off by global settings. Do not set back the strategy parameters to original values..."); @@ -288,7 +288,7 @@ public void notifyIterationStarts(IterationStartsEvent event) { if (isInnovativeStrategy(strategy)) { double originalValue = -1.0; - for (StrategySettings setting : event.getServices().getConfig().strategy().getStrategySettings()) { + for (StrategySettings setting : event.getServices().getConfig().replanning().getStrategySettings()) { log.info("setting: " + setting.getStrategyName()); log.info("strategyName: " + strategyName); diff --git a/contribs/decongestion/src/main/java/org/matsim/contrib/decongestion/DecongestionRunExample.java b/contribs/decongestion/src/main/java/org/matsim/contrib/decongestion/DecongestionRunExample.java index a7ae5e473de..72aca4c0fa7 100644 --- a/contribs/decongestion/src/main/java/org/matsim/contrib/decongestion/DecongestionRunExample.java +++ b/contribs/decongestion/src/main/java/org/matsim/contrib/decongestion/DecongestionRunExample.java @@ -19,7 +19,7 @@ * *********************************************************************** */ /** - * + * */ package org.matsim.contrib.decongestion; @@ -41,7 +41,7 @@ /** * Starts an interval-based decongestion pricing simulation run. - * + * * @author ikaddoura * */ @@ -50,22 +50,22 @@ public class DecongestionRunExample { private static final Logger log = LogManager.getLogger(DecongestionRunExample.class); private static String configFile; - + public static void main(String[] args) throws IOException { - + if (args.length > 0) { log.info("Starting simulation run with the following arguments:"); - configFile = args[0]; + configFile = args[0]; log.info("config file: "+ configFile); } else { configFile = "path/to/config.xml"; } - + DecongestionRunExample main = new DecongestionRunExample(); main.run(); - + } private void run() { @@ -77,9 +77,9 @@ private void run() { decongestionSettings.setUpdatePriceInterval(1); decongestionSettings.setMsa(false); decongestionSettings.setTollBlendFactor(1.0); - + // decongestionSettings.setDecongestionApproach(DecongestionApproach.P_MC); - + decongestionSettings.setDecongestionApproach(DecongestionApproach.PID); decongestionSettings.setKd(0.005); decongestionSettings.setKi(0.005); @@ -87,38 +87,38 @@ private void run() { decongestionSettings.setIntegralApproach(IntegralApproach.UnusedHeadway); decongestionSettings.setIntegralApproachUnusedHeadwayFactor(10.0); decongestionSettings.setIntegralApproachAverageAlpha(0.0); - + // decongestionSettings.setDecongestionApproach(DecongestionApproach.BangBang); // decongestionSettings.setTOLL_ADJUSTMENT(1.0); // decongestionSettings.setINITIAL_TOLL(1.0); - + Config config = ConfigUtils.loadConfig(configFile); config.addModule(decongestionSettings); - + final Scenario scenario = ScenarioUtils.loadScenario(config); Controler controler = new Controler(scenario); - + // ############################################################# - + // congestion toll computation - + controler.addOverridingModule(new DecongestionModule(scenario)); - + // toll-adjusted routing - + controler.addOverridingModule(new AbstractModule(){ @Override public void install() { final TollTimeDistanceTravelDisutilityFactory travelDisutilityFactory = new TollTimeDistanceTravelDisutilityFactory(); this.bindCarTravelDisutilityFactory().toInstance( travelDisutilityFactory ); } - }); - + }); + // ############################################################# - - controler.getConfig().controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.failIfDirectoryExists); + + controler.getConfig().controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.failIfDirectoryExists); controler.run(); - + } } diff --git a/contribs/decongestion/src/main/java/org/matsim/contrib/decongestion/DecongestionRunExampleFromConfig.java b/contribs/decongestion/src/main/java/org/matsim/contrib/decongestion/DecongestionRunExampleFromConfig.java index 3dd8a48c2a1..339c6fff079 100644 --- a/contribs/decongestion/src/main/java/org/matsim/contrib/decongestion/DecongestionRunExampleFromConfig.java +++ b/contribs/decongestion/src/main/java/org/matsim/contrib/decongestion/DecongestionRunExampleFromConfig.java @@ -19,7 +19,7 @@ * *********************************************************************** */ /** - * + * */ package org.matsim.contrib.decongestion; @@ -39,7 +39,7 @@ /** * Starts an interval-based decongestion pricing simulation run. - * + * * @author ikaddoura * */ @@ -48,37 +48,37 @@ public class DecongestionRunExampleFromConfig { private static final Logger log = LogManager.getLogger(DecongestionRunExampleFromConfig.class); private static String configFile; - - public static void main(String[] args) throws IOException { + + public static void main(String[] args) throws IOException { if (args.length > 0) { log.info("Starting simulation run with the following arguments:"); - configFile = args[0]; + configFile = args[0]; log.info("config file: "+ configFile); } else { configFile = "path/to/config.xml"; } - + DecongestionRunExampleFromConfig main = new DecongestionRunExampleFromConfig(); main.run(); } private void run() throws IOException { - + Config config = ConfigUtils.loadConfig(configFile, new DecongestionConfigGroup()); - + final Scenario scenario = ScenarioUtils.loadScenario(config); Controler controler = new Controler(scenario); - + // ############################################################# - + // congestion toll computation - + controler.addOverridingModule(new DecongestionModule(scenario)); - + // toll-adjusted routing - + final TollTimeDistanceTravelDisutilityFactory travelDisutilityFactory = new TollTimeDistanceTravelDisutilityFactory(); controler.addOverridingModule(new AbstractModule(){ @@ -86,11 +86,11 @@ private void run() throws IOException { public void install() { this.bindCarTravelDisutilityFactory().toInstance( travelDisutilityFactory ); } - }); - + }); + // ############################################################# - - controler.getConfig().controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.failIfDirectoryExists); + + controler.getConfig().controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.failIfDirectoryExists); controler.run(); } } diff --git a/contribs/decongestion/src/main/java/org/matsim/contrib/decongestion/routing/TollTimeDistanceTravelDisutility.java b/contribs/decongestion/src/main/java/org/matsim/contrib/decongestion/routing/TollTimeDistanceTravelDisutility.java index 5635fdbae0a..f4036b3e1a0 100644 --- a/contribs/decongestion/src/main/java/org/matsim/contrib/decongestion/routing/TollTimeDistanceTravelDisutility.java +++ b/contribs/decongestion/src/main/java/org/matsim/contrib/decongestion/routing/TollTimeDistanceTravelDisutility.java @@ -35,7 +35,7 @@ import org.matsim.contrib.decongestion.data.LinkInfo; /** - * A cost calculator which respects time, distance and decongestion tolls. + * A cost calculator which respects time, distance and decongestion tolls. * * @author ikaddoura */ @@ -50,15 +50,15 @@ public final class TollTimeDistanceTravelDisutility implements TravelDisutility TollTimeDistanceTravelDisutility( final TravelTime timeCalculator, Config config, DecongestionInfo info ) { this.info = info; - this.marginalUtilityOfMoney = config.planCalcScore().getMarginalUtilityOfMoney(); + this.marginalUtilityOfMoney = config.scoring().getMarginalUtilityOfMoney(); final RandomizingTimeDistanceTravelDisutilityFactory builder = new RandomizingTimeDistanceTravelDisutilityFactory( TransportMode.car, config ); this.delegate = builder.createTravelDisutility(timeCalculator); this.timeBinSize = info.getScenario().getConfig().travelTimeCalculator().getTraveltimeBinSize(); - this.sigma = config.plansCalcRoute().getRoutingRandomness(); - + this.sigma = config.routing().getRoutingRandomness(); + log.info("Using the toll-adjusted travel disutility (improved version) in the decongestion package."); } @@ -67,7 +67,7 @@ public double getLinkTravelDisutility(final Link link, final double time, final int timeBin = (int) (time / timeBinSize); double timeDistanceTravelDisutilityFromDelegate = this.delegate.getLinkTravelDisutility(link, time, person, vehicle); - + double logNormalRnd = 1. ; if ( sigma != 0. ) { logNormalRnd = (double) person.getCustomAttributes().get("logNormalRnd") ; @@ -75,17 +75,17 @@ public double getLinkTravelDisutility(final Link link, final double time, final // adjust the travel disutility for the toll double toll = 0.; - + LinkInfo linkInfo = info.getlinkInfos().get(link.getId()); if (linkInfo != null) { - - Double linkInfoTimeBinToll = linkInfo.getTime2toll().get(timeBin); + + Double linkInfoTimeBinToll = linkInfo.getTime2toll().get(timeBin); if (linkInfoTimeBinToll != null) { toll = linkInfoTimeBinToll; } } - - double tollAdjustedLinkTravelDisutility = timeDistanceTravelDisutilityFromDelegate + logNormalRnd * marginalUtilityOfMoney * toll; + + double tollAdjustedLinkTravelDisutility = timeDistanceTravelDisutilityFromDelegate + logNormalRnd * marginalUtilityOfMoney * toll; return tollAdjustedLinkTravelDisutility; } diff --git a/contribs/decongestion/src/main/java/org/matsim/contrib/decongestion/tollSetting/DecongestionTollingP_MCP.java b/contribs/decongestion/src/main/java/org/matsim/contrib/decongestion/tollSetting/DecongestionTollingP_MCP.java index 146bf63f012..00450067e9c 100644 --- a/contribs/decongestion/src/main/java/org/matsim/contrib/decongestion/tollSetting/DecongestionTollingP_MCP.java +++ b/contribs/decongestion/src/main/java/org/matsim/contrib/decongestion/tollSetting/DecongestionTollingP_MCP.java @@ -36,64 +36,64 @@ import org.matsim.contrib.decongestion.data.LinkInfo; /** - * + * * P-based toll adjustment, where e(t) = average delay and K_p = VTTS * number of delayed agents - * + * * @author ikaddoura */ public class DecongestionTollingP_MCP implements DecongestionTollSetting, LinkLeaveEventHandler { private static final Logger log = LogManager.getLogger(DecongestionTollingP_MCP.class); - + @Inject private DecongestionInfo congestionInfo; - - private Map, LinkInfo> linkId2infoPreviousTollComputation = new HashMap<>(); + + private Map, LinkInfo> linkId2infoPreviousTollComputation = new HashMap<>(); private int tollUpdateCounter = 0; private final Map, Map> linkId2time2leavingAgents = new HashMap<>(); @Override public void updateTolls() { - - final double vtts = ( this.congestionInfo.getScenario().getConfig().planCalcScore().getPerforming_utils_hr() - - this.congestionInfo.getScenario().getConfig().planCalcScore().getModes().get(TransportMode.car).getMarginalUtilityOfTraveling() ) - / this.congestionInfo.getScenario().getConfig().planCalcScore().getMarginalUtilityOfMoney(); - + final double vtts = ( this.congestionInfo.getScenario().getConfig().scoring().getPerforming_utils_hr() + - this.congestionInfo.getScenario().getConfig().scoring().getModes().get(TransportMode.car).getMarginalUtilityOfTraveling() ) + / this.congestionInfo.getScenario().getConfig().scoring().getMarginalUtilityOfMoney(); + + final double toleratedAvgDelay = this.congestionInfo.getDecongestionConfigGroup().getToleratedAverageDelaySec(); final boolean msa = this.congestionInfo.getDecongestionConfigGroup().isMsa(); final double blendFactorFromConfig = this.congestionInfo.getDecongestionConfigGroup().getTollBlendFactor(); - + for (Id linkId : this.congestionInfo.getlinkInfos().keySet()) { - + LinkInfo linkInfo = this.congestionInfo.getlinkInfos().get(linkId); for (Integer intervalNr : linkInfo.getTime2avgDelay().keySet()) { - + // average delay - - double averageDelay = linkInfo.getTime2avgDelay().get(intervalNr); + + double averageDelay = linkInfo.getTime2avgDelay().get(intervalNr); if (averageDelay <= toleratedAvgDelay) { averageDelay = 0.0; } - + // toll - + double demand = 1.0; if (this.linkId2time2leavingAgents.get(linkId) != null && this.linkId2time2leavingAgents.get(linkId).get(intervalNr) != null) { demand = this.linkId2time2leavingAgents.get(linkId).get(intervalNr); } - + double toll = vtts * demand * averageDelay / 3600.; // prevent negative tolls - + if (toll < 0) { log.warn("Negative tolls... Are you sure everything works fine?"); toll = 0; } - + // smoothen the tolls - + Double previousToll = linkInfo.getTime2toll().get(intervalNr); double blendFactor; @@ -106,35 +106,35 @@ public void updateTolls() { } else { blendFactor = blendFactorFromConfig; } - + double smoothedToll; if (previousToll != null && previousToll >= 0.) { smoothedToll = toll * blendFactor + previousToll * (1 - blendFactor); } else { smoothedToll = toll; } - + // store the updated toll - + linkInfo.getTime2toll().put(intervalNr, smoothedToll); - } + } } - + log.info("Updating tolls completed."); this.tollUpdateCounter++; - + // store the current link information for the next toll computation - + linkId2infoPreviousTollComputation = new HashMap<>(); for ( Map.Entry< Id,LinkInfo> entry : this.congestionInfo.getlinkInfos().entrySet() ) { LinkInfo linkInfo = entry.getValue() ; - + Map time2previousDelay = new HashMap<>(); for (Integer intervalNr : linkInfo.getTime2avgDelay().keySet()) { time2previousDelay.put(intervalNr, linkInfo.getTime2avgDelay().get(intervalNr)); } - + LinkInfo linkInfoPreviousTollComputation = new LinkInfo(linkInfo.getLink()); linkInfoPreviousTollComputation.setTime2avgDelay(time2previousDelay); linkId2infoPreviousTollComputation.put(linkInfo.getLink().getId(), linkInfoPreviousTollComputation); @@ -151,27 +151,27 @@ public void handleEvent(LinkLeaveEvent event) { int timeBinNr = getIntervalNr(event.getTime()); Id linkId = event.getLinkId(); - + if (linkId2time2leavingAgents.get(linkId) != null) { - + if (linkId2time2leavingAgents.get(linkId).get(timeBinNr) != null) { int leavingAgents = linkId2time2leavingAgents.get(linkId).get(timeBinNr) + 1; linkId2time2leavingAgents.get(linkId).put(timeBinNr, leavingAgents); - + } else { linkId2time2leavingAgents.get(linkId).put(timeBinNr, 1); } - + } else { Map time2leavingAgents = new HashMap<>(); time2leavingAgents.put(timeBinNr, 1); linkId2time2leavingAgents.put(linkId, time2leavingAgents); - + } } - + private int getIntervalNr(double time) { - double timeBinSize = congestionInfo.getScenario().getConfig().travelTimeCalculator().getTraveltimeBinSize(); + double timeBinSize = congestionInfo.getScenario().getConfig().travelTimeCalculator().getTraveltimeBinSize(); return (int) (time / timeBinSize); } diff --git a/contribs/decongestion/src/test/java/org/matsim/contrib/decongestion/DecongestionPricingTestIT.java b/contribs/decongestion/src/test/java/org/matsim/contrib/decongestion/DecongestionPricingTestIT.java index ac6697e3694..81f84e13492 100644 --- a/contribs/decongestion/src/test/java/org/matsim/contrib/decongestion/DecongestionPricingTestIT.java +++ b/contribs/decongestion/src/test/java/org/matsim/contrib/decongestion/DecongestionPricingTestIT.java @@ -18,7 +18,7 @@ * *********************************************************************** */ /** - * + * */ package org.matsim.contrib.decongestion; @@ -47,32 +47,32 @@ import org.matsim.testcases.MatsimTestUtils; /** - * - * + * + * * @author ikaddoura * */ public class DecongestionPricingTestIT { - + @Rule public MatsimTestUtils testUtils = new MatsimTestUtils(); /** * Kp = 0.0123 - * + * */ @Test public final void test0a() { - + System.out.println(testUtils.getPackageInputDirectory()); - + final String configFile = testUtils.getPackageInputDirectory() + "/config0.xml"; - + Config config = ConfigUtils.loadConfig(configFile); String outputDirectory = testUtils.getOutputDirectory() + "/"; - config.controler().setOutputDirectory(outputDirectory); - + config.controller().setOutputDirectory(outputDirectory); + final DecongestionConfigGroup decongestionSettings = new DecongestionConfigGroup(); decongestionSettings.setWriteOutputIteration(1); decongestionSettings.setKp(0.0123); @@ -83,37 +83,37 @@ public final void test0a() { decongestionSettings.setFractionOfIterationsToEndPriceAdjustment(1.0); decongestionSettings.setFractionOfIterationsToStartPriceAdjustment(0.0); config.addModule(decongestionSettings); - + final Scenario scenario = ScenarioUtils.loadScenario(config); Controler controler = new Controler(scenario); - + DecongestionInfo info = new DecongestionInfo(); - + // congestion toll computation controler.addOverridingModule(new AbstractModule() { @Override public void install() { - + this.bind(DecongestionInfo.class).toInstance(info); - + this.bind(DecongestionTollSetting.class).to(DecongestionTollingPID.class); this.bind(IntervalBasedTolling.class).to(IntervalBasedTollingAll.class); - + this.bind(IntervalBasedTollingAll.class).asEagerSingleton(); this.bind(DelayAnalysis.class).asEagerSingleton(); this.bind(PersonVehicleTracker.class).asEagerSingleton(); - + this.addEventHandlerBinding().to(IntervalBasedTollingAll.class); this.addEventHandlerBinding().to(DelayAnalysis.class); this.addEventHandlerBinding().to(PersonVehicleTracker.class); - + this.addControlerListenerBinding().to(DecongestionControlerListener.class); } }); - + // toll-adjusted routing - + final TollTimeDistanceTravelDisutilityFactory travelDisutilityFactory = new TollTimeDistanceTravelDisutilityFactory(); controler.addOverridingModule(new AbstractModule(){ @@ -121,23 +121,23 @@ public void install() { public void install() { this.bindCarTravelDisutilityFactory().toInstance( travelDisutilityFactory ); } - }); - - controler.getConfig().controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists); - controler.run(); - + }); + + controler.getConfig().controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists); + controler.run(); + double tt0 = controler.getLinkTravelTimes().getLinkTravelTime(scenario.getNetwork().getLinks().get(Id.createLinkId("link12")), 6 * 3600 + 50. * 60, null, null); double tt1 = controler.getLinkTravelTimes().getLinkTravelTime(scenario.getNetwork().getLinks().get(Id.createLinkId("link12")), 7 * 3600 + 63, null, null); double tt2 = controler.getLinkTravelTimes().getLinkTravelTime(scenario.getNetwork().getLinks().get(Id.createLinkId("link12")), 7 * 3600 + 15. * 60, null, null); - + Assert.assertEquals("Wrong travel time. The run output seems to have changed.", 100.0, tt0, MatsimTestUtils.EPSILON); Assert.assertEquals("Wrong travel time. The run output seems to have changed.", 150.5, tt1, MatsimTestUtils.EPSILON); Assert.assertEquals("Wrong travel time. The run output seems to have changed.", 100.0, tt2, MatsimTestUtils.EPSILON); - - final int index = config.controler().getLastIteration() - config.controler().getFirstIteration(); + + final int index = config.controller().getLastIteration() - config.controller().getFirstIteration(); double avgScore = controler.getScoreStats().getScoreHistory().get( ScoreItem.executed ).get(index); Assert.assertEquals("Wrong average executed score. The tolls seem to have changed.", -33.940316666666666, avgScore, MatsimTestUtils.EPSILON); - + System.out.println(info.getlinkInfos().get(Id.createLinkId("link12")).getTime2toll().toString()); System.out.println(info.getlinkInfos().get(Id.createLinkId("link12")).getTime2avgDelay().toString()); @@ -145,23 +145,23 @@ public void install() { Assert.assertEquals("Wrong toll.", 50.5 * 0.0123, info.getlinkInfos().get(Id.createLinkId("link12")).getTime2toll().get(84), MatsimTestUtils.EPSILON); } - + /** * Kp = 0.0123, other syntax - * + * */ @Test public final void test0amodified() { - + System.out.println(testUtils.getPackageInputDirectory()); - + final String configFile = testUtils.getPackageInputDirectory() + "/config0.xml"; - + Config config = ConfigUtils.loadConfig(configFile); String outputDirectory = testUtils.getOutputDirectory() + "/"; - config.controler().setOutputDirectory(outputDirectory); - + config.controller().setOutputDirectory(outputDirectory); + final DecongestionConfigGroup decongestionSettings = new DecongestionConfigGroup(); decongestionSettings.setWriteOutputIteration(1); decongestionSettings.setKp(0.0123); @@ -172,15 +172,15 @@ public final void test0amodified() { decongestionSettings.setFractionOfIterationsToEndPriceAdjustment(1.0); decongestionSettings.setFractionOfIterationsToStartPriceAdjustment(0.0); config.addModule(decongestionSettings); - + final Scenario scenario = ScenarioUtils.loadScenario(config); Controler controler = new Controler(scenario); - + // congestion toll computation controler.addOverridingModule(new DecongestionModule(scenario)); - + // toll-adjusted routing - + final TollTimeDistanceTravelDisutilityFactory travelDisutilityFactory = new TollTimeDistanceTravelDisutilityFactory(); controler.addOverridingModule(new AbstractModule(){ @@ -188,40 +188,40 @@ public final void test0amodified() { public void install() { this.bindCarTravelDisutilityFactory().toInstance( travelDisutilityFactory ); } - }); - - controler.getConfig().controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists); - controler.run(); - + }); + + controler.getConfig().controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists); + controler.run(); + double tt0 = controler.getLinkTravelTimes().getLinkTravelTime(scenario.getNetwork().getLinks().get(Id.createLinkId("link12")), 6 * 3600 + 50. * 60, null, null); double tt1 = controler.getLinkTravelTimes().getLinkTravelTime(scenario.getNetwork().getLinks().get(Id.createLinkId("link12")), 7 * 3600 + 63, null, null); double tt2 = controler.getLinkTravelTimes().getLinkTravelTime(scenario.getNetwork().getLinks().get(Id.createLinkId("link12")), 7 * 3600 + 15. * 60, null, null); - + Assert.assertEquals("Wrong travel time. The run output seems to have changed.", 100.0, tt0, MatsimTestUtils.EPSILON); Assert.assertEquals("Wrong travel time. The run output seems to have changed.", 150.5, tt1, MatsimTestUtils.EPSILON); Assert.assertEquals("Wrong travel time. The run output seems to have changed.", 100.0, tt2, MatsimTestUtils.EPSILON); - - final int index = config.controler().getLastIteration() - config.controler().getFirstIteration(); + + final int index = config.controller().getLastIteration() - config.controller().getFirstIteration(); double avgScore = controler.getScoreStats().getScoreHistory().get( ScoreItem.executed ).get(index); Assert.assertEquals("Wrong average executed score. The tolls seem to have changed.", -33.940316666666666, avgScore, MatsimTestUtils.EPSILON); } - + /** * Kp = 2 - * + * */ @Test public final void test0b() { - + System.out.println(testUtils.getPackageInputDirectory()); - + final String configFile = testUtils.getPackageInputDirectory() + "/config0.xml"; - + Config config = ConfigUtils.loadConfig(configFile); String outputDirectory = testUtils.getOutputDirectory() + "/"; - config.controler().setOutputDirectory(outputDirectory); - + config.controller().setOutputDirectory(outputDirectory); + final DecongestionConfigGroup decongestionSettings = new DecongestionConfigGroup(); decongestionSettings.setWriteOutputIteration(1); decongestionSettings.setKp(2.0); @@ -232,37 +232,37 @@ public final void test0b() { decongestionSettings.setFractionOfIterationsToEndPriceAdjustment(1.0); decongestionSettings.setFractionOfIterationsToStartPriceAdjustment(0.0); config.addModule(decongestionSettings); - - final Scenario scenario = ScenarioUtils.loadScenario(config); + + final Scenario scenario = ScenarioUtils.loadScenario(config); Controler controler = new Controler(scenario); DecongestionInfo info = new DecongestionInfo(); - + // congestion toll computation controler.addOverridingModule(new AbstractModule() { @Override public void install() { - + this.bind(DecongestionInfo.class).toInstance(info); - + this.bind(DecongestionTollSetting.class).to(DecongestionTollingPID.class); this.bind(IntervalBasedTolling.class).to(IntervalBasedTollingAll.class); - + this.bind(IntervalBasedTollingAll.class).asEagerSingleton(); this.bind(DelayAnalysis.class).asEagerSingleton(); this.bind(PersonVehicleTracker.class).asEagerSingleton(); - + this.addEventHandlerBinding().to(IntervalBasedTollingAll.class); this.addEventHandlerBinding().to(DelayAnalysis.class); this.addEventHandlerBinding().to(PersonVehicleTracker.class); - + this.addControlerListenerBinding().to(DecongestionControlerListener.class); } }); - + // toll-adjusted routing - + final TollTimeDistanceTravelDisutilityFactory travelDisutilityFactory = new TollTimeDistanceTravelDisutilityFactory(); controler.addOverridingModule(new AbstractModule(){ @@ -270,46 +270,46 @@ public void install() { public void install() { this.bindCarTravelDisutilityFactory().toInstance( travelDisutilityFactory ); } - }); - - controler.getConfig().controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists); - controler.run(); - + }); + + controler.getConfig().controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists); + controler.run(); + double tt0 = controler.getLinkTravelTimes().getLinkTravelTime(scenario.getNetwork().getLinks().get(Id.createLinkId("link12")), 6 * 3600 + 50. * 60, null, null); double tt1 = controler.getLinkTravelTimes().getLinkTravelTime(scenario.getNetwork().getLinks().get(Id.createLinkId("link12")), 7 * 3600 + 63, null, null); double tt2 = controler.getLinkTravelTimes().getLinkTravelTime(scenario.getNetwork().getLinks().get(Id.createLinkId("link12")), 7 * 3600 + 15. * 60, null, null); - + Assert.assertEquals("Wrong travel time. The run output seems to have changed.", 100.0, tt0, MatsimTestUtils.EPSILON); Assert.assertEquals("Wrong travel time. The run output seems to have changed.", 150.5, tt1, MatsimTestUtils.EPSILON); Assert.assertEquals("Wrong travel time. The run output seems to have changed.", 100.0, tt2, MatsimTestUtils.EPSILON); - - final int index = config.controler().getLastIteration() - config.controler().getFirstIteration(); + + final int index = config.controller().getLastIteration() - config.controller().getFirstIteration(); double avgScore = controler.getScoreStats().getScoreHistory().get( ScoreItem.executed ).get(index); Assert.assertEquals("Wrong average executed score. The tolls seem to have changed.", -134.31916666666666, avgScore, MatsimTestUtils.EPSILON); - + System.out.println(info.getlinkInfos().get(Id.createLinkId("link12")).getTime2toll().toString()); System.out.println(info.getlinkInfos().get(Id.createLinkId("link12")).getTime2avgDelay().toString()); Assert.assertEquals("Wrong average delay (capacity is set in a way that one of the two agents has to wait 101 sec. Thus the average is 50.5", 50.5, info.getlinkInfos().get(Id.createLinkId("link12")).getTime2avgDelay().get(84), MatsimTestUtils.EPSILON); Assert.assertEquals("Wrong toll.", 50.5 * 2, info.getlinkInfos().get(Id.createLinkId("link12")).getTime2toll().get(84), MatsimTestUtils.EPSILON); } - + /** * Kp = 2 - * + * */ @Test public final void test0bmodified() { - + System.out.println(testUtils.getPackageInputDirectory()); - + final String configFile = testUtils.getPackageInputDirectory() + "/config0.xml"; - + Config config = ConfigUtils.loadConfig(configFile); String outputDirectory = testUtils.getOutputDirectory() + "/"; - config.controler().setOutputDirectory(outputDirectory); - + config.controller().setOutputDirectory(outputDirectory); + final DecongestionConfigGroup decongestionSettings = new DecongestionConfigGroup(); decongestionSettings.setWriteOutputIteration(1); decongestionSettings.setKp(2.0); @@ -320,15 +320,15 @@ public final void test0bmodified() { decongestionSettings.setFractionOfIterationsToEndPriceAdjustment(1.0); decongestionSettings.setFractionOfIterationsToStartPriceAdjustment(0.0); config.addModule(decongestionSettings); - - final Scenario scenario = ScenarioUtils.loadScenario(config); + + final Scenario scenario = ScenarioUtils.loadScenario(config); Controler controler = new Controler(scenario); - + // congestion toll computation controler.addOverridingModule(new DecongestionModule(scenario)); - + // toll-adjusted routing - + final TollTimeDistanceTravelDisutilityFactory travelDisutilityFactory = new TollTimeDistanceTravelDisutilityFactory(); controler.addOverridingModule(new AbstractModule(){ @@ -336,39 +336,39 @@ public final void test0bmodified() { public void install() { this.bindCarTravelDisutilityFactory().toInstance( travelDisutilityFactory ); } - }); - - controler.getConfig().controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists); - controler.run(); - + }); + + controler.getConfig().controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists); + controler.run(); + double tt0 = controler.getLinkTravelTimes().getLinkTravelTime(scenario.getNetwork().getLinks().get(Id.createLinkId("link12")), 6 * 3600 + 50. * 60, null, null); double tt1 = controler.getLinkTravelTimes().getLinkTravelTime(scenario.getNetwork().getLinks().get(Id.createLinkId("link12")), 7 * 3600 + 63, null, null); double tt2 = controler.getLinkTravelTimes().getLinkTravelTime(scenario.getNetwork().getLinks().get(Id.createLinkId("link12")), 7 * 3600 + 15. * 60, null, null); - + Assert.assertEquals("Wrong travel time. The run output seems to have changed.", 100.0, tt0, MatsimTestUtils.EPSILON); Assert.assertEquals("Wrong travel time. The run output seems to have changed.", 150.5, tt1, MatsimTestUtils.EPSILON); Assert.assertEquals("Wrong travel time. The run output seems to have changed.", 100.0, tt2, MatsimTestUtils.EPSILON); - - final int index = config.controler().getLastIteration() - config.controler().getFirstIteration(); + + final int index = config.controller().getLastIteration() - config.controller().getFirstIteration(); double avgScore = controler.getScoreStats().getScoreHistory().get( ScoreItem.executed ).get(index); Assert.assertEquals("Wrong average executed score. The tolls seem to have changed.", -134.31916666666666, avgScore, MatsimTestUtils.EPSILON); } - + /** * Kp = 0 / no tolling - * + * */ @Test public final void test0c() { - + System.out.println(testUtils.getPackageInputDirectory()); - + final String configFile = testUtils.getPackageInputDirectory() + "/config0.xml"; - + Config config = ConfigUtils.loadConfig(configFile); String outputDirectory = testUtils.getOutputDirectory() + "/"; - config.controler().setOutputDirectory(outputDirectory); + config.controller().setOutputDirectory(outputDirectory); final DecongestionConfigGroup decongestionSettings = new DecongestionConfigGroup(); decongestionSettings.setWriteOutputIteration(1); @@ -383,26 +383,26 @@ public final void test0c() { final Scenario scenario = ScenarioUtils.loadScenario(config); Controler controler = new Controler(scenario); - + DecongestionInfo info = new DecongestionInfo(); - + // congestion toll computation controler.addOverridingModule(new AbstractModule() { @Override public void install() { - + this.bind(DecongestionInfo.class).toInstance(info); - + this.bind(DelayAnalysis.class).asEagerSingleton(); this.addEventHandlerBinding().to(DelayAnalysis.class); - + this.addControlerListenerBinding().to(DecongestionControlerListener.class); } }); - + // toll-adjusted routing - + final TollTimeDistanceTravelDisutilityFactory travelDisutilityFactory = new TollTimeDistanceTravelDisutilityFactory(); controler.addOverridingModule(new AbstractModule(){ @@ -410,23 +410,23 @@ public void install() { public void install() { this.bindCarTravelDisutilityFactory().toInstance( travelDisutilityFactory ); } - }); - - controler.getConfig().controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists); - controler.run(); - + }); + + controler.getConfig().controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists); + controler.run(); + double tt0 = controler.getLinkTravelTimes().getLinkTravelTime(scenario.getNetwork().getLinks().get(Id.createLinkId("link12")), 6 * 3600 + 50. * 60, null, null); double tt1 = controler.getLinkTravelTimes().getLinkTravelTime(scenario.getNetwork().getLinks().get(Id.createLinkId("link12")), 7 * 3600 + 63, null, null); double tt2 = controler.getLinkTravelTimes().getLinkTravelTime(scenario.getNetwork().getLinks().get(Id.createLinkId("link12")), 7 * 3600 + 15. * 60, null, null); - + Assert.assertEquals("Wrong travel time. The run output seems to have changed.", 100.0, tt0, MatsimTestUtils.EPSILON); Assert.assertEquals("Wrong travel time. The run output seems to have changed.", 150.5, tt1, MatsimTestUtils.EPSILON); Assert.assertEquals("Wrong travel time. The run output seems to have changed.", 100.0, tt2, MatsimTestUtils.EPSILON); - - final int index = config.controler().getLastIteration() - config.controler().getFirstIteration(); + + final int index = config.controller().getLastIteration() - config.controller().getFirstIteration(); double avgScore = controler.getScoreStats().getScoreHistory().get( ScoreItem.executed ).get(index); Assert.assertEquals("Wrong average executed score. The tolls seem to have changed.", -33.31916666666666, avgScore, MatsimTestUtils.EPSILON); - + System.out.println(info.getlinkInfos().get(Id.createLinkId("link12")).getTime2toll().toString()); System.out.println(info.getlinkInfos().get(Id.createLinkId("link12")).getTime2avgDelay().toString()); @@ -434,22 +434,22 @@ public void install() { Assert.assertEquals("Wrong toll.", null, info.getlinkInfos().get(Id.createLinkId("link12")).getTime2toll().get(84)); } - + /** * Tests the PID controller - * + * */ @Test public final void test1() { - + System.out.println(testUtils.getPackageInputDirectory()); - + final String configFile = testUtils.getPackageInputDirectory() + "/config.xml"; Config config = ConfigUtils.loadConfig(configFile); String outputDirectory = testUtils.getOutputDirectory() + "/"; - config.controler().setOutputDirectory(outputDirectory); - + config.controller().setOutputDirectory(outputDirectory); + final DecongestionConfigGroup decongestionSettings = new DecongestionConfigGroup(); decongestionSettings.setWriteOutputIteration(1); decongestionSettings.setFractionOfIterationsToEndPriceAdjustment(1.0); @@ -459,57 +459,57 @@ public final void test1() { final Scenario scenario = ScenarioUtils.loadScenario(config); Controler controler = new Controler(scenario); - + DecongestionInfo info = new DecongestionInfo(); - + // decongestion pricing controler.addOverridingModule(new AbstractModule() { @Override public void install() { - + this.bind(DecongestionInfo.class).toInstance(info); - + this.bind(DecongestionTollSetting.class).to(DecongestionTollingPID.class); this.bind(IntervalBasedTolling.class).to(IntervalBasedTollingAll.class); - + this.bind(IntervalBasedTollingAll.class).asEagerSingleton(); this.bind(DelayAnalysis.class).asEagerSingleton(); this.bind(PersonVehicleTracker.class).asEagerSingleton(); - + this.addEventHandlerBinding().to(IntervalBasedTollingAll.class); this.addEventHandlerBinding().to(DelayAnalysis.class); this.addEventHandlerBinding().to(PersonVehicleTracker.class); - + this.addControlerListenerBinding().to(DecongestionControlerListener.class); } }); - - controler.getConfig().controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists); + + controler.getConfig().controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists); controler.run(); - final int index = config.controler().getLastIteration() - config.controler().getFirstIteration(); + final int index = config.controller().getLastIteration() - config.controller().getFirstIteration(); double avgScore = controler.getScoreStats().getScoreHistory().get( ScoreItem.executed ).get(index) ; Assert.assertEquals("Wrong average executed score. The run output seems to have changed.", -11749.431349675931, avgScore, MatsimTestUtils.EPSILON); - + System.out.println(info.getlinkInfos().get(Id.createLinkId("link12")).getTime2toll().toString()); Assert.assertEquals("Wrong toll in time bin 61.", 12.600000000000009, info.getlinkInfos().get(Id.createLinkId("link12")).getTime2toll().get(61), MatsimTestUtils.EPSILON); Assert.assertEquals("Wrong toll in time bin 73.", 16.665000000000006, info.getlinkInfos().get(Id.createLinkId("link12")).getTime2toll().get(73), MatsimTestUtils.EPSILON); } - + /** * Tests the BangBang controller - * + * */ @Test public final void test2() { - + System.out.println(testUtils.getPackageInputDirectory()); - + final String configFile = testUtils.getPackageInputDirectory() + "/config.xml"; Config config = ConfigUtils.loadConfig(configFile); String outputDirectory = testUtils.getOutputDirectory() + "/"; - config.controler().setOutputDirectory(outputDirectory); + config.controller().setOutputDirectory(outputDirectory); final DecongestionConfigGroup decongestionSettings = new DecongestionConfigGroup(); decongestionSettings.setWriteOutputIteration(1); @@ -518,7 +518,7 @@ public final void test2() { config.addModule(decongestionSettings); DecongestionInfo info = new DecongestionInfo(); - + final Scenario scenario = ScenarioUtils.loadScenario(config); Controler controler = new Controler(scenario); @@ -526,35 +526,35 @@ public final void test2() { controler.addOverridingModule(new AbstractModule() { @Override public void install() { - + this.bind(DecongestionInfo.class).toInstance(info); - + this.bind(DecongestionTollSetting.class).to(DecongestionTollingBangBang.class); this.bind(IntervalBasedTolling.class).to(IntervalBasedTollingAll.class); - this.bind(IntervalBasedTollingAll.class).asEagerSingleton(); + this.bind(IntervalBasedTollingAll.class).asEagerSingleton(); this.bind(DelayAnalysis.class).asEagerSingleton(); this.bind(PersonVehicleTracker.class).asEagerSingleton(); - + this.addEventHandlerBinding().to(IntervalBasedTollingAll.class); this.addEventHandlerBinding().to(DelayAnalysis.class); this.addEventHandlerBinding().to(PersonVehicleTracker.class); - + this.addControlerListenerBinding().to(DecongestionControlerListener.class); } }); - - controler.getConfig().controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists); + + controler.getConfig().controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists); controler.run(); - - final int index = config.controler().getLastIteration() - config.controler().getFirstIteration(); + + final int index = config.controller().getLastIteration() - config.controller().getFirstIteration(); double avgScore = controler.getScoreStats().getScoreHistory().get( ScoreItem.executed ).get( index ) ; Assert.assertEquals("Wrong average executed score. The run output seems to have changed.", -54.97929444444, avgScore, MatsimTestUtils.EPSILON); - + System.out.println(info.getlinkInfos().get(Id.createLinkId("link12")).getTime2toll().toString()); - Assert.assertEquals("Wrong toll in time bin 61.", 13., info.getlinkInfos().get(Id.createLinkId("link12")).getTime2toll().get(61), MatsimTestUtils.EPSILON); - Assert.assertEquals("Wrong toll in time bin 73.", 13., info.getlinkInfos().get(Id.createLinkId("link12")).getTime2toll().get(73), MatsimTestUtils.EPSILON); + Assert.assertEquals("Wrong toll in time bin 61.", 13., info.getlinkInfos().get(Id.createLinkId("link12")).getTime2toll().get(61), MatsimTestUtils.EPSILON); + Assert.assertEquals("Wrong toll in time bin 73.", 13., info.getlinkInfos().get(Id.createLinkId("link12")).getTime2toll().get(73), MatsimTestUtils.EPSILON); } - + } diff --git a/contribs/discrete_mode_choice/src/main/java/org/matsim/contribs/discrete_mode_choice/modules/DiscreteModeChoiceConfigurator.java b/contribs/discrete_mode_choice/src/main/java/org/matsim/contribs/discrete_mode_choice/modules/DiscreteModeChoiceConfigurator.java index 94fe60a570a..4cf1f8704cb 100644 --- a/contribs/discrete_mode_choice/src/main/java/org/matsim/contribs/discrete_mode_choice/modules/DiscreteModeChoiceConfigurator.java +++ b/contribs/discrete_mode_choice/src/main/java/org/matsim/contribs/discrete_mode_choice/modules/DiscreteModeChoiceConfigurator.java @@ -28,7 +28,7 @@ private DiscreteModeChoiceConfigurator() { } static public void configureAsSubtourModeChoiceReplacement(Config config) { - for (StrategySettings strategy : config.strategy().getStrategySettings()) { + for (StrategySettings strategy : config.replanning().getStrategySettings()) { if (strategy.getStrategyName().equals(DefaultStrategy.SubtourModeChoice)) { strategy.setStrategyName(DiscreteModeChoiceModule.STRATEGY_NAME); } @@ -89,7 +89,7 @@ static public void configureAsModeChoiceInTheLoop(Config config) { } static public void configureAsModeChoiceInTheLoop(Config config, double replanningRate) { - ReplanningConfigGroup replanningConfigGroup = config.strategy(); + ReplanningConfigGroup replanningConfigGroup = config.replanning(); replanningConfigGroup.clearStrategySettings(); replanningConfigGroup.setMaxAgentPlanMemorySize(1); diff --git a/contribs/discrete_mode_choice/src/main/java/org/matsim/contribs/discrete_mode_choice/modules/DiscreteModeChoiceModule.java b/contribs/discrete_mode_choice/src/main/java/org/matsim/contribs/discrete_mode_choice/modules/DiscreteModeChoiceModule.java index 58db9c55b85..abf34cb42f6 100644 --- a/contribs/discrete_mode_choice/src/main/java/org/matsim/contribs/discrete_mode_choice/modules/DiscreteModeChoiceModule.java +++ b/contribs/discrete_mode_choice/src/main/java/org/matsim/contribs/discrete_mode_choice/modules/DiscreteModeChoiceModule.java @@ -11,7 +11,7 @@ /** * Main module of the Discrete Mode Choice extension. Should be added as an * overriding module before the MATSim controller is started. - * + * * @author sebhoerl */ public class DiscreteModeChoiceModule extends AbstractModule { @@ -24,7 +24,7 @@ public class DiscreteModeChoiceModule extends AbstractModule { public void install() { addPlanStrategyBinding(STRATEGY_NAME).toProvider(DiscreteModeChoiceStrategyProvider.class); - if (getConfig().strategy().getPlanSelectorForRemoval().equals(NonSelectedPlanSelector.NAME)) { + if (getConfig().replanning().getPlanSelectorForRemoval().equals(NonSelectedPlanSelector.NAME)) { bindPlanSelectorForRemoval().to(NonSelectedPlanSelector.class); } diff --git a/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/examples/TestSiouxFalls.java b/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/examples/TestSiouxFalls.java index 9d931e70283..89e444ca0c4 100644 --- a/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/examples/TestSiouxFalls.java +++ b/contribs/discrete_mode_choice/src/test/java/org/matsim/contrib/discrete_mode_choice/examples/TestSiouxFalls.java @@ -31,13 +31,13 @@ public void testSiouxFallsWithSubtourModeChoiceReplacement() { config.transit().setRoutingAlgorithmType(TransitRoutingAlgorithmType.DijkstraBased); DiscreteModeChoiceConfigurator.configureAsSubtourModeChoiceReplacement(config); - config.controler().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); - config.controler().setLastIteration(1); + config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); + config.controller().setLastIteration(1); // save some bandwidth/time: - config.controler().setCreateGraphs( false ); - config.controler().setWritePlansInterval( 0 ); - config.controler().setWriteEventsInterval( 0 ); - config.controler().setDumpDataAtEnd( false ); + config.controller().setCreateGraphs( false ); + config.controller().setWritePlansInterval( 0 ); + config.controller().setWriteEventsInterval( 0 ); + config.controller().setDumpDataAtEnd( false ); config.qsim().setFlowCapFactor(10000.0); config.qsim().setStorageCapFactor(10000.0); diff --git a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/companions/DrtCompanionControlerCreator.java b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/companions/DrtCompanionControlerCreator.java index 9d14d6a5b37..058588cf40e 100644 --- a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/companions/DrtCompanionControlerCreator.java +++ b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/companions/DrtCompanionControlerCreator.java @@ -21,14 +21,12 @@ package org.matsim.contrib.drt.extension.companions; import org.matsim.api.core.v01.Scenario; -import org.matsim.contrib.drt.extension.companions.MultiModeDrtCompanionModule; import org.matsim.contrib.drt.run.DrtConfigs; import org.matsim.contrib.drt.run.DrtControlerCreator; import org.matsim.contrib.drt.run.MultiModeDrtConfigGroup; import org.matsim.contrib.drt.run.MultiModeDrtModule; import org.matsim.contrib.dvrp.run.DvrpModule; import org.matsim.contrib.dvrp.run.DvrpQSimComponents; -import org.matsim.contrib.otfvis.OTFVisLiveModule; import org.matsim.core.config.Config; import org.matsim.core.controler.Controler; import org.matsim.core.scenario.ScenarioUtils; @@ -42,7 +40,7 @@ public final class DrtCompanionControlerCreator { public static Controler createControler(Config config) { MultiModeDrtConfigGroup multiModeDrtConfig = MultiModeDrtConfigGroup.get(config); - DrtConfigs.adjustMultiModeDrtConfig(multiModeDrtConfig, config.planCalcScore(), config.plansCalcRoute()); + DrtConfigs.adjustMultiModeDrtConfig(multiModeDrtConfig, config.scoring(), config.routing()); Scenario scenario = DrtControlerCreator.createScenarioWithDrtRouteFactory(config); ScenarioUtils.loadScenario(scenario); diff --git a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/dashboards/DrtDashboardProvider.java b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/dashboards/DrtDashboardProvider.java index 9760f3ec617..93e186e2474 100644 --- a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/dashboards/DrtDashboardProvider.java +++ b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/dashboards/DrtDashboardProvider.java @@ -25,7 +25,7 @@ public List getDashboards(Config config, SimWrapper simWrapper) { for (DrtConfigGroup drtConfig : multiModeDrtConfigGroup.getModalElements()) { - result.add(new DrtDashboard(drtConfig, config.getContext(), config.global().getCoordinateSystem(), config.controler().getLastIteration())); + result.add(new DrtDashboard(drtConfig, config.getContext(), config.global().getCoordinateSystem(), config.controller().getLastIteration())); } } diff --git a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/edrt/run/EDrtControlerCreator.java b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/edrt/run/EDrtControlerCreator.java index 638180019a7..8471438ebe4 100644 --- a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/edrt/run/EDrtControlerCreator.java +++ b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/edrt/run/EDrtControlerCreator.java @@ -42,7 +42,7 @@ public class EDrtControlerCreator { public static Controler createControler(Config config, boolean otfvis) { MultiModeDrtConfigGroup multiModeDrtConfig = MultiModeDrtConfigGroup.get(config); - DrtConfigs.adjustMultiModeDrtConfig(multiModeDrtConfig, config.planCalcScore(), config.plansCalcRoute()); + DrtConfigs.adjustMultiModeDrtConfig(multiModeDrtConfig, config.scoring(), config.routing()); Scenario scenario = DrtControlerCreator.createScenarioWithDrtRouteFactory(config); ScenarioUtils.loadScenario(scenario); diff --git a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/fiss/FISS.java b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/fiss/FISS.java index ac265cf4a2c..58705f89cb3 100644 --- a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/fiss/FISS.java +++ b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/fiss/FISS.java @@ -164,7 +164,7 @@ public void afterSim() { } private boolean switchOffFISS() { - return (this.fissConfigGroup.switchOffFISSLastIteration && this.matsimServices.getConfig().controler().getLastIteration() == this.matsimServices.getIterationNumber()); + return (this.fissConfigGroup.switchOffFISSLastIteration && this.matsimServices.getConfig().controller().getLastIteration() == this.matsimServices.getIterationNumber()); } @Override diff --git a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/shifts/analysis/ShiftAnalysisControlerListener.java b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/shifts/analysis/ShiftAnalysisControlerListener.java index 2db2c3d8fec..de7026de9e2 100644 --- a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/shifts/analysis/ShiftAnalysisControlerListener.java +++ b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/shifts/analysis/ShiftAnalysisControlerListener.java @@ -52,7 +52,7 @@ public ShiftAnalysisControlerListener(Config config, DrtConfigGroup drtConfigGro @Override public void notifyIterationEnds(IterationEndsEvent event) { - boolean createGraphs = event.getServices().getConfig().controler().isCreateGraphs(); + boolean createGraphs = event.getServices().getConfig().controller().isCreateGraphs(); writeAndPlotShiftDurationComparison(shiftDurationXY.getShift2plannedVsActualDuration(), filename(event, "shiftDurationComparison", ".png"), diff --git a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/shifts/analysis/ShiftHistogramListener.java b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/shifts/analysis/ShiftHistogramListener.java index 18525c18a7f..15aef81a055 100644 --- a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/shifts/analysis/ShiftHistogramListener.java +++ b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/shifts/analysis/ShiftHistogramListener.java @@ -35,7 +35,7 @@ public void notifyIterationStarts(final IterationStartsEvent event) { public void notifyIterationEnds(final IterationEndsEvent event) { this.shiftHistogram.write(matsimServices.getControlerIO().getIterationFilename(event.getIteration(), drtConfigGroup.getMode() + "_" + "shiftHistogram.txt")); this.printStats(); - boolean createGraphs = event.getServices().getConfig().controler().isCreateGraphs(); + boolean createGraphs = event.getServices().getConfig().controller().isCreateGraphs(); if (createGraphs) { ShiftHistogramChart.writeGraphic(this.shiftHistogram, matsimServices.getControlerIO().getIterationFilename(event.getIteration(),drtConfigGroup.getMode() + "_" + "shiftHistogram.png")); } diff --git a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/shifts/analysis/efficiency/ShiftEfficiencyAnalysisControlerListener.java b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/shifts/analysis/efficiency/ShiftEfficiencyAnalysisControlerListener.java index a7b7c8248ed..f75637f76d7 100644 --- a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/shifts/analysis/efficiency/ShiftEfficiencyAnalysisControlerListener.java +++ b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/shifts/analysis/efficiency/ShiftEfficiencyAnalysisControlerListener.java @@ -56,7 +56,7 @@ public ShiftEfficiencyAnalysisControlerListener(DrtConfigGroup drtConfigGroup, @Override public void notifyIterationEnds(IterationEndsEvent event) { - boolean createGraphs = event.getServices().getConfig().controler().isCreateGraphs(); + boolean createGraphs = event.getServices().getConfig().controller().isCreateGraphs(); writeAndPlotShiftEfficiency( shiftEfficiencyTracker.getCurrentRecord().getRevenueByShift(), diff --git a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/preplanned/run/PreplannedDrtControlerCreator.java b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/preplanned/run/PreplannedDrtControlerCreator.java index fbf6325b77a..bbf5fa4c5c2 100644 --- a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/preplanned/run/PreplannedDrtControlerCreator.java +++ b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/preplanned/run/PreplannedDrtControlerCreator.java @@ -62,7 +62,7 @@ public final class PreplannedDrtControlerCreator { */ public static Controler createControler(Config config, boolean otfvis) { MultiModeDrtConfigGroup multiModeDrtConfig = MultiModeDrtConfigGroup.get(config); - DrtConfigs.adjustMultiModeDrtConfig(multiModeDrtConfig, config.planCalcScore(), config.plansCalcRoute()); + DrtConfigs.adjustMultiModeDrtConfig(multiModeDrtConfig, config.scoring(), config.routing()); Scenario scenario = createScenarioWithDrtRouteFactory(config); ScenarioUtils.loadScenario(scenario); diff --git a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/preplanned/run/RunPreplannedDrtExample.java b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/preplanned/run/RunPreplannedDrtExample.java index 04f7852c45a..e0463eb46f0 100644 --- a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/preplanned/run/RunPreplannedDrtExample.java +++ b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/preplanned/run/RunPreplannedDrtExample.java @@ -43,7 +43,7 @@ public static void run(URL configUrl, boolean otfvis, int lastIteration, Map preplannedSchedulesByMode) { Config config = ConfigUtils.loadConfig(configUrl, new MultiModeDrtConfigGroup(), new DvrpConfigGroup(), new OTFVisConfigGroup()); - config.controler().setLastIteration(lastIteration); + config.controller().setLastIteration(lastIteration); Controler controler = PreplannedDrtControlerCreator.createControler(config, otfvis); diff --git a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/DrtTestScenario.java b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/DrtTestScenario.java index 727e308844a..db01301303c 100644 --- a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/DrtTestScenario.java +++ b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/DrtTestScenario.java @@ -65,8 +65,8 @@ public static Config loadConfig(MatsimTestUtils utils) { URL context = ExamplesUtils.getTestScenarioURL("kelheim"); Config config = ConfigUtils.loadConfig(IOUtils.extendUrl(context, "config-with-drt.xml")); - config.controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists); - config.controler().setOutputDirectory(utils.getOutputDirectory()); + config.controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists); + config.controller().setOutputDirectory(utils.getOutputDirectory()); return config; } @@ -76,19 +76,19 @@ protected Config prepareConfig(Config config) { SnzActivities.addScoringParams(config); - config.planCalcScore().addActivityParams(new ScoringConfigGroup.ActivityParams("car interaction").setTypicalDuration(60)); - config.planCalcScore().addActivityParams(new ScoringConfigGroup.ActivityParams("other").setTypicalDuration(600 * 3)); + config.scoring().addActivityParams(new ScoringConfigGroup.ActivityParams("car interaction").setTypicalDuration(60)); + config.scoring().addActivityParams(new ScoringConfigGroup.ActivityParams("other").setTypicalDuration(600 * 3)); - config.planCalcScore().addActivityParams(new ScoringConfigGroup.ActivityParams("freight_start").setTypicalDuration(60 * 15)); - config.planCalcScore().addActivityParams(new ScoringConfigGroup.ActivityParams("freight_end").setTypicalDuration(60 * 15)); + config.scoring().addActivityParams(new ScoringConfigGroup.ActivityParams("freight_start").setTypicalDuration(60 * 15)); + config.scoring().addActivityParams(new ScoringConfigGroup.ActivityParams("freight_end").setTypicalDuration(60 * 15)); MultiModeDrtConfigGroup multiModeDrtConfig = ConfigUtils.addOrGetModule(config, MultiModeDrtConfigGroup.class); ConfigUtils.addOrGetModule(config, DvrpConfigGroup.class); - DrtConfigs.adjustMultiModeDrtConfig(multiModeDrtConfig, config.planCalcScore(), config.plansCalcRoute()); + DrtConfigs.adjustMultiModeDrtConfig(multiModeDrtConfig, config.scoring(), config.routing()); - config.plansCalcRoute().setAccessEgressType(RoutingConfigGroup.AccessEgressType.accessEgressModeToLink); + config.routing().setAccessEgressType(RoutingConfigGroup.AccessEgressType.accessEgressModeToLink); prepareConfig.accept(config); diff --git a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/companions/RunDrtWithCompanionExampleIT.java b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/companions/RunDrtWithCompanionExampleIT.java index de5534ab0e7..9ac24985fe4 100644 --- a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/companions/RunDrtWithCompanionExampleIT.java +++ b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/companions/RunDrtWithCompanionExampleIT.java @@ -24,9 +24,7 @@ import java.net.URL; import java.nio.file.Files; import java.nio.file.Paths; -import java.util.HashMap; import java.util.List; -import java.util.Map; import java.util.stream.Collectors; import org.assertj.core.api.Assertions; @@ -64,8 +62,8 @@ public void testRunDrtWithCompanions() { DrtWithExtensionsConfigGroup drtWithExtensionsConfigGroup = (DrtWithExtensionsConfigGroup) multiModeDrtConfigGroup.getModalElements().iterator().next(); drtWithExtensionsConfigGroup.addParameterSet(new DrtCompanionParams()); - config.controler().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); - config.controler().setOutputDirectory(utils.getOutputDirectory()); + config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); + config.controller().setOutputDirectory(utils.getOutputDirectory()); Controler controler = DrtCompanionControlerCreator.createControler(config); controler.run(); diff --git a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/dashboards/DashboardTests.java b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/dashboards/DashboardTests.java index 43e8f7dfffe..c26a623fec8 100644 --- a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/dashboards/DashboardTests.java +++ b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/dashboards/DashboardTests.java @@ -23,9 +23,9 @@ public class DashboardTests { private void run() { Config config = DrtTestScenario.loadConfig(utils); - config.controler().setLastIteration(4); - config.controler().setWritePlansInterval(4); - config.controler().setWriteEventsInterval(4); + config.controller().setLastIteration(4); + config.controller().setWritePlansInterval(4); + config.controller().setWriteEventsInterval(4); SimWrapperConfigGroup group = ConfigUtils.addOrGetModule(config, SimWrapperConfigGroup.class); group.defaultParams().sampleSize = 0.001; diff --git a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/fiss/RunFissDrtScenarioIT.java b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/fiss/RunFissDrtScenarioIT.java index 90c58dcc729..2f88290727e 100644 --- a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/fiss/RunFissDrtScenarioIT.java +++ b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/fiss/RunFissDrtScenarioIT.java @@ -92,9 +92,9 @@ public void test() { config.travelTimeCalculator().setAnalyzedModes(modes); ScoringConfigGroup.ModeParams scoreParams = new ScoringConfigGroup.ModeParams("drt"); - config.planCalcScore().addModeParams(scoreParams); + config.scoring().addModeParams(scoreParams); ScoringConfigGroup.ModeParams scoreParams2 = new ScoringConfigGroup.ModeParams("walk"); - config.planCalcScore().addModeParams(scoreParams2); + config.scoring().addModeParams(scoreParams2); config.plans().setInputFile(plansFile); config.network().setInputFile(networkFile); @@ -113,22 +113,22 @@ public void test() { final ScoringConfigGroup.ActivityParams work = new ScoringConfigGroup.ActivityParams("work"); work.setTypicalDuration(2 * 3600); - config.planCalcScore().addActivityParams(home); - config.planCalcScore().addActivityParams(other); - config.planCalcScore().addActivityParams(education); - config.planCalcScore().addActivityParams(shopping); - config.planCalcScore().addActivityParams(work); + config.scoring().addActivityParams(home); + config.scoring().addActivityParams(other); + config.scoring().addActivityParams(education); + config.scoring().addActivityParams(shopping); + config.scoring().addActivityParams(work); final ReplanningConfigGroup.StrategySettings stratSets = new ReplanningConfigGroup.StrategySettings(); stratSets.setWeight(1); stratSets.setStrategyName("ChangeExpBeta"); - config.strategy().addStrategySettings(stratSets); + config.replanning().addStrategySettings(stratSets); - config.controler().setLastIteration(2); - config.controler().setWriteEventsInterval(1); + config.controller().setLastIteration(2); + config.controller().setWriteEventsInterval(1); - config.controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists); - config.controler().setOutputDirectory("test/output/holzkirchen_shifts"); + config.controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists); + config.controller().setOutputDirectory("test/output/holzkirchen_shifts"); DrtOperationsParams operationsParams = (DrtOperationsParams) drtWithShiftsConfigGroup.createParameterSet(DrtOperationsParams.SET_NAME); ShiftsParams shiftsParams = (ShiftsParams) operationsParams.createParameterSet(ShiftsParams.SET_NAME); diff --git a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/eshifts/run/RunEShiftDrtScenarioIT.java b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/eshifts/run/RunEShiftDrtScenarioIT.java index be9a9ce3972..4abe57ba415 100644 --- a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/eshifts/run/RunEShiftDrtScenarioIT.java +++ b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/eshifts/run/RunEShiftDrtScenarioIT.java @@ -95,9 +95,9 @@ public void test() { config.travelTimeCalculator().setAnalyzedModes(modes); ScoringConfigGroup.ModeParams scoreParams = new ScoringConfigGroup.ModeParams("drt"); - config.planCalcScore().addModeParams(scoreParams); + config.scoring().addModeParams(scoreParams); ScoringConfigGroup.ModeParams scoreParams2 = new ScoringConfigGroup.ModeParams("walk"); - config.planCalcScore().addModeParams(scoreParams2); + config.scoring().addModeParams(scoreParams2); config.plans().setInputFile(plansFile); config.network().setInputFile(networkFile); @@ -117,22 +117,22 @@ public void test() { final ScoringConfigGroup.ActivityParams work = new ScoringConfigGroup.ActivityParams("work"); work.setTypicalDuration(2 * 3600); - config.planCalcScore().addActivityParams(home); - config.planCalcScore().addActivityParams(other); - config.planCalcScore().addActivityParams(education); - config.planCalcScore().addActivityParams(shopping); - config.planCalcScore().addActivityParams(work); + config.scoring().addActivityParams(home); + config.scoring().addActivityParams(other); + config.scoring().addActivityParams(education); + config.scoring().addActivityParams(shopping); + config.scoring().addActivityParams(work); final ReplanningConfigGroup.StrategySettings stratSets = new ReplanningConfigGroup.StrategySettings(); stratSets.setWeight(1); stratSets.setStrategyName("ChangeExpBeta"); - config.strategy().addStrategySettings(stratSets); + config.replanning().addStrategySettings(stratSets); - config.controler().setLastIteration(1); - config.controler().setWriteEventsInterval(1); + config.controller().setLastIteration(1); + config.controller().setWriteEventsInterval(1); - config.controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists); - config.controler().setOutputDirectory("test/output/holzkirchen_eshifts"); + config.controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists); + config.controller().setOutputDirectory("test/output/holzkirchen_eshifts"); DrtOperationsParams operationsParams = (DrtOperationsParams) drtWithShiftsConfigGroup.createParameterSet(DrtOperationsParams.SET_NAME); ShiftsParams shiftsParams = (ShiftsParams) operationsParams.createParameterSet(ShiftsParams.SET_NAME); diff --git a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/shifts/run/RunMultiHubShiftDrtScenarioIT.java b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/shifts/run/RunMultiHubShiftDrtScenarioIT.java index fa860c4ccdf..91c2dd16be9 100644 --- a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/shifts/run/RunMultiHubShiftDrtScenarioIT.java +++ b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/shifts/run/RunMultiHubShiftDrtScenarioIT.java @@ -84,9 +84,9 @@ public void test() { config.travelTimeCalculator().setAnalyzedModes(modes); ScoringConfigGroup.ModeParams scoreParams = new ScoringConfigGroup.ModeParams("drt"); - config.planCalcScore().addModeParams(scoreParams); + config.scoring().addModeParams(scoreParams); ScoringConfigGroup.ModeParams scoreParams2 = new ScoringConfigGroup.ModeParams("walk"); - config.planCalcScore().addModeParams(scoreParams2); + config.scoring().addModeParams(scoreParams2); config.plans().setInputFile(plansFile); config.network().setInputFile(networkFile); @@ -106,22 +106,22 @@ public void test() { final ScoringConfigGroup.ActivityParams work = new ScoringConfigGroup.ActivityParams("work"); work.setTypicalDuration(2 * 3600); - config.planCalcScore().addActivityParams(home); - config.planCalcScore().addActivityParams(other); - config.planCalcScore().addActivityParams(education); - config.planCalcScore().addActivityParams(shopping); - config.planCalcScore().addActivityParams(work); + config.scoring().addActivityParams(home); + config.scoring().addActivityParams(other); + config.scoring().addActivityParams(education); + config.scoring().addActivityParams(shopping); + config.scoring().addActivityParams(work); final ReplanningConfigGroup.StrategySettings stratSets = new ReplanningConfigGroup.StrategySettings(); stratSets.setWeight(1); stratSets.setStrategyName("ChangeExpBeta"); - config.strategy().addStrategySettings(stratSets); + config.replanning().addStrategySettings(stratSets); - config.controler().setLastIteration(1); - config.controler().setWriteEventsInterval(1); + config.controller().setLastIteration(1); + config.controller().setWriteEventsInterval(1); - config.controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists); - config.controler().setOutputDirectory("test/output/holzkirchen_shifts_multiHub"); + config.controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists); + config.controller().setOutputDirectory("test/output/holzkirchen_shifts_multiHub"); DrtOperationsParams operationsParams = (DrtOperationsParams) drtWithShiftsConfigGroup.createParameterSet(DrtOperationsParams.SET_NAME); ShiftsParams shiftsParams = (ShiftsParams) operationsParams.createParameterSet(ShiftsParams.SET_NAME); diff --git a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/shifts/run/RunShiftDrtScenarioIT.java b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/shifts/run/RunShiftDrtScenarioIT.java index 39e6cd667b4..e6b9caf51af 100644 --- a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/shifts/run/RunShiftDrtScenarioIT.java +++ b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/shifts/run/RunShiftDrtScenarioIT.java @@ -85,9 +85,9 @@ public void test() { config.travelTimeCalculator().setAnalyzedModes(modes); ScoringConfigGroup.ModeParams scoreParams = new ScoringConfigGroup.ModeParams("drt"); - config.planCalcScore().addModeParams(scoreParams); + config.scoring().addModeParams(scoreParams); ScoringConfigGroup.ModeParams scoreParams2 = new ScoringConfigGroup.ModeParams("walk"); - config.planCalcScore().addModeParams(scoreParams2); + config.scoring().addModeParams(scoreParams2); config.plans().setInputFile(plansFile); config.network().setInputFile(networkFile); @@ -106,22 +106,22 @@ public void test() { final ScoringConfigGroup.ActivityParams work = new ScoringConfigGroup.ActivityParams("work"); work.setTypicalDuration(2 * 3600); - config.planCalcScore().addActivityParams(home); - config.planCalcScore().addActivityParams(other); - config.planCalcScore().addActivityParams(education); - config.planCalcScore().addActivityParams(shopping); - config.planCalcScore().addActivityParams(work); + config.scoring().addActivityParams(home); + config.scoring().addActivityParams(other); + config.scoring().addActivityParams(education); + config.scoring().addActivityParams(shopping); + config.scoring().addActivityParams(work); final ReplanningConfigGroup.StrategySettings stratSets = new ReplanningConfigGroup.StrategySettings(); stratSets.setWeight(1); stratSets.setStrategyName("ChangeExpBeta"); - config.strategy().addStrategySettings(stratSets); + config.replanning().addStrategySettings(stratSets); - config.controler().setLastIteration(1); - config.controler().setWriteEventsInterval(1); + config.controller().setLastIteration(1); + config.controller().setWriteEventsInterval(1); - config.controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists); - config.controler().setOutputDirectory("test/output/holzkirchen_shifts"); + config.controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists); + config.controller().setOutputDirectory("test/output/holzkirchen_shifts"); DrtOperationsParams operationsParams = (DrtOperationsParams) drtWithShiftsConfigGroup.createParameterSet(DrtOperationsParams.SET_NAME); ShiftsParams shiftsParams = (ShiftsParams) operationsParams.createParameterSet(ShiftsParams.SET_NAME); diff --git a/contribs/drt/src/main/java/org/matsim/contrib/drt/analysis/DrtAnalysisControlerListener.java b/contribs/drt/src/main/java/org/matsim/contrib/drt/analysis/DrtAnalysisControlerListener.java index 17f55751141..ab98bfcc71a 100644 --- a/contribs/drt/src/main/java/org/matsim/contrib/drt/analysis/DrtAnalysisControlerListener.java +++ b/contribs/drt/src/main/java/org/matsim/contrib/drt/analysis/DrtAnalysisControlerListener.java @@ -110,7 +110,7 @@ public class DrtAnalysisControlerListener implements IterationEndsListener, Shut this.vehicleOccupancyProfileCalculator = vehicleOccupancyProfileCalculator; this.drtCfg = drtCfg; this.qSimCfg = config.qsim(); - runId = Optional.ofNullable(config.controler().getRunId()).orElse(notAvailableString); + runId = Optional.ofNullable(config.controller().getRunId()).orElse(notAvailableString); maxcap = findMaxVehicleCapacity(fleet); format.setDecimalFormatSymbols(new DecimalFormatSymbols(Locale.US)); @@ -153,7 +153,7 @@ private static DrtLeg newDrtLeg(EventSequence sequence, Function, ? ext @Override public void notifyIterationEnds(IterationEndsEvent event) { - boolean createGraphs = event.getServices().getConfig().controler().isCreateGraphs(); + boolean createGraphs = event.getServices().getConfig().controller().isCreateGraphs(); writeAndPlotWaitTimeEstimateComparison(drtEventSequenceCollector.getPerformedRequestSequences().values(), filename(event, "waitTimeComparison", ".png"), filename(event, "waitTimeComparison", ".csv"), createGraphs); diff --git a/contribs/drt/src/main/java/org/matsim/contrib/drt/run/DrtControlerCreator.java b/contribs/drt/src/main/java/org/matsim/contrib/drt/run/DrtControlerCreator.java index 7c28080f46f..ab438acc805 100644 --- a/contribs/drt/src/main/java/org/matsim/contrib/drt/run/DrtControlerCreator.java +++ b/contribs/drt/src/main/java/org/matsim/contrib/drt/run/DrtControlerCreator.java @@ -61,7 +61,7 @@ public static Scenario createScenarioWithDrtRouteFactory(Config config) { */ public static Controler createControler(Config config, boolean otfvis) { MultiModeDrtConfigGroup multiModeDrtConfig = MultiModeDrtConfigGroup.get(config); - DrtConfigs.adjustMultiModeDrtConfig(multiModeDrtConfig, config.planCalcScore(), config.plansCalcRoute()); + DrtConfigs.adjustMultiModeDrtConfig(multiModeDrtConfig, config.scoring(), config.routing()); Scenario scenario = createScenarioWithDrtRouteFactory(config); ScenarioUtils.loadScenario(scenario); diff --git a/contribs/drt/src/main/java/org/matsim/contrib/drt/run/DrtModeModule.java b/contribs/drt/src/main/java/org/matsim/contrib/drt/run/DrtModeModule.java index 6176da047c8..fac873dbb8e 100644 --- a/contribs/drt/src/main/java/org/matsim/contrib/drt/run/DrtModeModule.java +++ b/contribs/drt/src/main/java/org/matsim/contrib/drt/run/DrtModeModule.java @@ -77,16 +77,16 @@ public void install() { drtCfg.getDrtSpeedUpParams().ifPresent(drtSpeedUpParams -> { bindModal(DrtSpeedUp.class).toProvider(modalProvider( - getter -> new DrtSpeedUp(getMode(), drtSpeedUpParams, getConfig().controler(), + getter -> new DrtSpeedUp(getMode(), drtSpeedUpParams, getConfig().controller(), getter.get(Network.class), getter.getModal(FleetSpecification.class), getter.getModal(DrtEventSequenceCollector.class)))).asEagerSingleton(); addControlerListenerBinding().to(modalKey(DrtSpeedUp.class)); }); - + bindModal(DefaultStopTimeCalculator.class).toProvider(modalProvider(getter -> { return new DefaultStopTimeCalculator(drtCfg.stopDuration); })).in(Singleton.class); - + bindModal(StopTimeCalculator.class).to(modalKey(DefaultStopTimeCalculator.class)); install(new AdaptiveTravelTimeMatrixModule(drtCfg.mode)); diff --git a/contribs/drt/src/main/java/org/matsim/contrib/drt/run/DrtModeQSimModule.java b/contribs/drt/src/main/java/org/matsim/contrib/drt/run/DrtModeQSimModule.java index ffbe7f67537..ecaaf5b4065 100644 --- a/contribs/drt/src/main/java/org/matsim/contrib/drt/run/DrtModeQSimModule.java +++ b/contribs/drt/src/main/java/org/matsim/contrib/drt/run/DrtModeQSimModule.java @@ -55,7 +55,7 @@ public DrtModeQSimModule(DrtConfigGroup drtCfg, AbstractQSimModule optimizerQSim @Override protected void configureQSim() { boolean teleportDrtUsers = drtCfg.getDrtSpeedUpParams().isPresent() && DrtSpeedUp.isTeleportDrtUsers( - drtCfg.getDrtSpeedUpParams().get(), getConfig().controler(), getIterationNumber()); + drtCfg.getDrtSpeedUpParams().get(), getConfig().controller(), getIterationNumber()); if (teleportDrtUsers) { install(new PassengerEngineQSimModule(getMode(), PassengerEngineQSimModule.PassengerEngineType.TELEPORTING)); diff --git a/contribs/drt/src/main/java/org/matsim/contrib/drt/run/examples/RunMultiModeDrtExample.java b/contribs/drt/src/main/java/org/matsim/contrib/drt/run/examples/RunMultiModeDrtExample.java index 53da0c974db..8452181b4c2 100644 --- a/contribs/drt/src/main/java/org/matsim/contrib/drt/run/examples/RunMultiModeDrtExample.java +++ b/contribs/drt/src/main/java/org/matsim/contrib/drt/run/examples/RunMultiModeDrtExample.java @@ -41,7 +41,7 @@ public class RunMultiModeDrtExample { public static void run(URL configUrl, boolean otfvis, int lastIteration) { Config config = ConfigUtils.loadConfig(configUrl, new MultiModeDrtConfigGroup(), new DvrpConfigGroup(), new OTFVisConfigGroup()); - config.controler().setLastIteration(lastIteration); + config.controller().setLastIteration(lastIteration); Controler controler = DrtControlerCreator.createControler(config, otfvis); diff --git a/contribs/drt/src/main/java/org/matsim/contrib/drt/run/examples/RunOneSharedTaxiExample.java b/contribs/drt/src/main/java/org/matsim/contrib/drt/run/examples/RunOneSharedTaxiExample.java index 9ca1f9f3452..3ce549d1ac7 100644 --- a/contribs/drt/src/main/java/org/matsim/contrib/drt/run/examples/RunOneSharedTaxiExample.java +++ b/contribs/drt/src/main/java/org/matsim/contrib/drt/run/examples/RunOneSharedTaxiExample.java @@ -35,8 +35,8 @@ public class RunOneSharedTaxiExample { public static void run(URL configUrl, boolean otfvis, int lastIteration) { Config config = ConfigUtils.loadConfig(configUrl, new MultiModeDrtConfigGroup(), new DvrpConfigGroup(), new OTFVisConfigGroup()); - config.controler().setLastIteration(lastIteration); - config.controler().setWriteEventsInterval(lastIteration); + config.controller().setLastIteration(lastIteration); + config.controller().setWriteEventsInterval(lastIteration); DrtControlerCreator.createControler(config, otfvis).run(); } } diff --git a/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/DrtPoolingParameterTest.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/DrtPoolingParameterTest.java index 236d2889a6a..c708e623de0 100644 --- a/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/DrtPoolingParameterTest.java +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/insertion/DrtPoolingParameterTest.java @@ -4,7 +4,6 @@ import java.util.*; import org.junit.Assert; -import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.matsim.api.core.v01.Id; @@ -213,9 +212,9 @@ private PersonEnterDrtVehicleEventHandler setupAndRunScenario(double maxWaitTime new OTFVisConfigGroup()); config.plans().setInputFile(null); - config.controler() + config.controller() .setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists); - config.controler().setOutputDirectory(utils.getOutputDirectory()); + config.controller().setOutputDirectory(utils.getOutputDirectory()); MultiModeDrtConfigGroup mm = ConfigUtils.addOrGetModule(config, MultiModeDrtConfigGroup.class); mm.getModalElements().forEach(x -> { diff --git a/contribs/drt/src/test/java/org/matsim/contrib/drt/run/examples/RunDrtExampleIT.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/run/examples/RunDrtExampleIT.java index 3d28a85cffd..fe7d10d9b7b 100644 --- a/contribs/drt/src/test/java/org/matsim/contrib/drt/run/examples/RunDrtExampleIT.java +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/run/examples/RunDrtExampleIT.java @@ -78,8 +78,8 @@ public void testRunDrtExampleWithNoRejections_ExtensiveSearch() { drtCfg.rejectRequestIfMaxWaitOrTravelTimeViolated = false; } - config.controler().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); - config.controler().setOutputDirectory(utils.getOutputDirectory()); + config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); + config.controller().setOutputDirectory(utils.getOutputDirectory()); RunDrtExample.run(config, false); var expectedStats = Stats.newBuilder() @@ -112,8 +112,8 @@ public void testRunDrtExampleWithNoRejections_SelectiveSearch() { drtCfg.rejectRequestIfMaxWaitOrTravelTimeViolated = false; } - config.controler().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); - config.controler().setOutputDirectory(utils.getOutputDirectory()); + config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); + config.controller().setOutputDirectory(utils.getOutputDirectory()); RunDrtExample.run(config, false); var expectedStats = Stats.newBuilder() @@ -146,9 +146,9 @@ public void testRunDrtExampleWithNoRejections_RepeatedSelectiveSearch() { drtCfg.rejectRequestIfMaxWaitOrTravelTimeViolated = false; } - config.controler().setLastIteration(3); - config.controler().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); - config.controler().setOutputDirectory(utils.getOutputDirectory()); + config.controller().setLastIteration(3); + config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); + config.controller().setOutputDirectory(utils.getOutputDirectory()); RunDrtExample.run(config, false); var expectedStats = Stats.newBuilder() @@ -176,8 +176,8 @@ public void testRunDrtExampleWithRequestRetry() { drtCfg.addParameterSet(drtRequestInsertionRetryParams); } - config.controler().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); - config.controler().setOutputDirectory(utils.getOutputDirectory()); + config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); + config.controller().setOutputDirectory(utils.getOutputDirectory()); RunDrtExample.run(config, false); var expectedStats = Stats.newBuilder() @@ -199,8 +199,8 @@ public void testRunDrtStopbasedExample() { Config config = ConfigUtils.loadConfig(configUrl, new MultiModeDrtConfigGroup(), new DvrpConfigGroup(), new OTFVisConfigGroup()); - config.controler().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); - config.controler().setOutputDirectory(utils.getOutputDirectory()); + config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); + config.controller().setOutputDirectory(utils.getOutputDirectory()); RunDrtExample.run(config, false); var expectedStats = Stats.newBuilder() @@ -213,19 +213,19 @@ public void testRunDrtStopbasedExample() { verifyDrtCustomerStatsCloseToExpectedStats(utils.getOutputDirectory(), expectedStats); } - + @Test - public void testRunDrtStopbasedExampleWithFlexibleStopDuration() { + public void testRunDrtStopbasedExampleWithFlexibleStopDuration() { Id.resetCaches(); URL configUrl = IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("mielec"), "mielec_stop_based_drt_config.xml"); Config config = ConfigUtils.loadConfig(configUrl, new MultiModeDrtConfigGroup(), new DvrpConfigGroup(), new OTFVisConfigGroup()); - config.controler().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); - config.controler().setOutputDirectory(utils.getOutputDirectory()); - - Controler controller = DrtControlerCreator.createControler(config, false); + config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); + config.controller().setOutputDirectory(utils.getOutputDirectory()); + + Controler controller = DrtControlerCreator.createControler(config, false); // This snippet adds the correction against wait times smaller than the defined stopDuration controller.addOverridingModule(new AbstractDvrpModeModule("drt") { @@ -235,7 +235,7 @@ public void install() { bindModal(StopTimeCalculator.class).toInstance(stopTimeCalculator); } }); - + controller.run(); var expectedStats = Stats.newBuilder() @@ -257,8 +257,8 @@ public void testRunServiceAreabasedExampleWithSpeedUp() { Config config = ConfigUtils.loadConfig(configUrl, new MultiModeDrtConfigGroup(), new DvrpConfigGroup(), new OTFVisConfigGroup()); - config.controler().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); - config.controler().setOutputDirectory(utils.getOutputDirectory()); + config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); + config.controller().setOutputDirectory(utils.getOutputDirectory()); RunDrtExample.run(config, false); var expectedStats = Stats.newBuilder() @@ -279,8 +279,8 @@ public void testRunDrtExampleWithIncrementalStopDuration() { Config config = ConfigUtils.loadConfig(configUrl, new MultiModeDrtConfigGroup(), new DvrpConfigGroup(), new OTFVisConfigGroup()); - config.controler().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); - config.controler().setOutputDirectory(utils.getOutputDirectory()); + config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); + config.controller().setOutputDirectory(utils.getOutputDirectory()); Controler controller = DrtControlerCreator.createControler(config, false); diff --git a/contribs/dvrp/src/main/java/org/matsim/contrib/dvrp/examples/onetaxi/RunOneTaxiExample.java b/contribs/dvrp/src/main/java/org/matsim/contrib/dvrp/examples/onetaxi/RunOneTaxiExample.java index 686ff8d9713..e151f68821c 100644 --- a/contribs/dvrp/src/main/java/org/matsim/contrib/dvrp/examples/onetaxi/RunOneTaxiExample.java +++ b/contribs/dvrp/src/main/java/org/matsim/contrib/dvrp/examples/onetaxi/RunOneTaxiExample.java @@ -42,7 +42,7 @@ public final class RunOneTaxiExample { public static void run(URL configUrl, String taxisFile, boolean otfvis, int lastIteration) { // load config Config config = ConfigUtils.loadConfig(configUrl, new DvrpConfigGroup(), new OTFVisConfigGroup()); - config.controler().setLastIteration(lastIteration); + config.controller().setLastIteration(lastIteration); // load scenario Scenario scenario = ScenarioUtils.loadScenario(config); diff --git a/contribs/dvrp/src/main/java/org/matsim/contrib/dvrp/examples/onetaxionetruck/RunOneTaxiOneTruckExample.java b/contribs/dvrp/src/main/java/org/matsim/contrib/dvrp/examples/onetaxionetruck/RunOneTaxiOneTruckExample.java index 9c3298cde14..4c4232b15b5 100644 --- a/contribs/dvrp/src/main/java/org/matsim/contrib/dvrp/examples/onetaxionetruck/RunOneTaxiOneTruckExample.java +++ b/contribs/dvrp/src/main/java/org/matsim/contrib/dvrp/examples/onetaxionetruck/RunOneTaxiOneTruckExample.java @@ -45,7 +45,7 @@ public class RunOneTaxiOneTruckExample { public static void run(URL configUrl, String taxisFile, String trucksFile, boolean otfvis, int lastIteration) { // load config Config config = ConfigUtils.loadConfig(configUrl, new DvrpConfigGroup(), new OTFVisConfigGroup()); - config.controler().setLastIteration(lastIteration); + config.controller().setLastIteration(lastIteration); // load scenario Scenario scenario = ScenarioUtils.loadScenario(config); diff --git a/contribs/dvrp/src/main/java/org/matsim/contrib/dvrp/examples/onetruck/RunOneTruckExample.java b/contribs/dvrp/src/main/java/org/matsim/contrib/dvrp/examples/onetruck/RunOneTruckExample.java index 5f555ce90f7..2bb198672a7 100644 --- a/contribs/dvrp/src/main/java/org/matsim/contrib/dvrp/examples/onetruck/RunOneTruckExample.java +++ b/contribs/dvrp/src/main/java/org/matsim/contrib/dvrp/examples/onetruck/RunOneTruckExample.java @@ -41,7 +41,7 @@ public final class RunOneTruckExample { public static void run(URL configUrl, String trucksFile, boolean otfvis, int lastIteration) { // load config Config config = ConfigUtils.loadConfig(configUrl, new DvrpConfigGroup(), new OTFVisConfigGroup()); - config.controler().setLastIteration(lastIteration); + config.controller().setLastIteration(lastIteration); // load scenario Scenario scenario = ScenarioUtils.loadScenario(config); diff --git a/contribs/dvrp/src/main/java/org/matsim/contrib/dvrp/run/DvrpConfigGroup.java b/contribs/dvrp/src/main/java/org/matsim/contrib/dvrp/run/DvrpConfigGroup.java index cc4b609e6cc..6d0b68cb400 100644 --- a/contribs/dvrp/src/main/java/org/matsim/contrib/dvrp/run/DvrpConfigGroup.java +++ b/contribs/dvrp/src/main/java/org/matsim/contrib/dvrp/run/DvrpConfigGroup.java @@ -143,7 +143,7 @@ protected void checkConsistency(Config config) { if (config.qsim().isRemoveStuckVehicles()) { throw new RuntimeException("Stuck DynAgents cannot be removed from simulation"); } - if (!config.parallelEventHandling().getSynchronizeOnSimSteps()) { + if (!config.eventsManager().getSynchronizeOnSimSteps()) { throw new RuntimeException("Synchronization on sim steps is required"); } } diff --git a/contribs/dvrp/src/main/java/org/matsim/contrib/dynagent/examples/random/RunRandomDynAgentExample.java b/contribs/dvrp/src/main/java/org/matsim/contrib/dynagent/examples/random/RunRandomDynAgentExample.java index 3bb9d6b7231..0952558534d 100644 --- a/contribs/dvrp/src/main/java/org/matsim/contrib/dynagent/examples/random/RunRandomDynAgentExample.java +++ b/contribs/dvrp/src/main/java/org/matsim/contrib/dynagent/examples/random/RunRandomDynAgentExample.java @@ -47,9 +47,9 @@ public static void run(URL context, String networkFile, boolean otfvis) { config.qsim().setSimStarttimeInterpretation(StarttimeInterpretation.onlyUseStarttime); config.qsim().setSnapshotStyle(SnapshotStyle.queue); config.network().setInputFile(networkFile); - config.controler().setOutputDirectory("./test/output/random_dyn_agent/"); - config.controler().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); - config.controler().setLastIteration(0); + config.controller().setOutputDirectory("./test/output/random_dyn_agent/"); + config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); + config.controller().setLastIteration(0); config.addConfigConsistencyChecker(new DynQSimConfigConsistencyChecker()); Scenario scenario = ScenarioUtils.loadScenario(config); diff --git a/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/examples/onetaxi/RunOneTaxiWithPrebookingExampleIT.java b/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/examples/onetaxi/RunOneTaxiWithPrebookingExampleIT.java index 02917236596..c2b6f6a5753 100644 --- a/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/examples/onetaxi/RunOneTaxiWithPrebookingExampleIT.java +++ b/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/examples/onetaxi/RunOneTaxiWithPrebookingExampleIT.java @@ -78,9 +78,9 @@ public void testRun() { URL configUrl = IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("dvrp-grid"), "generic_dvrp_one_taxi_config.xml"); Config config = ConfigUtils.loadConfig(configUrl, new DvrpConfigGroup(), new OTFVisConfigGroup()); - config.controler().setLastIteration(0); + config.controller().setLastIteration(0); - config.controler().setOutputDirectory(utils.getOutputDirectory()); + config.controller().setOutputDirectory(utils.getOutputDirectory()); { QSimComponentsConfigGroup qsimComponentsConfig = ConfigUtils.addOrGetModule(config, QSimComponentsConfigGroup.class); diff --git a/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/router/DiversionTest.java b/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/router/DiversionTest.java index 5f158a0480a..adf44ba57ac 100644 --- a/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/router/DiversionTest.java +++ b/contribs/dvrp/src/test/java/org/matsim/contrib/dvrp/router/DiversionTest.java @@ -126,8 +126,8 @@ public void testRepeatedSameDestinationDiversions() { { /* Create some necessary configuration for the test */ - config.controler().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); - config.controler().setLastIteration(0); + config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); + config.controller().setLastIteration(0); config.qsim().setStartTime(0.0); config.qsim().setSimStarttimeInterpretation(StarttimeInterpretation.onlyUseStarttime); @@ -453,8 +453,8 @@ public void testRepeatedDiversionToDifferentDestinationRightBeforeLastLink() { { /* Create some necessary configuration for the test */ - config.controler().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); - config.controler().setLastIteration(0); + config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); + config.controller().setLastIteration(0); config.qsim().setStartTime(0.0); config.qsim().setSimStarttimeInterpretation(StarttimeInterpretation.onlyUseStarttime); diff --git a/contribs/emissions/src/main/java/org/matsim/contrib/emissions/PositionEmissionsModule.java b/contribs/emissions/src/main/java/org/matsim/contrib/emissions/PositionEmissionsModule.java index 2752083ac30..4652c3d7339 100644 --- a/contribs/emissions/src/main/java/org/matsim/contrib/emissions/PositionEmissionsModule.java +++ b/contribs/emissions/src/main/java/org/matsim/contrib/emissions/PositionEmissionsModule.java @@ -68,7 +68,7 @@ private static void checkConsistency(Config config) { if (config.qsim().getSnapshotPeriod() > 1) { throw new RuntimeException("only snapshot periods of 1s are supported."); } - if (!config.controler().getSnapshotFormat().contains(ControllerConfigGroup.SnapshotFormat.positionevents)) { + if (!config.controller().getSnapshotFormat().contains(ControllerConfigGroup.SnapshotFormat.positionevents)) { throw new RuntimeException("config.controler.snapshotFormat must be set to 'positionevents'"); } if (isNotCorrectSnapshotStyle(config.qsim().getSnapshotStyle())) { diff --git a/contribs/emissions/src/main/java/org/matsim/contrib/emissions/example/CreateEmissionConfig.java b/contribs/emissions/src/main/java/org/matsim/contrib/emissions/example/CreateEmissionConfig.java index bb4e8350d53..f50fc6a6d27 100644 --- a/contribs/emissions/src/main/java/org/matsim/contrib/emissions/example/CreateEmissionConfig.java +++ b/contribs/emissions/src/main/java/org/matsim/contrib/emissions/example/CreateEmissionConfig.java @@ -79,13 +79,13 @@ public static void main(String[] args) { MatsimServices controler = new Controler(config); // controlerConfigGroup - ControllerConfigGroup ccg = controler.getConfig().controler(); + ControllerConfigGroup ccg = controler.getConfig().controller(); ccg.setOutputDirectory(outputPath); ccg.setFirstIteration(0); ccg.setLastIteration(numberOfIterations-1); // planCalcScoreConfigGroup - ScoringConfigGroup pcs = controler.getConfig().planCalcScore(); + ScoringConfigGroup pcs = controler.getConfig().scoring(); ActivityParams homeP = new ActivityParams("home"); homeP.setTypicalDuration(12 * 3600); pcs.addActivityParams(homeP); @@ -94,7 +94,7 @@ public static void main(String[] args) { pcs.addActivityParams(workP); // strategy - ReplanningConfigGroup scg = controler.getConfig().strategy(); + ReplanningConfigGroup scg = controler.getConfig().replanning(); StrategySettings strategySettings = new StrategySettings(); strategySettings.setStrategyName("ChangeExpBeta"); strategySettings.setWeight(1.0); diff --git a/contribs/emissions/src/main/java/org/matsim/contrib/emissions/example/RunAverageEmissionToolOfflineExample.java b/contribs/emissions/src/main/java/org/matsim/contrib/emissions/example/RunAverageEmissionToolOfflineExample.java index fd852ba1a61..bd1af3c2a90 100644 --- a/contribs/emissions/src/main/java/org/matsim/contrib/emissions/example/RunAverageEmissionToolOfflineExample.java +++ b/contribs/emissions/src/main/java/org/matsim/contrib/emissions/example/RunAverageEmissionToolOfflineExample.java @@ -26,9 +26,7 @@ import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; import org.matsim.core.controler.AbstractModule; -import org.matsim.core.controler.Controler; import org.matsim.core.controler.Injector; -import org.matsim.core.controler.OutputDirectoryHierarchy; import org.matsim.core.events.EventsUtils; import org.matsim.core.events.MatsimEventsReader; import org.matsim.core.events.algorithms.EventWriterXML; @@ -39,7 +37,7 @@ /** * - * Use the config file as created by the + * Use the config file as created by the * {@link CreateEmissionConfig CreateEmissionConfig} to calculate * emissions based on the link leave events of an events file. Resulting emission events are written into an event file. * @@ -55,7 +53,7 @@ public final class RunAverageEmissionToolOfflineExample{ private Config config; - // ======================================================================================================= + // ======================================================================================================= public static void main (String[] args){ RunAverageEmissionToolOfflineExample emissionToolOfflineExampleV2 = new RunAverageEmissionToolOfflineExample(); @@ -105,7 +103,7 @@ public void install(){ EmissionModule emissionModule = injector.getInstance(EmissionModule.class); // OutputDirectoryHierarchy outputDirectoryHierarchy = injector.getInstance( OutputDirectoryHierarchy.class ); - final String outputDirectory = scenario.getConfig().controler().getOutputDirectory(); + final String outputDirectory = scenario.getConfig().controller().getOutputDirectory(); EventWriterXML emissionEventWriter = new EventWriterXML( outputDirectory + emissionEventsFilename ); emissionModule.getEmissionEventsManager().addHandler(emissionEventWriter); diff --git a/contribs/emissions/src/main/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOfflineExample.java b/contribs/emissions/src/main/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOfflineExample.java index a4818fcf794..191766556c2 100644 --- a/contribs/emissions/src/main/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOfflineExample.java +++ b/contribs/emissions/src/main/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOfflineExample.java @@ -29,7 +29,6 @@ import org.matsim.core.controler.Injector; import org.matsim.core.events.EventsUtils; import org.matsim.core.events.MatsimEventsReader; -import org.matsim.core.events.ParallelEventsManager; import org.matsim.core.events.algorithms.EventWriterXML; import org.matsim.core.scenario.ScenarioUtils; import org.matsim.core.utils.io.IOUtils; @@ -38,7 +37,7 @@ /** * - * Use the config file as created by the + * Use the config file as created by the * {@link CreateEmissionConfig CreateEmissionConfig} to calculate * emissions based on the link leave events of an events file. Resulting emission events are written into an event file. * @@ -54,7 +53,7 @@ public final class RunDetailedEmissionToolOfflineExample{ // private static final String emissionEventOutputFileName = "5.emission.events.offline.xml.gz"; private Config config; - // ======================================================================================================= + // ======================================================================================================= public static void main (String[] args){ RunDetailedEmissionToolOfflineExample emissionToolOfflineExampleV2Vehv1 = new RunDetailedEmissionToolOfflineExample(); @@ -96,7 +95,7 @@ public void install(){ EmissionModule emissionModule = injector.getInstance(EmissionModule.class); - final String outputDirectory = scenario.getConfig().controler().getOutputDirectory(); + final String outputDirectory = scenario.getConfig().controller().getOutputDirectory(); EventWriterXML emissionEventWriter = new EventWriterXML( outputDirectory + RunAverageEmissionToolOfflineExample.emissionEventsFilename ) ; emissionModule.getEmissionEventsManager().addHandler(emissionEventWriter); diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestPositionEmissionModule.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestPositionEmissionModule.java index f67e40f93d9..c48f5254b39 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestPositionEmissionModule.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/TestPositionEmissionModule.java @@ -67,11 +67,11 @@ public void simpleTest() { emissionConfig.setDetailedVsAverageLookupBehavior( EmissionsConfigGroup.DetailedVsAverageLookupBehavior.tryDetailedThenTechnologyAverageThenAverageTable); //This is the previous behaviour var config = ConfigUtils.loadConfig(configFile, emissionConfig); - config.controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists); + config.controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists); config.qsim().setSnapshotPeriod(1); config.qsim().setSnapshotStyle(QSimConfigGroup.SnapshotStyle.queue); - config.controler().setWriteSnapshotsInterval(1); - config.controler().setSnapshotFormat(Set.of(ControllerConfigGroup.SnapshotFormat.positionevents)); + config.controller().setWriteSnapshotsInterval(1); + config.controller().setSnapshotFormat(Set.of(ControllerConfigGroup.SnapshotFormat.positionevents)); var scenario = ScenarioUtils.loadScenario(config); @@ -89,8 +89,8 @@ public void compareToOtherModule_singleVehicleSingleLink() { emissionConfig.setDetailedVsAverageLookupBehavior(EmissionsConfigGroup.DetailedVsAverageLookupBehavior.tryDetailedThenTechnologyAverageThenAverageTable); var config = ConfigUtils.loadConfig(configFile, emissionConfig); - config.controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists); - config.controler().setOutputDirectory(testUtils.getOutputDirectory()); + config.controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists); + config.controller().setOutputDirectory(testUtils.getOutputDirectory()); emissionConfig.setAverageColdEmissionFactorsFile("../sample_41_EFA_ColdStart_vehcat_2020average.csv"); emissionConfig.setAverageWarmEmissionFactorsFile( "../sample_41_EFA_HOT_vehcat_2020average.csv" ); @@ -98,24 +98,24 @@ public void compareToOtherModule_singleVehicleSingleLink() { final ScoringConfigGroup.ActivityParams homeParams = new ScoringConfigGroup.ActivityParams("home") .setTypicalDuration(20); - config.planCalcScore().addActivityParams(homeParams); + config.scoring().addActivityParams(homeParams); final ScoringConfigGroup.ActivityParams workParams = new ScoringConfigGroup.ActivityParams("work") .setTypicalDuration(20); - config.planCalcScore().addActivityParams(workParams); + config.scoring().addActivityParams(workParams); var strategy = new ReplanningConfigGroup.StrategySettings(); strategy.setStrategyName("ChangeExpBeta"); strategy.setWeight(1.0); - config.strategy().addParameterSet(strategy); + config.replanning().addParameterSet(strategy); // activate snapshots config.qsim().setSnapshotPeriod(1); config.qsim().setSnapshotStyle(QSimConfigGroup.SnapshotStyle.queue); - config.controler().setWriteSnapshotsInterval(1); - config.controler().setSnapshotFormat(Set.of(ControllerConfigGroup.SnapshotFormat.positionevents)); - config.controler().setFirstIteration(0); - config.controler().setLastIteration(0); + config.controller().setWriteSnapshotsInterval(1); + config.controller().setSnapshotFormat(Set.of(ControllerConfigGroup.SnapshotFormat.positionevents)); + config.controller().setFirstIteration(0); + config.controller().setLastIteration(0); config.qsim().setVehiclesSource(QSimConfigGroup.VehiclesSource.fromVehiclesData); diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunAverageEmissionToolOfflineExampleIT.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunAverageEmissionToolOfflineExampleIT.java index fbe73cb8d24..5f231f96650 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunAverageEmissionToolOfflineExampleIT.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunAverageEmissionToolOfflineExampleIT.java @@ -30,7 +30,6 @@ import org.matsim.core.utils.io.IOUtils; import org.matsim.examples.ExamplesUtils; import org.matsim.testcases.MatsimTestUtils; -import org.matsim.utils.eventsfilecomparison.EventsFileComparator; import org.matsim.utils.eventsfilecomparison.EventsFileComparator.Result; import java.net.URL; @@ -50,7 +49,7 @@ public final void testAverage_vehTypeV1() { URL scenarioUrl = ExamplesUtils.getTestScenarioURL( "emissions-sampleScenario/testv2_Vehv1" ); URL configUrl = IOUtils.extendUrl( scenarioUrl, "config_average.xml" ); Config config = offlineExample.prepareConfig( new String [] {configUrl.toString()} ); - config.controler().setOutputDirectory(utils.getOutputDirectory()); + config.controller().setOutputDirectory(utils.getOutputDirectory()); EmissionsConfigGroup emissionsConfig = ConfigUtils.addOrGetModule( config, EmissionsConfigGroup.class ); emissionsConfig.setHbefaVehicleDescriptionSource( HbefaVehicleDescriptionSource.fromVehicleTypeDescription ); @@ -71,7 +70,7 @@ public final void testAverage_vehTypeV2() { URL scenarioUrl = ExamplesUtils.getTestScenarioURL( "emissions-sampleScenario/testv2_Vehv2" ); URL configUrl = IOUtils.extendUrl( scenarioUrl, "config_average.xml" ); Config config = offlineExample.prepareConfig( new String [] {configUrl.toString()} ); - config.controler().setOutputDirectory(utils.getOutputDirectory()); + config.controller().setOutputDirectory(utils.getOutputDirectory()); EmissionsConfigGroup emissionsConfig = ConfigUtils.addOrGetModule( config, EmissionsConfigGroup.class ); emissionsConfig.setHbefaVehicleDescriptionSource( HbefaVehicleDescriptionSource.asEngineInformationAttributes ); @@ -98,7 +97,7 @@ public final void testAverage_vehTypeV2b() { URL scenarioUrl = ExamplesUtils.getTestScenarioURL( "emissions-sampleScenario/testv2_Vehv2" ); URL configUrl = IOUtils.extendUrl( scenarioUrl, "config_average.xml" ); Config config = offlineExample.prepareConfig( new String [] {configUrl.toString()} ); - config.controler().setOutputDirectory(utils.getOutputDirectory()); + config.controller().setOutputDirectory(utils.getOutputDirectory()); EmissionsConfigGroup emissionsConfig = ConfigUtils.addOrGetModule( config, EmissionsConfigGroup.class ); emissionsConfig.setHbefaVehicleDescriptionSource( HbefaVehicleDescriptionSource.fromVehicleTypeDescription ); @@ -120,7 +119,7 @@ public final void testAverage_vehTypeV2_HBEFA4() { URL scenarioUrl = ExamplesUtils.getTestScenarioURL( "emissions-sampleScenario/testv2_Vehv2" ); URL configUrl = IOUtils.extendUrl( scenarioUrl, "config_average.xml" ); Config config = offlineExample.prepareConfig( new String [] {configUrl.toString()} ); - config.controler().setOutputDirectory(utils.getOutputDirectory()); + config.controller().setOutputDirectory(utils.getOutputDirectory()); EmissionsConfigGroup emissionsConfig = ConfigUtils.addOrGetModule( config, EmissionsConfigGroup.class ); emissionsConfig.setAverageColdEmissionFactorsFile("../sample_41_EFA_ColdStart_vehcat_2020average.csv"); diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOfflineExampleIT.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOfflineExampleIT.java index 7c8c842941a..35735730695 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOfflineExampleIT.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOfflineExampleIT.java @@ -24,7 +24,6 @@ import org.matsim.contrib.emissions.utils.EmissionsConfigGroup; import org.matsim.contrib.emissions.utils.EmissionsConfigGroup.DetailedVsAverageLookupBehavior; import org.matsim.contrib.emissions.utils.EmissionsConfigGroup.HbefaVehicleDescriptionSource; -import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; import org.matsim.core.utils.io.IOUtils; import org.matsim.examples.ExamplesUtils; @@ -59,7 +58,7 @@ public final void testDetailed_vehTypeV1() { EmissionsConfigGroup emissionsConfig = ConfigUtils.addOrGetModule( config, EmissionsConfigGroup.class ); emissionsConfig.setHbefaVehicleDescriptionSource( HbefaVehicleDescriptionSource.fromVehicleTypeDescription ); emissionsConfig.setDetailedVsAverageLookupBehavior( DetailedVsAverageLookupBehavior.onlyTryDetailedElseAbort ); - config.controler().setOutputDirectory( utils.getOutputDirectory() ); + config.controller().setOutputDirectory( utils.getOutputDirectory() ); offlineExample.run(); } catch (Exception ee ) { @@ -83,7 +82,7 @@ public final void testDetailed_vehTypeV2() { EmissionsConfigGroup emissionsConfig = ConfigUtils.addOrGetModule( config, EmissionsConfigGroup.class ); emissionsConfig.setDetailedVsAverageLookupBehavior( DetailedVsAverageLookupBehavior.onlyTryDetailedElseAbort ); - config.controler().setOutputDirectory(utils.getOutputDirectory()); + config.controller().setOutputDirectory(utils.getOutputDirectory()); offlineExample.run(); } catch (Exception ee ) { @@ -110,7 +109,7 @@ public final void testDetailed_vehTypeV2_HBEFA4() { emissionsConfig.setDetailedColdEmissionFactorsFile("../sample_41_EFA_ColdStart_SubSegm_2020detailed.csv"); emissionsConfig.setDetailedWarmEmissionFactorsFile("../sample_41_EFA_HOT_SubSegm_2020detailed.csv"); - config.controler().setOutputDirectory(utils.getOutputDirectory()); + config.controller().setOutputDirectory(utils.getOutputDirectory()); offlineExample.run(); } catch (Exception ee ) { gotAnException = true ; @@ -135,7 +134,7 @@ public final void testDetailed_vehTypeV1_FallbackToAverage() { var cfUrl = IOUtils.extendUrl( scUrl, "config_detailed.xml" ); var config = offlineExample.prepareConfig( new String [] {cfUrl.toString()} ); - config.controler().setOutputDirectory(utils.getOutputDirectory()); + config.controller().setOutputDirectory(utils.getOutputDirectory()); EmissionsConfigGroup emissionsConfig = ConfigUtils.addOrGetModule( config, EmissionsConfigGroup.class ); emissionsConfig.setAverageColdEmissionFactorsFile("../sample_41_EFA_ColdStart_vehcat_2020average.csv"); @@ -156,7 +155,7 @@ public final void testDetailed_vehTypeV2_FallbackToAverage() { var cfUrl = IOUtils.extendUrl( scUrl, "config_detailed.xml" ); var config = offlineExample.prepareConfig( new String [] {cfUrl.toString()} ); - config.controler().setOutputDirectory(utils.getOutputDirectory()); + config.controller().setOutputDirectory(utils.getOutputDirectory()); EmissionsConfigGroup emissionsConfig = ConfigUtils.addOrGetModule( config, EmissionsConfigGroup.class ); emissionsConfig.setAverageColdEmissionFactorsFile("../sample_41_EFA_ColdStart_vehcat_2020average.csv"); @@ -176,7 +175,7 @@ public final void testDetailed_vehTypeV2_HBEFA4_FallbackToAverage() { var cfUrl = IOUtils.extendUrl( scUrl, "config_detailed.xml" ); var config = offlineExample.prepareConfig( new String [] {cfUrl.toString()} ); - config.controler().setOutputDirectory(utils.getOutputDirectory()); + config.controller().setOutputDirectory(utils.getOutputDirectory()); EmissionsConfigGroup emissionsConfig = ConfigUtils.addOrGetModule( config, EmissionsConfigGroup.class ); emissionsConfig.setDetailedVsAverageLookupBehavior( DetailedVsAverageLookupBehavior.tryDetailedThenTechnologyAverageThenAverageTable ); diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOnlineExampleIT_vehTypeV1.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOnlineExampleIT_vehTypeV1.java index 0315a625693..a762a196a4a 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOnlineExampleIT_vehTypeV1.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOnlineExampleIT_vehTypeV1.java @@ -55,8 +55,8 @@ public final void testDetailed_vehTypeV1() { try { RunDetailedEmissionToolOnlineExample onlineExample = new RunDetailedEmissionToolOnlineExample(); Config config = onlineExample.prepareConfig( new String[]{"./scenarios/sampleScenario/testv2_Vehv1/config_detailed.xml"} ) ; - config.controler().setOutputDirectory( utils.getOutputDirectory() ); - config.controler().setLastIteration( 1 ); + config.controller().setOutputDirectory( utils.getOutputDirectory() ); + config.controller().setLastIteration( 1 ); EmissionsConfigGroup emissionsConfig = ConfigUtils.addOrGetModule( config, EmissionsConfigGroup.class ); emissionsConfig.setHbefaVehicleDescriptionSource( EmissionsConfigGroup.HbefaVehicleDescriptionSource.fromVehicleTypeDescription ); emissionsConfig.setDetailedVsAverageLookupBehavior( EmissionsConfigGroup.DetailedVsAverageLookupBehavior.onlyTryDetailedElseAbort ); diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOnlineExampleIT_vehTypeV1FallbackToAverage.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOnlineExampleIT_vehTypeV1FallbackToAverage.java index 12eed58acea..a046d363371 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOnlineExampleIT_vehTypeV1FallbackToAverage.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOnlineExampleIT_vehTypeV1FallbackToAverage.java @@ -55,8 +55,8 @@ public final void testDetailed_vehTypeV1_FallbackToAverage() { var configUrl = IOUtils.extendUrl( scenarioUrl, "config_detailed.xml" ); Config config = RunDetailedEmissionToolOnlineExample.prepareConfig( new String [] { configUrl.toString() } ); - config.controler().setOutputDirectory( utils.getOutputDirectory() ); - config.controler().setLastIteration( 1 ); + config.controller().setOutputDirectory( utils.getOutputDirectory() ); + config.controller().setLastIteration( 1 ); EmissionsConfigGroup emissionsConfig = ConfigUtils.addOrGetModule( config, EmissionsConfigGroup.class ); emissionsConfig.setHbefaVehicleDescriptionSource( EmissionsConfigGroup.HbefaVehicleDescriptionSource.fromVehicleTypeDescription ); emissionsConfig.setDetailedVsAverageLookupBehavior( diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOnlineExampleIT_vehTypeV2.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOnlineExampleIT_vehTypeV2.java index 42caf0ed295..1a247d71217 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOnlineExampleIT_vehTypeV2.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOnlineExampleIT_vehTypeV2.java @@ -49,8 +49,8 @@ public final void testDetailed_vehTypeV2() { try { RunDetailedEmissionToolOnlineExample onlineExample = new RunDetailedEmissionToolOnlineExample(); Config config = onlineExample.prepareConfig( new String[]{"./scenarios/sampleScenario/testv2_Vehv2/config_detailed.xml"} ) ; - config.controler().setOutputDirectory( utils.getOutputDirectory() ); - config.controler().setLastIteration( 1 ); + config.controller().setOutputDirectory( utils.getOutputDirectory() ); + config.controller().setLastIteration( 1 ); EmissionsConfigGroup emissionsConfig = ConfigUtils.addOrGetModule( config, EmissionsConfigGroup.class ); emissionsConfig.setDetailedVsAverageLookupBehavior( EmissionsConfigGroup.DetailedVsAverageLookupBehavior.onlyTryDetailedElseAbort ); Scenario scenario = onlineExample.prepareScenario( config ) ; diff --git a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOnlineExampleIT_vehTypeV2FallbackToAverage.java b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOnlineExampleIT_vehTypeV2FallbackToAverage.java index 5afbeb1337e..42f65e0010b 100644 --- a/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOnlineExampleIT_vehTypeV2FallbackToAverage.java +++ b/contribs/emissions/src/test/java/org/matsim/contrib/emissions/example/RunDetailedEmissionToolOnlineExampleIT_vehTypeV2FallbackToAverage.java @@ -51,8 +51,8 @@ public final void testDetailed_vehTypeV2_FallbackToAverage() { var configUrl = IOUtils.extendUrl( scenarioUrl, "config_detailed.xml" ); Config config = RunDetailedEmissionToolOnlineExample.prepareConfig( new String [] { configUrl.toString() } ); - config.controler().setOutputDirectory( utils.getOutputDirectory() ); - config.controler().setLastIteration( 1 ); + config.controller().setOutputDirectory( utils.getOutputDirectory() ); + config.controller().setLastIteration( 1 ); EmissionsConfigGroup emissionsConfig = ConfigUtils.addOrGetModule( config, EmissionsConfigGroup.class ); emissionsConfig.setDetailedVsAverageLookupBehavior( DetailedVsAverageLookupBehavior.tryDetailedThenTechnologyAverageThenAverageTable ); //This is the previous behaviour -> Test only passes if falling back to average table :( diff --git a/contribs/ev/src/main/java/org/matsim/contrib/ev/example/RunEvExample.java b/contribs/ev/src/main/java/org/matsim/contrib/ev/example/RunEvExample.java index 698dfe32e5c..406f0e647dc 100644 --- a/contribs/ev/src/main/java/org/matsim/contrib/ev/example/RunEvExample.java +++ b/contribs/ev/src/main/java/org/matsim/contrib/ev/example/RunEvExample.java @@ -23,7 +23,6 @@ import java.io.File; import java.io.IOException; -import java.net.URL; import java.util.Arrays; import org.apache.logging.log4j.LogManager; @@ -32,14 +31,12 @@ import org.matsim.api.core.v01.TransportMode; import org.matsim.contrib.ev.EvConfigGroup; import org.matsim.contrib.ev.EvModule; -import org.matsim.contrib.ev.charging.VehicleChargingHandler; import org.matsim.contrib.ev.routing.EvNetworkRoutingProvider; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; import org.matsim.core.controler.AbstractModule; import org.matsim.core.controler.Controler; import org.matsim.core.controler.OutputDirectoryHierarchy; -import org.matsim.core.mobsim.qsim.AbstractQSimModule; import org.matsim.core.scenario.ScenarioUtils; public class RunEvExample { @@ -66,7 +63,7 @@ public static void main(String[] args) throws IOException { public void run( String[] args ) { Config config = ConfigUtils.loadConfig(args, new EvConfigGroup()); - config.controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists); + config.controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists); Scenario scenario = ScenarioUtils.loadScenario(config); Controler controler = new Controler(scenario); controler.addOverridingModule( new AbstractModule(){ diff --git a/contribs/ev/src/main/java/org/matsim/contrib/ev/example/RunEvExampleWithLTHConsumptionModel.java b/contribs/ev/src/main/java/org/matsim/contrib/ev/example/RunEvExampleWithLTHConsumptionModel.java index 86db1f4478a..15ed10c0627 100644 --- a/contribs/ev/src/main/java/org/matsim/contrib/ev/example/RunEvExampleWithLTHConsumptionModel.java +++ b/contribs/ev/src/main/java/org/matsim/contrib/ev/example/RunEvExampleWithLTHConsumptionModel.java @@ -24,7 +24,6 @@ import java.io.File; import java.io.IOException; -import java.net.URL; import java.util.Arrays; import org.apache.logging.log4j.LogManager; @@ -34,7 +33,6 @@ import org.matsim.api.core.v01.TransportMode; import org.matsim.contrib.ev.EvConfigGroup; import org.matsim.contrib.ev.EvModule; -import org.matsim.contrib.ev.charging.VehicleChargingHandler; import org.matsim.contrib.ev.discharging.AuxEnergyConsumption; import org.matsim.contrib.ev.discharging.DriveEnergyConsumption; import org.matsim.contrib.ev.discharging.VehicleTypeSpecificDriveEnergyConsumptionFactory; @@ -46,7 +44,6 @@ import org.matsim.core.controler.AbstractModule; import org.matsim.core.controler.Controler; import org.matsim.core.controler.OutputDirectoryHierarchy; -import org.matsim.core.mobsim.qsim.AbstractQSimModule; import org.matsim.core.scenario.ScenarioUtils; import org.matsim.vehicles.VehicleType; @@ -79,7 +76,7 @@ public static void main(String[] args) throws IOException { public void run( String[] args ) { Config config = ConfigUtils.loadConfig(args, new EvConfigGroup()); - config.controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists); + config.controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists); // === diff --git a/contribs/ev/src/main/java/org/matsim/contrib/ev/stats/ChargerOccupancyTimeProfileCollectorProvider.java b/contribs/ev/src/main/java/org/matsim/contrib/ev/stats/ChargerOccupancyTimeProfileCollectorProvider.java index ecf41a5fe45..5c13fac0868 100644 --- a/contribs/ev/src/main/java/org/matsim/contrib/ev/stats/ChargerOccupancyTimeProfileCollectorProvider.java +++ b/contribs/ev/src/main/java/org/matsim/contrib/ev/stats/ChargerOccupancyTimeProfileCollectorProvider.java @@ -67,7 +67,7 @@ public MobsimListener get() { }; var collector = new TimeProfileCollector(header, calc, 300, "charger_occupancy_time_profiles", matsimServices); - if (matsimServices.getConfig().controler().isCreateGraphs()) { + if (matsimServices.getConfig().controller().isCreateGraphs()) { collector.setChartTypes(ChartType.Line, ChartType.StackedArea); } else { collector.setChartTypes(); diff --git a/contribs/ev/src/test/java/org/matsim/contrib/ev/temperature/TemperatureChangeModuleIntegrationTest.java b/contribs/ev/src/test/java/org/matsim/contrib/ev/temperature/TemperatureChangeModuleIntegrationTest.java index d5779706334..7c39936e0b6 100644 --- a/contribs/ev/src/test/java/org/matsim/contrib/ev/temperature/TemperatureChangeModuleIntegrationTest.java +++ b/contribs/ev/src/test/java/org/matsim/contrib/ev/temperature/TemperatureChangeModuleIntegrationTest.java @@ -49,7 +49,7 @@ public void testTemperatureChangeModule() { Config config = ConfigUtils.loadConfig(utils.getClassInputDirectory() + "/config.xml", new TemperatureChangeConfigGroup()); - config.controler() + config.controller() .setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists); config.qsim().setSimStarttimeInterpretation(QSimConfigGroup.StarttimeInterpretation.onlyUseStarttime); Scenario scenario = ScenarioUtils.loadScenario(config); diff --git a/contribs/freight/src/main/java/org/matsim/contrib/freight/controler/CarrierModule.java b/contribs/freight/src/main/java/org/matsim/contrib/freight/controler/CarrierModule.java index 325e82b5fe6..2e4a2980780 100644 --- a/contribs/freight/src/main/java/org/matsim/contrib/freight/controler/CarrierModule.java +++ b/contribs/freight/src/main/java/org/matsim/contrib/freight/controler/CarrierModule.java @@ -138,7 +138,7 @@ private static class CarrierScoringFunctionFactoryDummyImpl implements CarrierSc private static void writeAdditionalRunOutput( OutputDirectoryHierarchy controllerIO, Config config, Carriers carriers ) { // ### some final output: ### - String compression = config.controler().getCompressionType().fileEnding; + String compression = config.controller().getCompressionType().fileEnding; new CarrierPlanWriter(carriers).write( controllerIO.getOutputFilename("output_carriers.xml" + compression)); new CarrierVehicleTypeWriter(CarrierVehicleTypes.getVehicleTypes(carriers)).write(controllerIO.getOutputFilename("output_carriersVehicleTypes.xml" + compression)); } diff --git a/contribs/freight/src/main/java/org/matsim/contrib/freight/usecases/analysis/CarrierScoreStats.java b/contribs/freight/src/main/java/org/matsim/contrib/freight/usecases/analysis/CarrierScoreStats.java index 12fdd2fdacb..4f046a93987 100644 --- a/contribs/freight/src/main/java/org/matsim/contrib/freight/usecases/analysis/CarrierScoreStats.java +++ b/contribs/freight/src/main/java/org/matsim/contrib/freight/usecases/analysis/CarrierScoreStats.java @@ -100,8 +100,8 @@ public void notifyStartup(final StartupEvent event) { } catch (IOException e) { throw new UncheckedIOException(e); } - this.minIteration = event.getServices().getConfig().controler().getFirstIteration(); - int maxIter = event.getServices().getConfig().controler().getLastIteration(); + this.minIteration = event.getServices().getConfig().controller().getFirstIteration(); + int maxIter = event.getServices().getConfig().controller().getLastIteration(); int iterations = maxIter - this.minIteration; if (iterations > 5000) iterations = 5000; // limit the history size this.history = new double[4][iterations+1]; diff --git a/contribs/freight/src/main/java/org/matsim/contrib/freight/usecases/chessboard/RunChessboard.java b/contribs/freight/src/main/java/org/matsim/contrib/freight/usecases/chessboard/RunChessboard.java index a7f4ceb2f69..bf3d2682ef1 100644 --- a/contribs/freight/src/main/java/org/matsim/contrib/freight/usecases/chessboard/RunChessboard.java +++ b/contribs/freight/src/main/java/org/matsim/contrib/freight/usecases/chessboard/RunChessboard.java @@ -60,8 +60,8 @@ public static void main(String[] args){ Config config; if ( args ==null || args.length==0 || args[0]==null ){ config = ConfigUtils.loadConfig( IOUtils.extendUrl( ExamplesUtils.getTestScenarioURL( "freight-chessboard-9x9" ), "config.xml" ) ); - config.controler().setLastIteration( 1 ); - config.controler().setOverwriteFileSetting( OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists ); + config.controller().setLastIteration( 1 ); + config.controller().setOverwriteFileSetting( OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists ); } else { config = ConfigUtils.loadConfig( args ); } @@ -93,7 +93,7 @@ public void install() { final LegHistogram withoutFreight = new LegHistogram(900); addEventHandlerBinding().toInstance(withoutFreight); - addControlerListenerBinding().toInstance( new CarrierScoreStats(carriers, config.controler().getOutputDirectory() +"/carrier_scores", true) ); + addControlerListenerBinding().toInstance( new CarrierScoreStats(carriers, config.controller().getOutputDirectory() +"/carrier_scores", true) ); addControlerListenerBinding().toInstance( new IterationEndsListener() { @Inject private OutputDirectoryHierarchy controlerIO; diff --git a/contribs/freight/src/main/java/org/matsim/contrib/freight/usecases/chessboard/RunPassengerAlongWithCarriers.java b/contribs/freight/src/main/java/org/matsim/contrib/freight/usecases/chessboard/RunPassengerAlongWithCarriers.java index 2934ba58ca9..542c3add849 100644 --- a/contribs/freight/src/main/java/org/matsim/contrib/freight/usecases/chessboard/RunPassengerAlongWithCarriers.java +++ b/contribs/freight/src/main/java/org/matsim/contrib/freight/usecases/chessboard/RunPassengerAlongWithCarriers.java @@ -102,9 +102,9 @@ public void run() { public final Config prepareConfig() { Config config = ConfigUtils.loadConfig(IOUtils.extendUrl(url, "config.xml")); - config.controler().setOverwriteFileSetting( OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles ); + config.controller().setOverwriteFileSetting( OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles ); config.global().setRandomSeed(4177); - config.controler().setOutputDirectory("./output/"); + config.controller().setOutputDirectory("./output/"); return config; } @@ -123,7 +123,7 @@ private static void prepareFreightOutputDataAndStats(Scenario scenario, EventsMa final LegHistogram withoutFreight = new LegHistogram(900); withoutFreight.setPopulation(scenario.getPopulation()); - CarrierScoreStats scores = new CarrierScoreStats(carriers, scenario.getConfig().controler().getOutputDirectory()+ "carrier_scores", true); + CarrierScoreStats scores = new CarrierScoreStats(carriers, scenario.getConfig().controller().getOutputDirectory()+ "carrier_scores", true); eventsManager.addHandler(withoutFreight); eventsManager.addHandler(freightOnly); diff --git a/contribs/freight/src/main/java/org/matsim/contrib/freight/usecases/chessboard/RunPassengerPlansFromScratch.java b/contribs/freight/src/main/java/org/matsim/contrib/freight/usecases/chessboard/RunPassengerPlansFromScratch.java index b62382737da..33b0e6d89d0 100644 --- a/contribs/freight/src/main/java/org/matsim/contrib/freight/usecases/chessboard/RunPassengerPlansFromScratch.java +++ b/contribs/freight/src/main/java/org/matsim/contrib/freight/usecases/chessboard/RunPassengerPlansFromScratch.java @@ -40,13 +40,13 @@ public static void main(String[] args) { ActivityParams workParams = new ActivityParams("work"); workParams.setTypicalDuration(60 * 60 * 8); - config.planCalcScore().addActivityParams(workParams); + config.scoring().addActivityParams(workParams); ActivityParams homeParams = new ActivityParams("home"); homeParams.setTypicalDuration(16 * 60 * 60); - config.planCalcScore().addActivityParams(homeParams); + config.scoring().addActivityParams(homeParams); config.global().setCoordinateSystem("EPSG:32632"); - config.controler().setFirstIteration(0); - config.controler().setLastIteration(2); + config.controller().setFirstIteration(0); + config.controller().setLastIteration(2); config.network().setInputFile(NETWORK_FILENAME); config.plans().setInputFile(PLANS_FILENAME); @@ -59,15 +59,15 @@ public static void main(String[] args) { reRoute.setWeight(0.5); // reRoute.setDisableAfter(300); - config.strategy().setMaxAgentPlanMemorySize(5); - config.strategy().addStrategySettings(bestScore); - config.strategy().addStrategySettings(reRoute); + config.replanning().setMaxAgentPlanMemorySize(5); + config.replanning().addStrategySettings(bestScore); + config.replanning().addStrategySettings(reRoute); // Controler controler = new Controler(config); - controler.getConfig().controler().setWriteEventsInterval(1); - controler.getConfig().controler().setCreateGraphs(false); + controler.getConfig().controller().setWriteEventsInterval(1); + controler.getConfig().controller().setCreateGraphs(false); //Select how to react of not empty output directory - controler.getConfig().controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles); + controler.getConfig().controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles); // controler.getConfig().controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.failIfDirectoryExists); controler.run(); diff --git a/contribs/freight/src/test/java/org/matsim/contrib/freight/carrier/CarrierModuleTest.java b/contribs/freight/src/test/java/org/matsim/contrib/freight/carrier/CarrierModuleTest.java index 8ea974fa096..0602fa8d545 100644 --- a/contribs/freight/src/test/java/org/matsim/contrib/freight/carrier/CarrierModuleTest.java +++ b/contribs/freight/src/test/java/org/matsim/contrib/freight/carrier/CarrierModuleTest.java @@ -52,19 +52,19 @@ public void setUp(){ Config config = ConfigUtils.createConfig() ; ScoringConfigGroup.ActivityParams workParams = new ScoringConfigGroup.ActivityParams("w"); workParams.setTypicalDuration(60 * 60 * 8); - config.planCalcScore().addActivityParams(workParams); + config.scoring().addActivityParams(workParams); ScoringConfigGroup.ActivityParams homeParams = new ScoringConfigGroup.ActivityParams("h"); homeParams.setTypicalDuration(16 * 60 * 60); - config.planCalcScore().addActivityParams(homeParams); + config.scoring().addActivityParams(homeParams); config.global().setCoordinateSystem("EPSG:32632"); - config.controler().setFirstIteration(0); - config.controler().setLastIteration(0); - config.controler().setOutputDirectory(testUtils.getOutputDirectory()); + config.controller().setFirstIteration(0); + config.controller().setLastIteration(0); + config.controller().setOutputDirectory(testUtils.getOutputDirectory()); config.network().setInputFile( testUtils.getClassInputDirectory() + "network.xml" ); config.plans().setInputFile( testUtils.getClassInputDirectory() + "plans100.xml" ); - config.controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles); - config.controler().setWritePlansInterval(1); - config.controler().setCreateGraphs(false); + config.controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles); + config.controller().setWritePlansInterval(1); + config.controller().setCreateGraphs(false); freightConfigGroup = ConfigUtils.addOrGetModule( config, FreightConfigGroup.class ) ; freightConfigGroup.setCarriersFile( testUtils.getClassInputDirectory() + "carrierPlansEquils.xml"); freightConfigGroup.setCarriersVehicleTypesFile( testUtils.getClassInputDirectory() + "vehicleTypes.xml"); diff --git a/contribs/freight/src/test/java/org/matsim/contrib/freight/controler/EquilWithCarrierWithPersonsIT.java b/contribs/freight/src/test/java/org/matsim/contrib/freight/controler/EquilWithCarrierWithPersonsIT.java index b96a6f75553..4741b7de8fa 100644 --- a/contribs/freight/src/test/java/org/matsim/contrib/freight/controler/EquilWithCarrierWithPersonsIT.java +++ b/contribs/freight/src/test/java/org/matsim/contrib/freight/controler/EquilWithCarrierWithPersonsIT.java @@ -47,13 +47,13 @@ public class EquilWithCarrierWithPersonsIT { static Config commonConfig( MatsimTestUtils testUtils ) { Config config = ConfigUtils.createConfig(); - config.planCalcScore().addActivityParams( new ActivityParams("w").setTypicalDuration(60 * 60 * 8 ) ); - config.planCalcScore().addActivityParams( new ActivityParams("h").setTypicalDuration(16 * 60 * 60 ) ); + config.scoring().addActivityParams( new ActivityParams("w").setTypicalDuration(60 * 60 * 8 ) ); + config.scoring().addActivityParams( new ActivityParams("h").setTypicalDuration(16 * 60 * 60 ) ); config.global().setCoordinateSystem("EPSG:32632"); - config.controler().setFirstIteration(0); - config.controler().setLastIteration(2); + config.controller().setFirstIteration(0); + config.controller().setLastIteration(2); - config.controler().setOutputDirectory(testUtils.getOutputDirectory()); + config.controller().setOutputDirectory(testUtils.getOutputDirectory()); config.network().setInputFile( testUtils.getClassInputDirectory() + "network.xml" ); return config; @@ -64,9 +64,9 @@ public void setUp(){ Config config = commonConfig( testUtils ); config.plans().setInputFile( testUtils.getClassInputDirectory() + "plans100.xml" ); - config.strategy().setMaxAgentPlanMemorySize(5); - config.strategy().addStrategySettings( new StrategySettings().setStrategyName("BestScore" ).setWeight(1.0 ) ); - config.strategy().addStrategySettings( new StrategySettings().setStrategyName("ReRoute" ).setWeight(0.0 ).setDisableAfter(300 ) ); + config.replanning().setMaxAgentPlanMemorySize(5); + config.replanning().addStrategySettings( new StrategySettings().setStrategyName("BestScore" ).setWeight(1.0 ) ); + config.replanning().addStrategySettings( new StrategySettings().setStrategyName("ReRoute" ).setWeight(0.0 ).setDisableAfter(300 ) ); Scenario scenario = commonScenario( config, testUtils ); diff --git a/contribs/freight/src/test/java/org/matsim/contrib/freight/jsprit/DistanceConstraintFromVehiclesFileTest.java b/contribs/freight/src/test/java/org/matsim/contrib/freight/jsprit/DistanceConstraintFromVehiclesFileTest.java index e0c70e41e09..acd6613d0c4 100644 --- a/contribs/freight/src/test/java/org/matsim/contrib/freight/jsprit/DistanceConstraintFromVehiclesFileTest.java +++ b/contribs/freight/src/test/java/org/matsim/contrib/freight/jsprit/DistanceConstraintFromVehiclesFileTest.java @@ -81,7 +81,7 @@ public class DistanceConstraintFromVehiclesFileTest { public final void CarrierSmallBatteryTest_Version1() throws ExecutionException, InterruptedException { Config config = ConfigUtils.createConfig(); - config.controler().setOutputDirectory(testUtils.getOutputDirectory()); + config.controller().setOutputDirectory(testUtils.getOutputDirectory()); prepareConfig(config); Scenario scenario = ScenarioUtils.loadScenario(config); @@ -154,7 +154,7 @@ public final void CarrierSmallBatteryTest_Version1() throws ExecutionException, @Test public final void CarrierLargeBatteryTest_Version2() throws ExecutionException, InterruptedException { Config config = ConfigUtils.createConfig(); - config.controler().setOutputDirectory(testUtils.getOutputDirectory()); + config.controller().setOutputDirectory(testUtils.getOutputDirectory()); prepareConfig(config); Scenario scenario = ScenarioUtils.loadScenario(config); @@ -230,7 +230,7 @@ public final void CarrierLargeBatteryTest_Version2() throws ExecutionException, @Test public final void Carrier2SmallBatteryTest_Version3() throws ExecutionException, InterruptedException { Config config = ConfigUtils.createConfig(); - config.controler().setOutputDirectory(testUtils.getOutputDirectory()); + config.controller().setOutputDirectory(testUtils.getOutputDirectory()); prepareConfig(config); Scenario scenario = ScenarioUtils.loadScenario(config); @@ -311,7 +311,7 @@ public final void Carrier2SmallBatteryTest_Version3() throws ExecutionException, @Test public final void CarrierWithAdditionalDieselVehicleTest_Version4() throws ExecutionException, InterruptedException { Config config = ConfigUtils.createConfig(); - config.controler().setOutputDirectory(testUtils.getOutputDirectory()); + config.controller().setOutputDirectory(testUtils.getOutputDirectory()); prepareConfig(config); Scenario scenario = ScenarioUtils.loadScenario(config); @@ -391,14 +391,14 @@ else if (thisTypeId.equals("DieselVehicle")) */ private void prepareConfig(Config config) { config.network().setInputFile(IOUtils.extendUrl(SCENARIO_URL, "grid9x9.xml").toString()); - config.controler().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); - new OutputDirectoryHierarchy(config.controler().getOutputDirectory(), config.controler().getRunId(), - config.controler().getOverwriteFileSetting(), CompressionType.gzip); - config.controler().setOverwriteFileSetting(OverwriteFileSetting.overwriteExistingFiles); + config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); + new OutputDirectoryHierarchy(config.controller().getOutputDirectory(), config.controller().getRunId(), + config.controller().getOverwriteFileSetting(), CompressionType.gzip); + config.controller().setOverwriteFileSetting(OverwriteFileSetting.overwriteExistingFiles); - config.controler().setLastIteration(0); + config.controller().setLastIteration(0); config.global().setRandomSeed(4177); - config.controler().setOverwriteFileSetting(OverwriteFileSetting.overwriteExistingFiles); + config.controller().setOverwriteFileSetting(OverwriteFileSetting.overwriteExistingFiles); FreightConfigGroup freightConfigGroup = ConfigUtils.addOrGetModule(config, FreightConfigGroup.class); freightConfigGroup.setUseDistanceConstraintForTourPlanning(UseDistanceConstraintForTourPlanning.basedOnEnergyConsumption); diff --git a/contribs/freight/src/test/java/org/matsim/contrib/freight/jsprit/DistanceConstraintTest.java b/contribs/freight/src/test/java/org/matsim/contrib/freight/jsprit/DistanceConstraintTest.java index 1ca39718e22..fd47350bfb5 100644 --- a/contribs/freight/src/test/java/org/matsim/contrib/freight/jsprit/DistanceConstraintTest.java +++ b/contribs/freight/src/test/java/org/matsim/contrib/freight/jsprit/DistanceConstraintTest.java @@ -83,7 +83,7 @@ public class DistanceConstraintTest { public final void CarrierSmallBatteryTest_Version1() throws ExecutionException, InterruptedException { Config config = ConfigUtils.createConfig(); - config.controler().setOutputDirectory(testUtils.getOutputDirectory()); + config.controller().setOutputDirectory(testUtils.getOutputDirectory()); prepareConfig(config); Scenario scenario = ScenarioUtils.loadScenario(config); @@ -161,7 +161,7 @@ public final void CarrierSmallBatteryTest_Version1() throws ExecutionException, @Test public final void CarrierLargeBatteryTest_Version2() throws ExecutionException, InterruptedException { Config config = ConfigUtils.createConfig(); - config.controler().setOutputDirectory(testUtils.getOutputDirectory()); + config.controller().setOutputDirectory(testUtils.getOutputDirectory()); prepareConfig(config); Scenario scenario = ScenarioUtils.loadScenario(config); @@ -243,7 +243,7 @@ public final void CarrierLargeBatteryTest_Version2() throws ExecutionException, @Test public final void Carrier2SmallBatteryTest_Version3() throws ExecutionException, InterruptedException { Config config = ConfigUtils.createConfig(); - config.controler().setOutputDirectory(testUtils.getOutputDirectory()); + config.controller().setOutputDirectory(testUtils.getOutputDirectory()); prepareConfig(config); Scenario scenario = ScenarioUtils.loadScenario(config); @@ -333,7 +333,7 @@ public final void Carrier2SmallBatteryTest_Version3() throws ExecutionException, @Test public final void CarrierWithAdditionalDieselVehicleTest_Version4() throws ExecutionException, InterruptedException { Config config = ConfigUtils.createConfig(); - config.controler().setOutputDirectory(testUtils.getOutputDirectory()); + config.controller().setOutputDirectory(testUtils.getOutputDirectory()); prepareConfig(config); Scenario scenario = ScenarioUtils.loadScenario(config); @@ -432,7 +432,7 @@ else if (thisTypeId.equals("DieselVehicle")) @Test public final void CarrierWithShipmentsMidSizeBatteryTest_Version5() throws ExecutionException, InterruptedException { Config config = ConfigUtils.createConfig(); - config.controler().setOutputDirectory(testUtils.getOutputDirectory()); + config.controller().setOutputDirectory(testUtils.getOutputDirectory()); prepareConfig(config); Scenario scenario = ScenarioUtils.loadScenario(config); @@ -511,7 +511,7 @@ public final void CarrierWithShipmentsMidSizeBatteryTest_Version5() throws Execu @Test public final void CarrierWithShipmentsLargeBatteryTest_Version6() throws ExecutionException, InterruptedException { Config config = ConfigUtils.createConfig(); - config.controler().setOutputDirectory(testUtils.getOutputDirectory()); + config.controller().setOutputDirectory(testUtils.getOutputDirectory()); prepareConfig(config); Scenario scenario = ScenarioUtils.loadScenario(config); @@ -583,14 +583,14 @@ public final void CarrierWithShipmentsLargeBatteryTest_Version6() throws Executi */ static void prepareConfig(Config config) { config.network().setInputFile(IOUtils.extendUrl(SCENARIO_URL, "grid9x9.xml").toString()); - config.controler().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); - new OutputDirectoryHierarchy(config.controler().getOutputDirectory(), config.controler().getRunId(), - config.controler().getOverwriteFileSetting(), CompressionType.gzip); - config.controler().setOverwriteFileSetting(OverwriteFileSetting.overwriteExistingFiles); + config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); + new OutputDirectoryHierarchy(config.controller().getOutputDirectory(), config.controller().getRunId(), + config.controller().getOverwriteFileSetting(), CompressionType.gzip); + config.controller().setOverwriteFileSetting(OverwriteFileSetting.overwriteExistingFiles); - config.controler().setLastIteration(0); + config.controller().setLastIteration(0); config.global().setRandomSeed(4177); - config.controler().setOverwriteFileSetting(OverwriteFileSetting.overwriteExistingFiles); + config.controller().setOverwriteFileSetting(OverwriteFileSetting.overwriteExistingFiles); FreightConfigGroup freightConfigGroup = ConfigUtils.addOrGetModule(config, FreightConfigGroup.class); freightConfigGroup.setUseDistanceConstraintForTourPlanning(UseDistanceConstraintForTourPlanning.basedOnEnergyConsumption); diff --git a/contribs/freight/src/test/java/org/matsim/contrib/freight/usecases/chessboard/RunPassengerAlongWithCarriersIT.java b/contribs/freight/src/test/java/org/matsim/contrib/freight/usecases/chessboard/RunPassengerAlongWithCarriersIT.java index c5dc01247e7..062ceb5a5d4 100644 --- a/contribs/freight/src/test/java/org/matsim/contrib/freight/usecases/chessboard/RunPassengerAlongWithCarriersIT.java +++ b/contribs/freight/src/test/java/org/matsim/contrib/freight/usecases/chessboard/RunPassengerAlongWithCarriersIT.java @@ -7,7 +7,7 @@ import org.matsim.testcases.MatsimTestUtils; public class RunPassengerAlongWithCarriersIT { - + @Rule public MatsimTestUtils utils = new MatsimTestUtils() ; @@ -17,8 +17,8 @@ public void runChessboard() { RunPassengerAlongWithCarriers abc = new RunPassengerAlongWithCarriers(); // --- Config config = abc.prepareConfig(); - config.controler().setLastIteration( 1 ); - config.controler().setOutputDirectory( utils.getOutputDirectory() ); + config.controller().setLastIteration( 1 ); + config.controller().setOutputDirectory( utils.getOutputDirectory() ); // --- abc.run(); } catch (Exception ee ) { diff --git a/contribs/freight/src/test/java/org/matsim/contrib/freight/utils/FreightUtilsTest.java b/contribs/freight/src/test/java/org/matsim/contrib/freight/utils/FreightUtilsTest.java index b01f8560bf2..fd09806762e 100644 --- a/contribs/freight/src/test/java/org/matsim/contrib/freight/utils/FreightUtilsTest.java +++ b/contribs/freight/src/test/java/org/matsim/contrib/freight/utils/FreightUtilsTest.java @@ -410,7 +410,7 @@ public void testAddServiceSkill(){ @Test public void testRunJsprit_allInformationGiven(){ Config config = prepareConfig(); - config.controler().setOutputDirectory(utils.getOutputDirectory()); + config.controller().setOutputDirectory(utils.getOutputDirectory()); URL scenarioUrl = ExamplesUtils.getTestScenarioURL( "freight-chessboard-9x9" ) ; String vraFile= IOUtils.extendUrl(scenarioUrl, "algorithm_v2.xml" ).toString(); @@ -439,7 +439,7 @@ public void testRunJsprit_allInformationGiven(){ @Test(expected = java.util.concurrent.ExecutionException.class) public void testRunJsprit_NoOfJspritIterationsMissing() throws ExecutionException, InterruptedException { Config config = prepareConfig(); - config.controler().setOutputDirectory(utils.getOutputDirectory()); + config.controller().setOutputDirectory(utils.getOutputDirectory()); Scenario scenario = ScenarioUtils.loadScenario(config); FreightUtils.loadCarriersAccordingToFreightConfig(scenario); @@ -459,7 +459,7 @@ public void testRunJsprit_NoOfJspritIterationsMissing() throws ExecutionExceptio @Test public void testRunJsprit_NoAlgortihmFileGiven(){ Config config = prepareConfig(); - config.controler().setOutputDirectory(utils.getOutputDirectory()); + config.controller().setOutputDirectory(utils.getOutputDirectory()); Scenario scenario = ScenarioUtils.loadScenario(config); FreightUtils.loadCarriersAccordingToFreightConfig(scenario); @@ -474,7 +474,7 @@ public void testRunJsprit_NoAlgortihmFileGiven(){ private Config prepareConfig(){ URL scenarioUrl = ExamplesUtils.getTestScenarioURL( "freight-chessboard-9x9" ) ; Config config = ConfigUtils.loadConfig(IOUtils.extendUrl(scenarioUrl, "config.xml" ) ); - config.controler().setLastIteration(0); + config.controller().setLastIteration(0); config.plans().setActivityDurationInterpretation(PlansConfigGroup.ActivityDurationInterpretation.tryEndTimeThenDuration ); //freight configstuff FreightConfigGroup freightConfigGroup = ConfigUtils.addOrGetModule(config, FreightConfigGroup.class); diff --git a/contribs/freightreceiver/src/main/java/org/matsim/contrib/freightreceiver/ReceiverControlerListener.java b/contribs/freightreceiver/src/main/java/org/matsim/contrib/freightreceiver/ReceiverControlerListener.java index 698bd61b5d7..dc3d95d4a82 100644 --- a/contribs/freightreceiver/src/main/java/org/matsim/contrib/freightreceiver/ReceiverControlerListener.java +++ b/contribs/freightreceiver/src/main/java/org/matsim/contrib/freightreceiver/ReceiverControlerListener.java @@ -165,7 +165,7 @@ private void linkReceiverTimeWindowToCarrierTourPosition() throws IOException { receiverLinkMap.put(linkId, receiver); } - try (BufferedWriter bw = IOUtils.getBufferedWriter(this.sc.getConfig().controler().getOutputDirectory() + "output_receiverInTourPlacement.csv.gz")) { + try (BufferedWriter bw = IOUtils.getBufferedWriter(this.sc.getConfig().controller().getOutputDirectory() + "output_receiverInTourPlacement.csv.gz")) { bw.write("receiverId,twStart,twEnd,twDuration,positionInTour,product,deliveryStart,deliveryEnd"); bw.newLine(); diff --git a/contribs/freightreceiver/src/main/java/org/matsim/contrib/freightreceiver/ReceiverScoreStats.java b/contribs/freightreceiver/src/main/java/org/matsim/contrib/freightreceiver/ReceiverScoreStats.java index 8e9d8c3de75..d6e806c3f24 100644 --- a/contribs/freightreceiver/src/main/java/org/matsim/contrib/freightreceiver/ReceiverScoreStats.java +++ b/contribs/freightreceiver/src/main/java/org/matsim/contrib/freightreceiver/ReceiverScoreStats.java @@ -58,7 +58,7 @@ public ReceiverScoreStats() throws UncheckedIOException { @Override public void notifyStartup(final StartupEvent event) { - String fileName = sc.getConfig().controler().getOutputDirectory() + ReceiverUtils.FILENAME_RECEIVER_SCORES; + String fileName = sc.getConfig().controller().getOutputDirectory() + ReceiverUtils.FILENAME_RECEIVER_SCORES; if (fileName.toLowerCase(Locale.ROOT).endsWith(".txt")) { this.out = IOUtils.getBufferedWriter(fileName); } else { @@ -69,8 +69,8 @@ public void notifyStartup(final StartupEvent event) { } catch (IOException e) { throw new UncheckedIOException(e); } - this.minIteration = event.getServices().getConfig().controler().getFirstIteration(); - int maxIter = event.getServices().getConfig().controler().getLastIteration(); + this.minIteration = event.getServices().getConfig().controller().getFirstIteration(); + int maxIter = event.getServices().getConfig().controller().getLastIteration(); int iterations = maxIter - this.minIteration; if (iterations > 5000) iterations = 5000; // limit the history size this.history = new double[4][iterations + 1]; @@ -97,7 +97,7 @@ public void notifyIterationEnds(final IterationEndsEvent event) { } private void writeIterationScores(IterationEndsEvent event) { - String fileName = sc.getConfig().controler().getOutputDirectory() + ReceiverUtils.FILENAME_RECEIVER_SCORES; + String fileName = sc.getConfig().controller().getOutputDirectory() + ReceiverUtils.FILENAME_RECEIVER_SCORES; double sumScoreWorst = 0.0; double sumScoreBest = 0.0; @@ -228,7 +228,7 @@ public void notifyShutdown(final ShutdownEvent controlerShudownEvent) { } static void writeHeadings(Scenario sc) { - try(BufferedWriter bw = IOUtils.getBufferedWriter(sc.getConfig().controler().getOutputDirectory() + RECEIVER_STATS_CSV)) { + try(BufferedWriter bw = IOUtils.getBufferedWriter(sc.getConfig().controller().getOutputDirectory() + RECEIVER_STATS_CSV)) { bw.write(String.format("%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s", "iteration", "receiver_id", @@ -264,7 +264,7 @@ private void recordReceiverStats(IterationEndsEvent event) { boolean member = (boolean) receiver.getAttributes().getAttribute(CollaborationUtils.ATTR_GRANDCOALITION_MEMBER); - try (BufferedWriter bw1 = IOUtils.getAppendingBufferedWriter(sc.getConfig().controler().getOutputDirectory() + RECEIVER_STATS_CSV)) { + try (BufferedWriter bw1 = IOUtils.getAppendingBufferedWriter(sc.getConfig().controller().getOutputDirectory() + RECEIVER_STATS_CSV)) { bw1.write(String.format("%d,%s,%s,%f,%f,%f,%s,%f,%f,%f,%b,%b", event.getIteration(), receiver.getId(), diff --git a/contribs/freightreceiver/src/main/java/org/matsim/contrib/freightreceiver/ReceiverTriggersCarrierReplanningListener.java b/contribs/freightreceiver/src/main/java/org/matsim/contrib/freightreceiver/ReceiverTriggersCarrierReplanningListener.java index b5c5fa34062..ada89ad47ed 100644 --- a/contribs/freightreceiver/src/main/java/org/matsim/contrib/freightreceiver/ReceiverTriggersCarrierReplanningListener.java +++ b/contribs/freightreceiver/src/main/java/org/matsim/contrib/freightreceiver/ReceiverTriggersCarrierReplanningListener.java @@ -119,7 +119,7 @@ public void notifyIterationStarts(IterationStartsEvent event) { carrier.setSelectedPlan(newPlan); } - String outputdirectory = sc.getConfig().controler().getOutputDirectory(); + String outputdirectory = sc.getConfig().controller().getOutputDirectory(); outputdirectory += outputdirectory.endsWith("/") ? "" : "/"; // new CarrierPlanWriter(FreightUtils.getCarriers(sc)).write(outputdirectory + ReceiverConfigGroup.CARRIERS_FILE); new CarrierPlanWriter(FreightUtils.getCarriers(sc)).write(outputdirectory +receiverConfig.getCarriersFile() ); diff --git a/contribs/freightreceiver/src/main/java/org/matsim/contrib/freightreceiver/replanning/OrderFrequencyStrategyManager.java b/contribs/freightreceiver/src/main/java/org/matsim/contrib/freightreceiver/replanning/OrderFrequencyStrategyManager.java index 97af3b36976..f74750d9924 100644 --- a/contribs/freightreceiver/src/main/java/org/matsim/contrib/freightreceiver/replanning/OrderFrequencyStrategyManager.java +++ b/contribs/freightreceiver/src/main/java/org/matsim/contrib/freightreceiver/replanning/OrderFrequencyStrategyManager.java @@ -41,7 +41,7 @@ public ReceiverStrategyManager get() { GenericPlanStrategyImpl strategy = new GenericPlanStrategyImpl<>( new ExpBetaPlanChanger.Factory().setBetaValue(10.0).build() ); strategy.addStrategyModule(new OrderSizeMutator(true)); strategyManager.addStrategy(strategy, null, 0.15); - strategyManager.addChangeRequest((int) (sc.getConfig().controler().getLastIteration()*0.9), strategy, null, 0.0); + strategyManager.addChangeRequest((int) (sc.getConfig().controller().getLastIteration()*0.9), strategy, null, 0.0); } /* @@ -52,7 +52,7 @@ public ReceiverStrategyManager get() { GenericPlanStrategyImpl strategy = new GenericPlanStrategyImpl<>( new ExpBetaPlanChanger.Factory().setBetaValue(10.0).build() ); strategy.addStrategyModule(new OrderSizeMutator(false)); strategyManager.addStrategy(strategy, null, 0.15); - strategyManager.addChangeRequest((int) (sc.getConfig().controler().getLastIteration()*0.9), strategy, null, 0.0); + strategyManager.addChangeRequest((int) (sc.getConfig().controller().getLastIteration()*0.9), strategy, null, 0.0); } /* Replanning for grand coalition receivers. TODO Removed for now. */ diff --git a/contribs/freightreceiver/src/main/java/org/matsim/contrib/freightreceiver/replanning/ServiceTimeStrategyManagerProvider.java b/contribs/freightreceiver/src/main/java/org/matsim/contrib/freightreceiver/replanning/ServiceTimeStrategyManagerProvider.java index 8e2b3f4c8c7..6271e402b57 100644 --- a/contribs/freightreceiver/src/main/java/org/matsim/contrib/freightreceiver/replanning/ServiceTimeStrategyManagerProvider.java +++ b/contribs/freightreceiver/src/main/java/org/matsim/contrib/freightreceiver/replanning/ServiceTimeStrategyManagerProvider.java @@ -39,7 +39,7 @@ public ReceiverStrategyManager get() { GenericPlanStrategyImpl increaseStrategy = new GenericPlanStrategyImpl<>(new ExpBetaPlanChanger.Factory().build()); increaseStrategy.addStrategyModule(new ServiceTimeMutator(Time.parseTime("0:15:00"), Time.parseTime("04:00:00"), true)); strategyManager.addStrategy(increaseStrategy, null, 0.15); - strategyManager.addChangeRequest((int) (sc.getConfig().controler().getLastIteration() * 0.9), increaseStrategy, null, 0.0); + strategyManager.addChangeRequest((int) (sc.getConfig().controller().getLastIteration() * 0.9), increaseStrategy, null, 0.0); } { @@ -48,7 +48,7 @@ public ReceiverStrategyManager get() { GenericPlanStrategyImpl decreaseStrategy = new GenericPlanStrategyImpl<>(new ExpBetaPlanChanger.Factory().build()); decreaseStrategy.addStrategyModule(new ServiceTimeMutator(Time.parseTime("00:15:00"), Time.parseTime("01:00:00"), false)); strategyManager.addStrategy(decreaseStrategy, null, 0.15); - strategyManager.addChangeRequest((int) (sc.getConfig().controler().getLastIteration() * 0.9), decreaseStrategy, null, 0.0); + strategyManager.addChangeRequest((int) (sc.getConfig().controller().getLastIteration() * 0.9), decreaseStrategy, null, 0.0); } /* Replanning for grand coalition receivers.*/ diff --git a/contribs/freightreceiver/src/main/java/org/matsim/contrib/freightreceiver/replanning/TimeWindowStrategyManagerFactory.java b/contribs/freightreceiver/src/main/java/org/matsim/contrib/freightreceiver/replanning/TimeWindowStrategyManagerFactory.java index c4d789e1ee2..e19d1437dc0 100644 --- a/contribs/freightreceiver/src/main/java/org/matsim/contrib/freightreceiver/replanning/TimeWindowStrategyManagerFactory.java +++ b/contribs/freightreceiver/src/main/java/org/matsim/contrib/freightreceiver/replanning/TimeWindowStrategyManagerFactory.java @@ -42,7 +42,7 @@ public ReceiverStrategyManager get() { GenericPlanStrategyImpl strategy = new GenericPlanStrategyImpl<>(new ExpBetaPlanChanger.Factory().setBetaValue(10.).build()); strategy.addStrategyModule(new TimeWindowUpperBoundMutator(Time.parseTime("01:00:00"))); strategyManager.addStrategy(strategy, null, 0.3); - strategyManager.addChangeRequest((int) (sc.getConfig().controler().getLastIteration() * 0.9), strategy, null, 0.0); + strategyManager.addChangeRequest((int) (sc.getConfig().controller().getLastIteration() * 0.9), strategy, null, 0.0); } /* Replanning for grand coalition receivers. TODO Ignored for now */ diff --git a/contribs/freightreceiver/src/main/java/org/matsim/contrib/freightreceiver/run/chessboard/ReceiverChessboardScenario.java b/contribs/freightreceiver/src/main/java/org/matsim/contrib/freightreceiver/run/chessboard/ReceiverChessboardScenario.java index 8e1884f1337..11b083243b1 100644 --- a/contribs/freightreceiver/src/main/java/org/matsim/contrib/freightreceiver/run/chessboard/ReceiverChessboardScenario.java +++ b/contribs/freightreceiver/src/main/java/org/matsim/contrib/freightreceiver/run/chessboard/ReceiverChessboardScenario.java @@ -102,15 +102,15 @@ private static Config setupChessboardConfig(long seed, String outputFolder) { config.setContext(context); - config.controler().setOutputDirectory(outputFolder); - config.controler().setFirstIteration(0); - config.controler().setLastIteration(ReceiverChessboardParameters.NUM_ITERATIONS); - config.controler().setMobsim("qsim"); - config.controler().setWriteSnapshotsInterval(ReceiverChessboardParameters.STAT_INTERVAL); + config.controller().setOutputDirectory(outputFolder); + config.controller().setFirstIteration(0); + config.controller().setLastIteration(ReceiverChessboardParameters.NUM_ITERATIONS); + config.controller().setMobsim("qsim"); + config.controller().setWriteSnapshotsInterval(ReceiverChessboardParameters.STAT_INTERVAL); config.global().setRandomSeed(seed); config.network().setInputFile("grid9x9.xml"); - config.controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists); + config.controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists); return config; } @@ -120,7 +120,7 @@ private static Config setupChessboardConfig(long seed, String outputFolder) { */ public static void writeFreightScenario(Scenario sc) { /* Write the necessary bits to file. */ - String outputFolder = sc.getConfig().controler().getOutputDirectory(); + String outputFolder = sc.getConfig().controller().getOutputDirectory(); boolean success = new File(outputFolder).mkdirs(); if (!success) { LOG.warn("Could not successfully create '" + outputFolder + "'. Maybe it already exists?"); diff --git a/contribs/freightreceiver/src/main/java/org/matsim/contrib/freightreceiver/run/chessboard/RunReceiverChessboardWithEqualProportionCost.java b/contribs/freightreceiver/src/main/java/org/matsim/contrib/freightreceiver/run/chessboard/RunReceiverChessboardWithEqualProportionCost.java index ae0efa51070..cc1baca9beb 100644 --- a/contribs/freightreceiver/src/main/java/org/matsim/contrib/freightreceiver/run/chessboard/RunReceiverChessboardWithEqualProportionCost.java +++ b/contribs/freightreceiver/src/main/java/org/matsim/contrib/freightreceiver/run/chessboard/RunReceiverChessboardWithEqualProportionCost.java @@ -65,7 +65,7 @@ static void run(int run) { true); Controler controler = new Controler(scenario); - controler.getConfig().controler().setLastIteration(50); + controler.getConfig().controller().setLastIteration(50); /* Set up the receiver module. */ ReceiverModule receiverModule = new ReceiverModule(ReceiverUtils.createEqualProportionCostAllocation()); @@ -83,7 +83,7 @@ static void run(int run) { * TODO This is less elegant than the embedded score stats for the receiver. */ static void prepareFreightOutputDataAndStats(MatsimServices controler) { - CarrierScoreStats scoreStats = new CarrierScoreStats(FreightUtils.getCarriers(controler.getScenario()), controler.getScenario().getConfig().controler().getOutputDirectory() + "/carrier_scores", true); + CarrierScoreStats scoreStats = new CarrierScoreStats(FreightUtils.getCarriers(controler.getScenario()), controler.getScenario().getConfig().controller().getOutputDirectory() + "/carrier_scores", true); controler.addControlerListener(scoreStats); } diff --git a/contribs/freightreceiver/src/main/java/org/matsim/contrib/freightreceiver/run/chessboard/RunReceiverChessboardWithFixedCarrierCost.java b/contribs/freightreceiver/src/main/java/org/matsim/contrib/freightreceiver/run/chessboard/RunReceiverChessboardWithFixedCarrierCost.java index 15d840b5d66..1b2098b2c29 100644 --- a/contribs/freightreceiver/src/main/java/org/matsim/contrib/freightreceiver/run/chessboard/RunReceiverChessboardWithFixedCarrierCost.java +++ b/contribs/freightreceiver/src/main/java/org/matsim/contrib/freightreceiver/run/chessboard/RunReceiverChessboardWithFixedCarrierCost.java @@ -65,7 +65,7 @@ static void run(int run) { true); Controler controler = new Controler(scenario); - controler.getConfig().controler().setLastIteration(50); + controler.getConfig().controller().setLastIteration(50); /* Set up the receiver module. */ ReceiverModule receiverModule = new ReceiverModule(ReceiverUtils.createFixedReceiverCostAllocation(100.0)); @@ -85,7 +85,7 @@ static void run(int run) { * TODO This is less elegant than the embedded score stats for the receiver. */ static void prepareFreightOutputDataAndStats(MatsimServices controler) { - CarrierScoreStats scoreStats = new CarrierScoreStats(FreightUtils.getCarriers(controler.getScenario()), controler.getScenario().getConfig().controler().getOutputDirectory() + "/carrier_scores", true); + CarrierScoreStats scoreStats = new CarrierScoreStats(FreightUtils.getCarriers(controler.getScenario()), controler.getScenario().getConfig().controller().getOutputDirectory() + "/carrier_scores", true); controler.addControlerListener(scoreStats); } diff --git a/contribs/hybridsim/src/main/java/org/matsim/contrib/hybridsim/run/RunExample.java b/contribs/hybridsim/src/main/java/org/matsim/contrib/hybridsim/run/RunExample.java index 119dd040d69..7521cd4df26 100644 --- a/contribs/hybridsim/src/main/java/org/matsim/contrib/hybridsim/run/RunExample.java +++ b/contribs/hybridsim/src/main/java/org/matsim/contrib/hybridsim/run/RunExample.java @@ -80,8 +80,8 @@ public static void main(String[] args) throws IOException, InterruptedException } Config c = ConfigUtils.createConfig(); - c.controler().setLastIteration(0); - c.controler().setWriteEventsInterval(1); + c.controller().setLastIteration(0); + c.controller().setWriteEventsInterval(1); c.qsim().setEndTime(3600); @@ -93,7 +93,7 @@ public static void main(String[] args) throws IOException, InterruptedException createHybridsimScenario(sc); //enable for grpc_jps_as_a_service branch final Controler controller = new Controler(sc); - controller.getConfig().controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles); + controller.getConfig().controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles); final EventsManager eventsManager = EventsUtils.createEventsManager(); @@ -346,11 +346,11 @@ private static void enrichConfig(Config c) { post.setEarliestEndTime(49); post.setLatestStartTime(49); post.setOpeningTime(49); - c.planCalcScore().addActivityParams(pre); - c.planCalcScore().addActivityParams(post); + c.scoring().addActivityParams(pre); + c.scoring().addActivityParams(post); - c.planCalcScore().setLateArrival_utils_hr(0.); - c.planCalcScore().setPerforming_utils_hr(0.); + c.scoring().setLateArrival_utils_hr(0.); + c.scoring().setPerforming_utils_hr(0.); } private static void createPopulation(Scenario sc) { diff --git a/contribs/informed-mode-choice/src/main/java/org/matsim/modechoice/ModeChoiceWeightScheduler.java b/contribs/informed-mode-choice/src/main/java/org/matsim/modechoice/ModeChoiceWeightScheduler.java index c817bb6d849..5d0eed4bb41 100644 --- a/contribs/informed-mode-choice/src/main/java/org/matsim/modechoice/ModeChoiceWeightScheduler.java +++ b/contribs/informed-mode-choice/src/main/java/org/matsim/modechoice/ModeChoiceWeightScheduler.java @@ -40,8 +40,8 @@ public void notifyStartup(StartupEvent event) { anneal = imc.getAnneal(); // The first iteration does not do any replanning - n = config.controler().getLastIteration() - 1; - double disableInnovation = config.strategy().getFractionOfIterationsToDisableInnovation(); + n = config.controller().getLastIteration() - 1; + double disableInnovation = config.replanning().getFractionOfIterationsToDisableInnovation(); if (disableInnovation > 0 && disableInnovation < 1) n *= disableInnovation; diff --git a/contribs/informed-mode-choice/src/main/java/org/matsim/modechoice/commands/AnalyzeCarChoice.java b/contribs/informed-mode-choice/src/main/java/org/matsim/modechoice/commands/AnalyzeCarChoice.java index fb97767357a..4c04f72487c 100644 --- a/contribs/informed-mode-choice/src/main/java/org/matsim/modechoice/commands/AnalyzeCarChoice.java +++ b/contribs/informed-mode-choice/src/main/java/org/matsim/modechoice/commands/AnalyzeCarChoice.java @@ -63,8 +63,8 @@ public Integer call() throws Exception { Config config = scenario.getConfig(); - config.controler().setLastIteration(0); - config.controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles); + config.controller().setLastIteration(0); + config.controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles); InformedModeChoiceConfigGroup imc = ConfigUtils.addOrGetModule(config, InformedModeChoiceConfigGroup.class); diff --git a/contribs/informed-mode-choice/src/main/java/org/matsim/modechoice/commands/GenerateChoiceSet.java b/contribs/informed-mode-choice/src/main/java/org/matsim/modechoice/commands/GenerateChoiceSet.java index 6be247ec47b..14d08f8902c 100644 --- a/contribs/informed-mode-choice/src/main/java/org/matsim/modechoice/commands/GenerateChoiceSet.java +++ b/contribs/informed-mode-choice/src/main/java/org/matsim/modechoice/commands/GenerateChoiceSet.java @@ -74,8 +74,8 @@ public Integer call() throws Exception { Config config = scenario.getConfig(); - config.controler().setLastIteration(0); - config.controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles); + config.controller().setLastIteration(0); + config.controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles); InformedModeChoiceConfigGroup imc = ConfigUtils.addOrGetModule(config, InformedModeChoiceConfigGroup.class); diff --git a/contribs/informed-mode-choice/src/main/java/org/matsim/modechoice/commands/StrategyOptions.java b/contribs/informed-mode-choice/src/main/java/org/matsim/modechoice/commands/StrategyOptions.java index 038c1421efc..532c0995236 100644 --- a/contribs/informed-mode-choice/src/main/java/org/matsim/modechoice/commands/StrategyOptions.java +++ b/contribs/informed-mode-choice/src/main/java/org/matsim/modechoice/commands/StrategyOptions.java @@ -104,7 +104,7 @@ public void applyConfig(Config config, TriConsumer log) // Depends on number of pre generated plans if (getModeChoice() == ModeChoice.none) - config.strategy().setMaxAgentPlanMemorySize(Math.max(config.strategy().getMaxAgentPlanMemorySize(), group.k) + 5); + config.replanning().setMaxAgentPlanMemorySize(Math.max(config.replanning().getMaxAgentPlanMemorySize(), group.k) + 5); } @@ -128,7 +128,7 @@ public Module applyModule(Binder binder, Config config, Consumer strategies = config.strategy().getStrategySettings().stream() + List strategies = config.replanning().getStrategySettings().stream() .filter(s -> !filtered.contains(s.getStrategyName()) || !Objects.equals(s.getSubpopulation(), defaultSubpopulation)) .collect(Collectors.toList()); @@ -150,8 +150,8 @@ public Module applyModule(Binder binder, Config config, Consumer config.strategy().addStrategySettings(s)); + config.replanning().clearStrategySettings(); + strategies.forEach(s -> config.replanning().addStrategySettings(s)); if (group.forceInnovation > 0) binder.bind(new TypeLiteral>() { diff --git a/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/ModeChoiceWeightSchedulerTest.java b/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/ModeChoiceWeightSchedulerTest.java index 103712a5eaa..b7a4d6cd386 100644 --- a/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/ModeChoiceWeightSchedulerTest.java +++ b/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/ModeChoiceWeightSchedulerTest.java @@ -14,7 +14,7 @@ public class ModeChoiceWeightSchedulerTest extends ScenarioTest { @Test public void linear() { - controler.getConfig().controler().setLastIteration(100); + controler.getConfig().controller().setLastIteration(100); InformedModeChoiceConfigGroup imc = ConfigUtils.addOrGetModule(controler.getConfig(), InformedModeChoiceConfigGroup.class); imc.setInvBeta(1); @@ -40,7 +40,7 @@ public void linear() { @Test public void quadratic() { - controler.getConfig().controler().setLastIteration(101); + controler.getConfig().controller().setLastIteration(101); InformedModeChoiceConfigGroup imc = ConfigUtils.addOrGetModule(controler.getConfig(), InformedModeChoiceConfigGroup.class); imc.setInvBeta(1); @@ -60,4 +60,4 @@ public void quadratic() { assertThat(scheduler.getInvBeta()).isEqualTo(0.25); } -} \ No newline at end of file +} diff --git a/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/TestScenario.java b/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/TestScenario.java index e0a518ec2a1..98798263fad 100644 --- a/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/TestScenario.java +++ b/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/TestScenario.java @@ -65,8 +65,8 @@ public static Config loadConfig(MatsimTestUtils utils) { URL context = ExamplesUtils.getTestScenarioURL("kelheim"); Config config = ConfigUtils.loadConfig(IOUtils.extendUrl(context, "config.xml")); - config.controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists); - config.controler().setOutputDirectory(utils.getOutputDirectory()); + config.controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists); + config.controller().setOutputDirectory(utils.getOutputDirectory()); return config; } @@ -78,28 +78,28 @@ protected Config prepareConfig(Config config) { for (String act : List.of("home", "restaurant", "other", "visit", "errands", "accomp_other", "accomp_children", "educ_higher", "educ_secondary", "educ_primary", "educ_tertiary", "educ_kiga", "educ_other")) { - config.planCalcScore() + config.scoring() .addActivityParams(new ScoringConfigGroup.ActivityParams(act + "_" + ii).setTypicalDuration(ii)); } - config.planCalcScore().addActivityParams(new ScoringConfigGroup.ActivityParams("work_" + ii).setTypicalDuration(ii) + config.scoring().addActivityParams(new ScoringConfigGroup.ActivityParams("work_" + ii).setTypicalDuration(ii) .setOpeningTime(6. * 3600.).setClosingTime(20. * 3600.)); - config.planCalcScore().addActivityParams(new ScoringConfigGroup.ActivityParams("business_" + ii).setTypicalDuration(ii) + config.scoring().addActivityParams(new ScoringConfigGroup.ActivityParams("business_" + ii).setTypicalDuration(ii) .setOpeningTime(6. * 3600.).setClosingTime(20. * 3600.)); - config.planCalcScore().addActivityParams(new ScoringConfigGroup.ActivityParams("leisure_" + ii).setTypicalDuration(ii) + config.scoring().addActivityParams(new ScoringConfigGroup.ActivityParams("leisure_" + ii).setTypicalDuration(ii) .setOpeningTime(9. * 3600.).setClosingTime(27. * 3600.)); - config.planCalcScore().addActivityParams(new ScoringConfigGroup.ActivityParams("shop_daily_" + ii).setTypicalDuration(ii) + config.scoring().addActivityParams(new ScoringConfigGroup.ActivityParams("shop_daily_" + ii).setTypicalDuration(ii) .setOpeningTime(8. * 3600.).setClosingTime(20. * 3600.)); - config.planCalcScore().addActivityParams(new ScoringConfigGroup.ActivityParams("shop_other_" + ii).setTypicalDuration(ii) + config.scoring().addActivityParams(new ScoringConfigGroup.ActivityParams("shop_other_" + ii).setTypicalDuration(ii) .setOpeningTime(8. * 3600.).setClosingTime(20. * 3600.)); } - config.planCalcScore().addActivityParams(new ScoringConfigGroup.ActivityParams("car interaction").setTypicalDuration(60)); - config.planCalcScore().addActivityParams(new ScoringConfigGroup.ActivityParams("other").setTypicalDuration(600 * 3)); + config.scoring().addActivityParams(new ScoringConfigGroup.ActivityParams("car interaction").setTypicalDuration(60)); + config.scoring().addActivityParams(new ScoringConfigGroup.ActivityParams("other").setTypicalDuration(600 * 3)); - config.planCalcScore().addActivityParams(new ScoringConfigGroup.ActivityParams("freight_start").setTypicalDuration(60 * 15)); - config.planCalcScore().addActivityParams(new ScoringConfigGroup.ActivityParams("freight_end").setTypicalDuration(60 * 15)); + config.scoring().addActivityParams(new ScoringConfigGroup.ActivityParams("freight_start").setTypicalDuration(60 * 15)); + config.scoring().addActivityParams(new ScoringConfigGroup.ActivityParams("freight_end").setTypicalDuration(60 * 15)); InformedModeChoiceConfigGroup imc = ConfigUtils.addOrGetModule(config, InformedModeChoiceConfigGroup.class); imc.setModes(Set.of("car", "ride", "bike", "walk", "pt")); diff --git a/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/estimators/ComplexEstimatorTest.java b/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/estimators/ComplexEstimatorTest.java index 3ce186a0124..5d3dd6a7a36 100644 --- a/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/estimators/ComplexEstimatorTest.java +++ b/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/estimators/ComplexEstimatorTest.java @@ -21,7 +21,7 @@ public void bindings() { Config config = TestScenario.loadConfig(utils); - config.controler().setLastIteration(2); + config.controller().setLastIteration(2); Controler controler = MATSimApplication.prepare(TestScenario.class, config, "--complex"); controler.run(); diff --git a/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/replanning/SelectSingleTripModeStrategyTest.java b/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/replanning/SelectSingleTripModeStrategyTest.java index 8e94a7da3ab..7ae3ffca08f 100644 --- a/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/replanning/SelectSingleTripModeStrategyTest.java +++ b/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/replanning/SelectSingleTripModeStrategyTest.java @@ -24,9 +24,9 @@ public void selectSingleTrip() { Config config = TestScenario.loadConfig(utils); - config.controler().setLastIteration(10); - config.controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles); - config.strategy().addStrategySettings(new ReplanningConfigGroup.StrategySettings() + config.controller().setLastIteration(10); + config.controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles); + config.replanning().addStrategySettings(new ReplanningConfigGroup.StrategySettings() .setStrategyName(InformedModeChoiceModule.SELECT_SINGLE_TRIP_MODE_STRATEGY) .setSubpopulation("person") .setWeight(0.5) diff --git a/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/search/TopKMinMaxTest.java b/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/search/TopKMinMaxTest.java index 55aa1d8e8e7..e57a6413116 100644 --- a/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/search/TopKMinMaxTest.java +++ b/contribs/informed-mode-choice/src/test/java/org/matsim/modechoice/search/TopKMinMaxTest.java @@ -236,7 +236,7 @@ else if (invocationOnMock.getArgument(0).equals(TransportMode.walk)) { tripBinder.addBinding(TransportMode.car).toInstance(new CarTripEstimator()); - ScoringParameters.Builder scoring = new ScoringParameters.Builder(config.planCalcScore(), config.planCalcScore().getScoringParameters("person"), Map.of(), config.scenario()); + ScoringParameters.Builder scoring = new ScoringParameters.Builder(config.scoring(), config.scoring().getScoringParameters("person"), Map.of(), config.scenario()); bind(ScoringParametersForPerson.class).toInstance(person -> scoring.build()); bind(InformedModeChoiceConfigGroup.class).toInstance(ConfigUtils.addOrGetModule(config, InformedModeChoiceConfigGroup.class)); diff --git a/contribs/locationchoice/src/main/java/org/matsim/contrib/locationchoice/frozenepsilons/BestReplyLocationChoicePlanAlgorithm.java b/contribs/locationchoice/src/main/java/org/matsim/contrib/locationchoice/frozenepsilons/BestReplyLocationChoicePlanAlgorithm.java index 2a242659ae1..7d0fa5398b2 100644 --- a/contribs/locationchoice/src/main/java/org/matsim/contrib/locationchoice/frozenepsilons/BestReplyLocationChoicePlanAlgorithm.java +++ b/contribs/locationchoice/src/main/java/org/matsim/contrib/locationchoice/frozenepsilons/BestReplyLocationChoicePlanAlgorithm.java @@ -55,7 +55,7 @@ final class BestReplyLocationChoicePlanAlgorithm implements PlanAlgorithm { private static final Logger log = LogManager.getLogger( BestReplyLocationChoicePlanAlgorithm.class ) ; - + private final ActivityFacilities facilities; private final ObjectAttributes personsMaxDCScoreUnscaled; private final ScaleEpsilon scaleEpsilon; @@ -168,15 +168,15 @@ private ChoiceSet createChoiceSetFromCircle(Plan plan, int personIndex, final QuadTree quadTree = this.quadTreesOfType.get( convertedType ); Gbl.assertNotNull( quadTree ); Collection list = quadTree.getDisk(center.getX(), center.getY(), maxRadius ); - + for (ActivityFacilityWithIndex facility : list) { // int facilityIndex = this.lcContext.getFacilityIndex(facility.getId()); int facilityIndex = facility.getArrayIndex(); - if (this.sampler.sample(facilityIndex, personIndex)) { - + if (this.sampler.sample(facilityIndex, personIndex)) { + // only add destination if it can be reached with the chosen mode String mode = PopulationUtils.getPreviousLeg( plan, actToMove ).getMode(); - + Id linkId = null; // try to get linkId from facility, else get it from act. other options not allowed! if (facility.getLinkId() != null) { @@ -186,16 +186,16 @@ private ChoiceSet createChoiceSetFromCircle(Plan plan, int personIndex, linkId = actToMove.getLinkId(); } // TODO: solve this generic. for that we need info from the config, which modes are actually teleported. - if (this.lcContext.getScenario().getNetwork().getLinks().get(linkId).getAllowedModes().contains(mode) || - mode.equals(TransportMode.bike) || + if (this.lcContext.getScenario().getNetwork().getLinks().get(linkId).getAllowedModes().contains(mode) || + mode.equals(TransportMode.bike) || mode.equals(TransportMode.walk) || mode.equals(TransportMode.transit_walk) || mode.equals(TransportMode.other)) { cs.addDestination(facility.getId()); - } + } } } - + return cs; } @@ -223,14 +223,14 @@ private double convertEpsilonIntoDistance(Person person, String type) { // maxDCScore *= scale; // apply the scale factors given in the config file - /* + /* * here one could do a much more sophisticated calculation including time use and travel speed estimations (from previous iteration) */ double travelSpeedCrowFly = this.dccg.getTravelSpeed_car(); - double betaTime = this.scenario.getConfig().planCalcScore().getModes().get(TransportMode.car ).getMarginalUtilityOfTraveling(); + double betaTime = this.scenario.getConfig().scoring().getModes().get(TransportMode.car ).getMarginalUtilityOfTraveling(); // if ( Boolean.getBoolean(this.scenario.getConfig().vspExperimental().getValue(VspExperimentalConfigKey.isUsingOpportunityCostOfTimeForLocationChoice)) ) { if ( this.scenario.getConfig().vspExperimental().isUsingOpportunityCostOfTimeForLocationChoice() ) { - betaTime -= this.scenario.getConfig().planCalcScore().getPerforming_utils_hr() ; + betaTime -= this.scenario.getConfig().scoring().getPerforming_utils_hr() ; // needs to be negative (I think) since AH uses this as a cost parameter. kai, jan'13 } double maxTravelTime = Double.MAX_VALUE; @@ -243,7 +243,7 @@ private double convertEpsilonIntoDistance(Person person, String type) { // correct way. kai, jan'13 } // distance linear - double maxDistance = travelSpeedCrowFly * maxTravelTime; + double maxDistance = travelSpeedCrowFly * maxTravelTime; // define a maximum distance choice set manually // yyyy it is quite stupid to do the following at the end of this method and not at the beginning. Can probably be moved up, but would need to be tested. kai, jul'23 diff --git a/contribs/locationchoice/src/main/java/org/matsim/contrib/locationchoice/frozenepsilons/BestReplyLocationChoicePlanStrategy.java b/contribs/locationchoice/src/main/java/org/matsim/contrib/locationchoice/frozenepsilons/BestReplyLocationChoicePlanStrategy.java index 134d10ac14a..048c3a03f3e 100644 --- a/contribs/locationchoice/src/main/java/org/matsim/contrib/locationchoice/frozenepsilons/BestReplyLocationChoicePlanStrategy.java +++ b/contribs/locationchoice/src/main/java/org/matsim/contrib/locationchoice/frozenepsilons/BestReplyLocationChoicePlanStrategy.java @@ -29,7 +29,6 @@ import org.matsim.core.replanning.PlanStrategyImpl; import org.matsim.core.replanning.ReplanningContext; import org.matsim.core.replanning.modules.ReRoute; -import org.matsim.core.replanning.modules.TripsToLegsModule; import org.matsim.core.replanning.selectors.BestPlanSelector; import org.matsim.core.replanning.selectors.ExpBetaPlanChanger; import org.matsim.core.replanning.selectors.ExpBetaPlanSelector; @@ -82,13 +81,13 @@ public void init(ReplanningContext replanningContext) { delegate = new PlanStrategyImpl( new BestPlanSelector<>() ); break; case "ChangeExpBeta": - delegate = new PlanStrategyImpl( new ExpBetaPlanChanger( config.planCalcScore().getBrainExpBeta() ) ); + delegate = new PlanStrategyImpl( new ExpBetaPlanChanger( config.scoring().getBrainExpBeta() ) ); break; case "SelectRandom": delegate = new PlanStrategyImpl( new RandomPlanSelector() ); break; default: - delegate = new PlanStrategyImpl( new ExpBetaPlanSelector( config.planCalcScore() ) ); + delegate = new PlanStrategyImpl( new ExpBetaPlanSelector( config.scoring() ) ); break; } delegate.addStrategyModule(new BestReplyLocationChoiceStrategymodule(tripRouterProvider, lcContext, maxDcScoreWrapper.getPersonsMaxDCScoreUnscaled(), scoringFunctionFactory, travelTimes, travelDisutilities, timeInterpretation) ); diff --git a/contribs/locationchoice/src/main/java/org/matsim/contrib/locationchoice/frozenepsilons/DCScoringFunctionFactory.java b/contribs/locationchoice/src/main/java/org/matsim/contrib/locationchoice/frozenepsilons/DCScoringFunctionFactory.java index da142e4aecb..902ac71178a 100644 --- a/contribs/locationchoice/src/main/java/org/matsim/contrib/locationchoice/frozenepsilons/DCScoringFunctionFactory.java +++ b/contribs/locationchoice/src/main/java/org/matsim/contrib/locationchoice/frozenepsilons/DCScoringFunctionFactory.java @@ -33,12 +33,12 @@ import org.matsim.core.scoring.functions.ScoringParameters; class DCScoringFunctionFactory implements ScoringFunctionFactory { - + private final static Logger log = LogManager.getLogger(DCScoringFunctionFactory.class); - + private final Scenario scenario; private final DestinationChoiceContext lcContext; - + private boolean usingConfigParamsForScoring = true; private boolean usingIndividualScoringParameters = true; private ScoringParameters nonPersonalizedScoringParameters = null; @@ -47,7 +47,7 @@ public DCScoringFunctionFactory(Scenario scenario, DestinationChoiceContext lcCo this.scenario = scenario; this.lcContext = lcContext; log.info("creating DCScoringFunctionFactory"); - + // configure ScoringFunction according to config FrozenTastesConfigGroup dccg = (FrozenTastesConfigGroup) scenario.getConfig().getModule( FrozenTastesConfigGroup.GROUP_NAME ); if (dccg != null) { @@ -55,7 +55,7 @@ public DCScoringFunctionFactory(Scenario scenario, DestinationChoiceContext lcCo this.setUsingIndividualScoringParameters(dccg.getUseIndividualScoringParameters()); } else log.warn("No DestinationChoiceConfigGroup was found in the config - cannot configure DCScoringFunctionFactory according to it!"); } - + public void setUsingConfigParamsForScoring(boolean val) { this.usingConfigParamsForScoring = val; } @@ -65,15 +65,15 @@ public void setUsingIndividualScoringParameters(boolean val) { if (!this.usingIndividualScoringParameters) { Config config = this.scenario.getConfig(); String subPopulationAttributeName = null; - this.nonPersonalizedScoringParameters = new ScoringParameters.Builder(config.planCalcScore(), config.planCalcScore().getScoringParameters(subPopulationAttributeName), config.scenario()).build(); + this.nonPersonalizedScoringParameters = new ScoringParameters.Builder(config.scoring(), config.scoring().getScoringParameters(subPopulationAttributeName), config.scenario()).build(); } } - + @Override public ScoringFunction createNewScoringFunction(Person person) { - + SumScoringFunction scoringFunctionAccumulator = new SumScoringFunction(); - + SumScoringFunction.BasicScoring scoringFunction; if (this.usingConfigParamsForScoring) { scoringFunction = new DCActivityWOFacilitiesScoringFunction(person, this.lcContext); @@ -83,7 +83,7 @@ public ScoringFunction createNewScoringFunction(Person person) { scoringFunction = new DCActivityScoringFunction(person.getSelectedPlan(), this.lcContext); } scoringFunctionAccumulator.addScoringFunction(scoringFunction); - + if (this.usingIndividualScoringParameters) { ScoringParameters scoringParameters = new ScoringParameters.Builder(this.scenario, person ).build(); scoringFunctionAccumulator.addScoringFunction(new CharyparNagelLegScoring(scoringParameters, this.scenario.getNetwork(), this.scenario.getConfig().transit().getTransitModes())); @@ -92,7 +92,7 @@ public ScoringFunction createNewScoringFunction(Person person) { scoringFunctionAccumulator.addScoringFunction(new CharyparNagelLegScoring(this.nonPersonalizedScoringParameters, this.scenario.getNetwork(), this.scenario.getConfig().transit().getTransitModes())); scoringFunctionAccumulator.addScoringFunction(new CharyparNagelAgentStuckScoring(this.nonPersonalizedScoringParameters)); } - + return scoringFunctionAccumulator; } } diff --git a/contribs/locationchoice/src/main/java/org/matsim/contrib/locationchoice/frozenepsilons/DestinationChoiceContext.java b/contribs/locationchoice/src/main/java/org/matsim/contrib/locationchoice/frozenepsilons/DestinationChoiceContext.java index c56f096d27c..68e787690ce 100644 --- a/contribs/locationchoice/src/main/java/org/matsim/contrib/locationchoice/frozenepsilons/DestinationChoiceContext.java +++ b/contribs/locationchoice/src/main/java/org/matsim/contrib/locationchoice/frozenepsilons/DestinationChoiceContext.java @@ -111,7 +111,7 @@ public DestinationChoiceContext(Scenario scenario) { public void init() { if ( params==null ){ - this.params = new ScoringParameters.Builder( scenario.getConfig().planCalcScore(), scenario.getConfig().planCalcScore().getScoringParameters( null ), + this.params = new ScoringParameters.Builder( scenario.getConfig().scoring(), scenario.getConfig().scoring().getScoringParameters( null ), scenario.getConfig().scenario() ).build(); this.dccg = ConfigUtils.addOrGetModule( this.scenario.getConfig(), FrozenTastesConfigGroup.class ); ActivitiesHandler defineFlexibleActivities = new ActivitiesHandler( this.dccg ); @@ -185,7 +185,7 @@ private void readPrefs() { } } else { log.warn("prefs are taken from the config and if available from the desires as there is no preferences file specified \n"); - for (ActivityParams activityParams : this.scenario.getConfig().planCalcScore().getActivityParams()) { + for (ActivityParams activityParams : this.scenario.getConfig().scoring().getActivityParams()) { for (Person p : this.scenario.getPopulation().getPersons().values()) { prefsAttributes.putAttribute(p.getId().toString(), "typicalDuration_" + activityParams.getActivityType(), activityParams.getTypicalDuration()); diff --git a/contribs/locationchoice/src/main/java/org/matsim/contrib/locationchoice/timegeography/LocationChoicePlanStrategy.java b/contribs/locationchoice/src/main/java/org/matsim/contrib/locationchoice/timegeography/LocationChoicePlanStrategy.java index 210f59c15e0..70562a0c1fd 100644 --- a/contribs/locationchoice/src/main/java/org/matsim/contrib/locationchoice/timegeography/LocationChoicePlanStrategy.java +++ b/contribs/locationchoice/src/main/java/org/matsim/contrib/locationchoice/timegeography/LocationChoicePlanStrategy.java @@ -34,13 +34,13 @@ public LocationChoicePlanStrategy(Scenario scenario, Provider tripRo delegate = new PlanStrategyImpl( new BestPlanSelector() ); break; case "ChangeExpBeta": - delegate = new PlanStrategyImpl( new ExpBetaPlanChanger( scenario.getConfig().planCalcScore().getBrainExpBeta() ) ); + delegate = new PlanStrategyImpl( new ExpBetaPlanChanger( scenario.getConfig().scoring().getBrainExpBeta() ) ); break; case "SelectRandom": delegate = new PlanStrategyImpl( new RandomPlanSelector() ); break; default: - delegate = new PlanStrategyImpl( new ExpBetaPlanSelector( scenario.getConfig().planCalcScore() ) ); + delegate = new PlanStrategyImpl( new ExpBetaPlanSelector( scenario.getConfig().scoring() ) ); break; } delegate.addStrategyModule(new DestinationChoice( tripRouterProvider, scenario, timeInterpretation) ); diff --git a/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/Initializer.java b/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/Initializer.java index 9f640aafaaf..cf53eb647bd 100644 --- a/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/Initializer.java +++ b/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/Initializer.java @@ -51,10 +51,10 @@ public void init(MatsimTestUtils utils) { preparePlans(scenario); this.controler = new Controler(scenario); - this.controler.getConfig().controler().setCreateGraphs(false); - this.controler.getConfig().controler().setWriteEventsInterval(0); // disables events-writing + this.controler.getConfig().controller().setCreateGraphs(false); + this.controler.getConfig().controller().setWriteEventsInterval(0); // disables events-writing this.controler.getConfig() - .controler() + .controller() .setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles); this.controler.run(); } @@ -74,7 +74,7 @@ private static void preparePlans(Scenario scenario) { .forEach(planElement -> ((Leg)planElement).setRoute(null)); final FreespeedTravelTimeAndDisutility timeCostCalc = new FreespeedTravelTimeAndDisutility( - scenario.getConfig().planCalcScore()); + scenario.getConfig().scoring()); PlanAlgorithm router = new PlanRouter(new TripRouterFactoryBuilderWithDefaults().build(scenario).get(), TimeInterpretation.create(scenario.getConfig())); PersonPrepareForSim pp4s = new PersonPrepareForSim(router, scenario); scenario.getPopulation().getPersons().values().forEach(pp4s::run); diff --git a/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/LocationChoiceIT.java b/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/LocationChoiceIT.java index 36f9d1731b0..82fbd9e7a0e 100644 --- a/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/LocationChoiceIT.java +++ b/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/LocationChoiceIT.java @@ -124,7 +124,7 @@ public PlanStrategy get() { // (this is now only necessary since the config for all three tests sets MyLocationChoice instead of LocationChoice. Probably // should pull the best response test away from the other (old) test. kai, feb'13 - controler.getConfig().controler().setOverwriteFileSetting( OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles ); + controler.getConfig().controller().setOverwriteFileSetting( OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles ); controler.run(); // test that everything worked as expected @@ -137,7 +137,7 @@ public PlanStrategy get() { assertEquals("number of plans in person.", 2, person.getPlans().size()); Plan newPlan = person.getSelectedPlan(); Activity newWork = (Activity) newPlan.getPlanElements().get(2); - if (!config.plansCalcRoute().getAccessEgressType().equals(RoutingConfigGroup.AccessEgressType.none) ) { + if (!config.routing().getAccessEgressType().equals(RoutingConfigGroup.AccessEgressType.none) ) { newWork = (Activity) newPlan.getPlanElements().get(6); } assertNotNull( newWork ) ; @@ -188,9 +188,9 @@ static Config localCreateConfig( String configFileName ) { Config config = ConfigUtils.loadConfig(configFileName, new DestinationChoiceConfigGroup() , new FrozenTastesConfigGroup() ) ; config.global().setNumberOfThreads(0); - config.controler().setFirstIteration(0); - config.controler().setLastIteration(1); - config.controler().setMobsim("qsim"); + config.controller().setFirstIteration(0); + config.controller().setLastIteration(1); + config.controller().setMobsim("qsim"); config.qsim().setSnapshotStyle(QSimConfigGroup.SnapshotStyle.queue) ; final DestinationChoiceConfigGroup dccg = ConfigUtils.addOrGetModule(config, DestinationChoiceConfigGroup.class ) ; @@ -199,18 +199,18 @@ static Config localCreateConfig( String configFileName ) { ActivityParams home = new ActivityParams("home"); home.setTypicalDuration(12*60*60); - config.planCalcScore().addActivityParams(home); + config.scoring().addActivityParams(home); ActivityParams work = new ActivityParams("work"); work.setTypicalDuration(12*60*60); - config.planCalcScore().addActivityParams(work); + config.scoring().addActivityParams(work); ActivityParams shop = new ActivityParams("shop"); shop.setTypicalDuration(1.*60*60); - config.planCalcScore().addActivityParams(shop); + config.scoring().addActivityParams(shop); final StrategySettings strategySettings = new StrategySettings(Id.create("1", StrategySettings.class)); strategySettings.setStrategyName("MyLocationChoice"); strategySettings.setWeight(1.0); - config.strategy().addStrategySettings(strategySettings); + config.replanning().addStrategySettings(strategySettings); ConfigUtils.addOrGetModule(config, OTFVisConfigGroup.GROUP_NAME, OTFVisConfigGroup.class).setEffectiveLaneWidth(1.) ; config.qsim().setLinkWidthForVis((float)1.) ; diff --git a/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/frozenepsilons/BestReplyIT.java b/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/frozenepsilons/BestReplyIT.java index 9b85f7ec218..133a45fc886 100644 --- a/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/frozenepsilons/BestReplyIT.java +++ b/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/frozenepsilons/BestReplyIT.java @@ -24,14 +24,14 @@ public void testRunControler() { IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("chessboard"), "config.xml"), new FrozenTastesConfigGroup() ); - + // override or add some material: ConfigUtils.loadConfig(config, utils.getPackageInputDirectory() + "/config.xml"); - config.controler().setOutputDirectory( utils.getOutputDirectory() ); - config.controler().setOverwriteFileSetting( OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists ); - - + config.controller().setOutputDirectory( utils.getOutputDirectory() ); + config.controller().setOverwriteFileSetting( OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists ); + + Scenario scenario = ScenarioUtils.loadScenario(config); RunLocationChoiceBestResponse.run(scenario ); } diff --git a/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/frozenepsilons/FrozenEpsilonLocaChoiceIT.java b/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/frozenepsilons/FrozenEpsilonLocaChoiceIT.java index d3674fa6302..08af97c8a0c 100644 --- a/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/frozenepsilons/FrozenEpsilonLocaChoiceIT.java +++ b/contribs/locationchoice/src/test/java/org/matsim/contrib/locationchoice/frozenepsilons/FrozenEpsilonLocaChoiceIT.java @@ -95,8 +95,8 @@ public void testLocationChoiceJan2013() { // CONFIG: final Config config = localCreateConfig( this.utils.getPackageInputDirectory() + "../config2.xml"); - config.controler().setOutputDirectory( utils.getOutputDirectory() ); - config.controler().setOverwriteFileSetting( OverwriteFileSetting.deleteDirectoryIfExists ); + config.controller().setOutputDirectory( utils.getOutputDirectory() ); + config.controller().setOverwriteFileSetting( OverwriteFileSetting.deleteDirectoryIfExists ); { FrozenTastesConfigGroup dccg = ConfigUtils.addOrGetModule( config, FrozenTastesConfigGroup.class ); @@ -107,7 +107,7 @@ public void testLocationChoiceJan2013() { dccg.setRandomSeed( 4711 ); dccg.setTravelTimeApproximationLevel( ApproximationLevel.localRouting ); } - config.plansCalcRoute().setRoutingRandomness(0.); + config.routing().setRoutingRandomness(0.); // SCENARIO: final Scenario scenario = ScenarioUtils.createScenario(config ); @@ -157,7 +157,7 @@ public void install() { Plan newPlan = person.getSelectedPlan(); System.err.println( " newPlan: " + newPlan ) ; Activity newWork = (Activity) newPlan.getPlanElements().get(2 ); - if ( !config.plansCalcRoute().getAccessEgressType().equals(RoutingConfigGroup.AccessEgressType.none) ) { + if ( !config.routing().getAccessEgressType().equals(RoutingConfigGroup.AccessEgressType.none) ) { newWork = (Activity) newPlan.getPlanElements().get(6); } System.err.println( " newWork: " + newWork ) ; @@ -173,7 +173,7 @@ public void testLocationChoiceFeb2013NegativeScores() { // config: final Config config = localCreateConfig( utils.getPackageInputDirectory() + "../config2.xml"); - config.controler().setOutputDirectory( utils.getOutputDirectory() ); + config.controller().setOutputDirectory( utils.getOutputDirectory() ); final FrozenTastesConfigGroup dccg = ConfigUtils.addOrGetModule(config, FrozenTastesConfigGroup.class ) ; @@ -201,7 +201,7 @@ public void testLocationChoiceFeb2013NegativeScores() { // CONTROL(L)ER: Controler controler = new Controler(scenario); - controler.getConfig().controler().setOverwriteFileSetting( OverwriteFileSetting.overwriteExistingFiles ); + controler.getConfig().controller().setOverwriteFileSetting( OverwriteFileSetting.overwriteExistingFiles ); // set scoring function DCScoringFunctionFactory scoringFunctionFactory = new DCScoringFunctionFactory(controler.getScenario(), lcContext); @@ -236,33 +236,33 @@ enum RunType { shortRun, medRun, longRun } Config config = ConfigUtils.createConfig() ; switch( runType ) { case shortRun: - config.controler().setLastIteration( 2 ); + config.controller().setLastIteration( 2 ); break; case medRun: - config.controler().setLastIteration( 100 ); + config.controller().setLastIteration( 100 ); break; case longRun: - config.controler().setLastIteration( 1000 ); + config.controller().setLastIteration( 1000 ); break; default: throw new RuntimeException( Gbl.NOT_IMPLEMENTED) ; } - config.controler().setOutputDirectory( utils.getOutputDirectory() ); + config.controller().setOutputDirectory( utils.getOutputDirectory() ); - config.planCalcScore().addActivityParams( new ActivityParams( "home" ).setTypicalDuration( 12.*3600. ) ); - config.planCalcScore().addActivityParams( new ActivityParams( "shop" ).setTypicalDuration( 2.*3600. ) ); + config.scoring().addActivityParams( new ActivityParams( "home" ).setTypicalDuration( 12.*3600. ) ); + config.scoring().addActivityParams( new ActivityParams( "shop" ).setTypicalDuration( 2.*3600. ) ); - config.strategy().addStrategySettings( new StrategySettings( ).setStrategyName( FrozenTastes.LOCATION_CHOICE_PLAN_STRATEGY ).setWeight( 1.0 ).setDisableAfter( 10 ) ); + config.replanning().addStrategySettings( new StrategySettings( ).setStrategyName( FrozenTastes.LOCATION_CHOICE_PLAN_STRATEGY ).setWeight( 1.0 ).setDisableAfter( 10 ) ); switch ( runType ){ case shortRun: break; case medRun: case longRun: - config.strategy().addStrategySettings( new StrategySettings().setStrategyName( FrozenTastes.LOCATION_CHOICE_PLAN_STRATEGY ).setWeight( 0.1 ) ); - config.strategy().addStrategySettings( new StrategySettings().setStrategyName( DefaultSelector.ChangeExpBeta ).setWeight( 1.0 ) ); - config.strategy().setFractionOfIterationsToDisableInnovation( 0.8 ); - config.planCalcScore().setFractionOfIterationsToStartScoreMSA( 0.8 ); + config.replanning().addStrategySettings( new StrategySettings().setStrategyName( FrozenTastes.LOCATION_CHOICE_PLAN_STRATEGY ).setWeight( 0.1 ) ); + config.replanning().addStrategySettings( new StrategySettings().setStrategyName( DefaultSelector.ChangeExpBeta ).setWeight( 1.0 ) ); + config.replanning().setFractionOfIterationsToDisableInnovation( 0.8 ); + config.scoring().setFractionOfIterationsToStartScoreMSA( 0.8 ); break ; default: throw new RuntimeException( Gbl.NOT_IMPLEMENTED ) ; @@ -358,7 +358,7 @@ enum RunType { shortRun, medRun, longRun } // CONTROL(L)ER: Controler controler = new Controler(scenario); - controler.getConfig().controler().setOverwriteFileSetting( OverwriteFileSetting.deleteDirectoryIfExists ); + controler.getConfig().controller().setOverwriteFileSetting( OverwriteFileSetting.deleteDirectoryIfExists ); FrozenTastes.configure( controler ); @@ -518,9 +518,9 @@ static Config localCreateConfig( String configFileName ) { Config config = ConfigUtils.loadConfig(configFileName, new FrozenTastesConfigGroup() ) ; config.global().setNumberOfThreads(0); - config.controler().setFirstIteration(0); - config.controler().setLastIteration(1); - config.controler().setMobsim("qsim"); + config.controller().setFirstIteration(0); + config.controller().setLastIteration(1); + config.controller().setMobsim("qsim"); config.qsim().setSnapshotStyle( QSimConfigGroup.SnapshotStyle.queue ) ; final FrozenTastesConfigGroup dccg = ConfigUtils.addOrGetModule(config, FrozenTastesConfigGroup.class ) ; @@ -529,18 +529,18 @@ static Config localCreateConfig( String configFileName ) { ActivityParams home = new ActivityParams("home"); home.setTypicalDuration(12*60*60); - config.planCalcScore().addActivityParams(home); + config.scoring().addActivityParams(home); ActivityParams work = new ActivityParams("work"); work.setTypicalDuration(12*60*60); - config.planCalcScore().addActivityParams(work); + config.scoring().addActivityParams(work); ActivityParams shop = new ActivityParams("shop"); shop.setTypicalDuration(1.*60*60); - config.planCalcScore().addActivityParams(shop); + config.scoring().addActivityParams(shop); final StrategySettings strategySettings = new StrategySettings(Id.create("1", StrategySettings.class )); strategySettings.setStrategyName("MyLocationChoice"); strategySettings.setWeight(1.0); - config.strategy().addStrategySettings(strategySettings); + config.replanning().addStrategySettings(strategySettings); ConfigUtils.addOrGetModule(config, OTFVisConfigGroup.GROUP_NAME, OTFVisConfigGroup.class ).setEffectiveLaneWidth(1. ) ; config.qsim().setLinkWidthForVis((float)1.) ; diff --git a/contribs/locationchoice/src/test/java/org/matsim/core/router/BackwardFastMultiNodeTest.java b/contribs/locationchoice/src/test/java/org/matsim/core/router/BackwardFastMultiNodeTest.java index a2590bccf2b..844fdbe02ef 100644 --- a/contribs/locationchoice/src/test/java/org/matsim/core/router/BackwardFastMultiNodeTest.java +++ b/contribs/locationchoice/src/test/java/org/matsim/core/router/BackwardFastMultiNodeTest.java @@ -46,19 +46,19 @@ * @author cdobler */ public class BackwardFastMultiNodeTest { - + @Test public void testBackwardsFastMultiNodeDijkstra_OneToOne() { runTestBackwardsFastMultiNodeDijkstra_OneToOne(true); runTestBackwardsFastMultiNodeDijkstra_OneToOne(false); } - + private void runTestBackwardsFastMultiNodeDijkstra_OneToOne(boolean searchAllEndNodes) { - + Config config = ConfigUtils.createConfig(); - config.plansCalcRoute().setRoutingRandomness(0.); + config.routing().setRoutingRandomness(0.); Scenario scenario = ScenarioUtils.createScenario(config); - + createNetwork(scenario); TravelTime travelTime = new FreeSpeedTravelTime(); @@ -66,59 +66,59 @@ private void runTestBackwardsFastMultiNodeDijkstra_OneToOne(boolean searchAllEnd config ).createTravelDisutility(travelTime ); BackwardFastMultiNodeDijkstra dijkstra = (BackwardFastMultiNodeDijkstra) new BackwardFastMultiNodeDijkstraFactory(searchAllEndNodes). createPathCalculator(scenario.getNetwork(), travelDisutility, travelTime); - + Node fromNode = scenario.getNetwork().getNodes().get(Id.create("n3", Node.class)); Node toNode = scenario.getNetwork().getNodes().get(Id.create("n0", Node.class)); - + /* * test calcLeastCostPath method */ Path path = dijkstra.calcLeastCostPath(fromNode, toNode, 3600.0, null, null); - + Assert.assertEquals(1.0, path.travelCost, 0.0); Assert.assertEquals(300.0, path.travelTime, 0.0); - + Assert.assertEquals(4, path.nodes.size()); Assert.assertEquals(Id.create("n0", Node.class), path.nodes.get(0).getId()); Assert.assertEquals(Id.create("n1", Node.class), path.nodes.get(1).getId()); Assert.assertEquals(Id.create("n2", Node.class), path.nodes.get(2).getId()); Assert.assertEquals(Id.create("n3", Node.class), path.nodes.get(3).getId()); - + Assert.assertEquals(3, path.links.size()); Assert.assertEquals(Id.create("l0", Link.class), path.links.get(0).getId()); Assert.assertEquals(Id.create("l1", Link.class), path.links.get(1).getId()); Assert.assertEquals(Id.create("l2", Link.class), path.links.get(2).getId()); - + /* * test constructPath method which uses data from the previous routing operation */ path = dijkstra.constructPath(fromNode, toNode, 3600.0); - + Assert.assertEquals(1.0, path.travelCost, 0.0); Assert.assertEquals(300.0, path.travelTime, 0.0); - + Assert.assertEquals(4, path.nodes.size()); Assert.assertEquals(Id.create("n0", Node.class), path.nodes.get(0).getId()); Assert.assertEquals(Id.create("n1", Node.class), path.nodes.get(1).getId()); Assert.assertEquals(Id.create("n2", Node.class), path.nodes.get(2).getId()); Assert.assertEquals(Id.create("n3", Node.class), path.nodes.get(3).getId()); - + Assert.assertEquals(3, path.links.size()); Assert.assertEquals(Id.create("l0", Link.class), path.links.get(0).getId()); Assert.assertEquals(Id.create("l1", Link.class), path.links.get(1).getId()); Assert.assertEquals(Id.create("l2", Link.class), path.links.get(2).getId()); } - + /* * Search only cheapest to node. n5 should not be found. */ @Test public void testBackwardsFastMultiNodeDijkstra_OneToMany() { - + Config config = ConfigUtils.createConfig(); - config.plansCalcRoute().setRoutingRandomness(0.); + config.routing().setRoutingRandomness(0.); Scenario scenario = ScenarioUtils.createScenario(config); - + createNetwork(scenario); TravelTime travelTime = new FreeSpeedTravelTime(); @@ -126,7 +126,7 @@ public void testBackwardsFastMultiNodeDijkstra_OneToMany() { config ).createTravelDisutility(travelTime ); BackwardFastMultiNodeDijkstra dijkstra = (BackwardFastMultiNodeDijkstra) new BackwardFastMultiNodeDijkstraFactory(false). createPathCalculator(scenario.getNetwork(), travelDisutility, travelTime); - + Node fromNode = scenario.getNetwork().getNodes().get(Id.create("n3", Node.class)); Node toNode1 = scenario.getNetwork().getNodes().get(Id.create("n0", Node.class)); Node toNode2 = scenario.getNetwork().getNodes().get(Id.create("n4", Node.class)); @@ -136,79 +136,79 @@ public void testBackwardsFastMultiNodeDijkstra_OneToMany() { toNodes.add(new InitialNode(toNode2, 0.0, 0.0)); toNodes.add(new InitialNode(toNode3, 0.0, 0.0)); Node toNode = dijkstra.createImaginaryNode(toNodes); - + /* * test calcLeastCostPath method */ Path path = dijkstra.calcLeastCostPath(fromNode, toNode, 3600.0, null, null); - + Assert.assertEquals(1.0, path.travelCost, 0.0); Assert.assertEquals(300.0, path.travelTime, 0.0); - + Assert.assertEquals(4, path.nodes.size()); Assert.assertEquals(Id.create("n0", Node.class), path.nodes.get(0).getId()); Assert.assertEquals(Id.create("n1", Node.class), path.nodes.get(1).getId()); Assert.assertEquals(Id.create("n2", Node.class), path.nodes.get(2).getId()); Assert.assertEquals(Id.create("n3", Node.class), path.nodes.get(3).getId()); - + Assert.assertEquals(3, path.links.size()); Assert.assertEquals(Id.create("l0", Link.class), path.links.get(0).getId()); Assert.assertEquals(Id.create("l1", Link.class), path.links.get(1).getId()); Assert.assertEquals(Id.create("l2", Link.class), path.links.get(2).getId()); - + /* * test constructPath method which uses data from the previous routing operation - toNode1 */ path = dijkstra.constructPath(fromNode, toNode1, 3600.0); - + Assert.assertEquals(1.0, path.travelCost, 0.0); Assert.assertEquals(300.0, path.travelTime, 0.0); - + Assert.assertEquals(4, path.nodes.size()); Assert.assertEquals(Id.create("n0", Node.class), path.nodes.get(0).getId()); Assert.assertEquals(Id.create("n1", Node.class), path.nodes.get(1).getId()); Assert.assertEquals(Id.create("n2", Node.class), path.nodes.get(2).getId()); Assert.assertEquals(Id.create("n3", Node.class), path.nodes.get(3).getId()); - + Assert.assertEquals(3, path.links.size()); Assert.assertEquals(Id.create("l0", Link.class), path.links.get(0).getId()); Assert.assertEquals(Id.create("l1", Link.class), path.links.get(1).getId()); Assert.assertEquals(Id.create("l2", Link.class), path.links.get(2).getId()); - + /* * test constructPath method which uses data from the previous routing operation - toNode2 */ path = dijkstra.constructPath(fromNode, toNode2, 3600.0); - + Assert.assertEquals(1.333, path.travelCost, 0.001); Assert.assertEquals(400.0, path.travelTime, 0.0); - + Assert.assertEquals(4, path.nodes.size()); Assert.assertEquals(Id.create("n4", Node.class), path.nodes.get(0).getId()); Assert.assertEquals(Id.create("n1", Node.class), path.nodes.get(1).getId()); Assert.assertEquals(Id.create("n2", Node.class), path.nodes.get(2).getId()); Assert.assertEquals(Id.create("n3", Node.class), path.nodes.get(3).getId()); - + Assert.assertEquals(3, path.links.size()); Assert.assertEquals(Id.create("l3", Link.class), path.links.get(0).getId()); Assert.assertEquals(Id.create("l1", Link.class), path.links.get(1).getId()); Assert.assertEquals(Id.create("l2", Link.class), path.links.get(2).getId()); - + /* * test constructPath method which uses data from the previous routing operation - toNode3 */ path = dijkstra.constructPath(fromNode, toNode3, 3600.0); - + Assert.assertNull(null); } - + @Test public void testBackwardsFastMultiNodeDijkstra_OneToMany_SearchAllNodes() { - + Config config = ConfigUtils.createConfig(); - config.plansCalcRoute().setRoutingRandomness(0.); + config.routing().setRoutingRandomness(0.); Scenario scenario = ScenarioUtils.createScenario(config); - + createNetwork(scenario); TravelTime travelTime = new FreeSpeedTravelTime(); @@ -216,7 +216,7 @@ public void testBackwardsFastMultiNodeDijkstra_OneToMany_SearchAllNodes() { config ).createTravelDisutility(travelTime ); BackwardFastMultiNodeDijkstra dijkstra = (BackwardFastMultiNodeDijkstra) new BackwardFastMultiNodeDijkstraFactory(true). createPathCalculator(scenario.getNetwork(), travelDisutility, travelTime); - + Node fromNode = scenario.getNetwork().getNodes().get(Id.create("n3", Node.class)); Node toNode1 = scenario.getNetwork().getNodes().get(Id.create("n0", Node.class)); Node toNode2 = scenario.getNetwork().getNodes().get(Id.create("n4", Node.class)); @@ -226,89 +226,89 @@ public void testBackwardsFastMultiNodeDijkstra_OneToMany_SearchAllNodes() { toNodes.add(new InitialNode(toNode2, 0.0, 0.0)); toNodes.add(new InitialNode(toNode3, 0.0, 0.0)); Node toNode = dijkstra.createImaginaryNode(toNodes); - + /* * test calcLeastCostPath method */ Path path = dijkstra.calcLeastCostPath(fromNode, toNode, 3600.0, null, null); - + Assert.assertEquals(1.0, path.travelCost, 0.0); Assert.assertEquals(300.0, path.travelTime, 0.0); - + Assert.assertEquals(4, path.nodes.size()); Assert.assertEquals(Id.create("n0", Node.class), path.nodes.get(0).getId()); Assert.assertEquals(Id.create("n1", Node.class), path.nodes.get(1).getId()); Assert.assertEquals(Id.create("n2", Node.class), path.nodes.get(2).getId()); Assert.assertEquals(Id.create("n3", Node.class), path.nodes.get(3).getId()); - + Assert.assertEquals(3, path.links.size()); Assert.assertEquals(Id.create("l0", Link.class), path.links.get(0).getId()); Assert.assertEquals(Id.create("l1", Link.class), path.links.get(1).getId()); Assert.assertEquals(Id.create("l2", Link.class), path.links.get(2).getId()); - + /* * test constructPath method which uses data from the previous routing operation - toNode1 */ path = dijkstra.constructPath(fromNode, toNode1, 3600.0); - + Assert.assertEquals(1.0, path.travelCost, 0.0); Assert.assertEquals(300.0, path.travelTime, 0.0); - + Assert.assertEquals(4, path.nodes.size()); Assert.assertEquals(Id.create("n0", Node.class), path.nodes.get(0).getId()); Assert.assertEquals(Id.create("n1", Node.class), path.nodes.get(1).getId()); Assert.assertEquals(Id.create("n2", Node.class), path.nodes.get(2).getId()); Assert.assertEquals(Id.create("n3", Node.class), path.nodes.get(3).getId()); - + Assert.assertEquals(3, path.links.size()); Assert.assertEquals(Id.create("l0", Link.class), path.links.get(0).getId()); Assert.assertEquals(Id.create("l1", Link.class), path.links.get(1).getId()); Assert.assertEquals(Id.create("l2", Link.class), path.links.get(2).getId()); - + /* * test constructPath method which uses data from the previous routing operation - toNode2 */ path = dijkstra.constructPath(fromNode, toNode2, 3600.0); - + Assert.assertEquals(1.333, path.travelCost, 0.001); Assert.assertEquals(400.0, path.travelTime, 0.0); - + Assert.assertEquals(4, path.nodes.size()); Assert.assertEquals(Id.create("n4", Node.class), path.nodes.get(0).getId()); Assert.assertEquals(Id.create("n1", Node.class), path.nodes.get(1).getId()); Assert.assertEquals(Id.create("n2", Node.class), path.nodes.get(2).getId()); Assert.assertEquals(Id.create("n3", Node.class), path.nodes.get(3).getId()); - + Assert.assertEquals(3, path.links.size()); Assert.assertEquals(Id.create("l3", Link.class), path.links.get(0).getId()); Assert.assertEquals(Id.create("l1", Link.class), path.links.get(1).getId()); Assert.assertEquals(Id.create("l2", Link.class), path.links.get(2).getId()); - + /* * test constructPath method which uses data from the previous routing operation - toNode3 */ path = dijkstra.constructPath(fromNode, toNode3, 3600.0); - + Assert.assertEquals(2.0, path.travelCost, 0.0); Assert.assertEquals(600.0, path.travelTime, 0.0); - + Assert.assertEquals(5, path.nodes.size()); Assert.assertEquals(Id.create("n5", Node.class), path.nodes.get(0).getId()); Assert.assertEquals(Id.create("n4", Node.class), path.nodes.get(1).getId()); Assert.assertEquals(Id.create("n1", Node.class), path.nodes.get(2).getId()); Assert.assertEquals(Id.create("n2", Node.class), path.nodes.get(3).getId()); Assert.assertEquals(Id.create("n3", Node.class), path.nodes.get(4).getId()); - + Assert.assertEquals(4, path.links.size()); Assert.assertEquals(Id.create("l4", Link.class), path.links.get(0).getId()); Assert.assertEquals(Id.create("l3", Link.class), path.links.get(1).getId()); Assert.assertEquals(Id.create("l1", Link.class), path.links.get(2).getId()); Assert.assertEquals(Id.create("l2", Link.class), path.links.get(3).getId()); } - + /* * Network structure - * + * * n0---l0---n1---l1---n2---l2---n3 * | * | @@ -336,7 +336,7 @@ private void createNetwork(Scenario scenario) { Node n4 = scenario.getNetwork().getFactory().createNode(Id.create("n4", Node.class), new Coord(1000.0, y1)); double y = -4000.0; Node n5 = scenario.getNetwork().getFactory().createNode(Id.create("n5", Node.class), new Coord(1000.0, y)); - + /* * create links */ @@ -345,7 +345,7 @@ private void createNetwork(Scenario scenario) { Link l2 = scenario.getNetwork().getFactory().createLink(Id.create("l2", Link.class), n2, n3); Link l3 = scenario.getNetwork().getFactory().createLink(Id.create("l3", Link.class), n4, n1); Link l4 = scenario.getNetwork().getFactory().createLink(Id.create("l4", Link.class), n5, n4); - + /* * set link parameter */ @@ -354,13 +354,13 @@ private void createNetwork(Scenario scenario) { l2.setLength(1000.0); l3.setLength(2000.0); l4.setLength(2000.0); - + l0.setFreespeed(10.0); l1.setFreespeed(10.0); l2.setFreespeed(10.0); l3.setFreespeed(10.0); l4.setFreespeed(10.0); - + /* * add nodes to network */ @@ -370,7 +370,7 @@ private void createNetwork(Scenario scenario) { scenario.getNetwork().addNode(n3); scenario.getNetwork().addNode(n4); scenario.getNetwork().addNode(n5); - + /* * add links to network */ diff --git a/contribs/locationchoice/src/test/java/org/matsim/core/router/FastMultiNodeTest.java b/contribs/locationchoice/src/test/java/org/matsim/core/router/FastMultiNodeTest.java index ad2af47c972..1dc5a2a4650 100644 --- a/contribs/locationchoice/src/test/java/org/matsim/core/router/FastMultiNodeTest.java +++ b/contribs/locationchoice/src/test/java/org/matsim/core/router/FastMultiNodeTest.java @@ -44,19 +44,19 @@ * Some more tests - but all of them assuming that there is only * a single from node as in the location choice use case. * For test using multiple from nodes look at MultiNodeDijkstraTest! - * + * * @author cdobler */ public class FastMultiNodeTest { - + @Test public void testFastMultiNodeDijkstra_OneToOne() { - + Config config = ConfigUtils.createConfig(); - config.plansCalcRoute().setRoutingRandomness( 0. ); + config.routing().setRoutingRandomness( 0. ); Scenario scenario = ScenarioUtils.createScenario(config); - + createNetwork(scenario); TravelTime travelTime = new FreeSpeedTravelTime(); @@ -64,57 +64,57 @@ public void testFastMultiNodeDijkstra_OneToOne() { config ).createTravelDisutility(travelTime ); FastMultiNodeDijkstra dijkstra = (FastMultiNodeDijkstra) new FastMultiNodeDijkstraFactory(). createPathCalculator(scenario.getNetwork(), travelDisutility, travelTime); - + Node fromNode = scenario.getNetwork().getNodes().get(Id.create("n0", Node.class)); Node toNode = scenario.getNetwork().getNodes().get(Id.create("n3", Node.class)); - + /* * test calcLeastCostPath method */ Path path = dijkstra.calcLeastCostPath(fromNode, toNode, 3600.0, null, null); - + Assert.assertEquals(1.0, path.travelCost, 0.0); Assert.assertEquals(300.0, path.travelTime, 0.0); - + Assert.assertEquals(4, path.nodes.size()); Assert.assertEquals(Id.create("n0", Node.class), path.nodes.get(0).getId()); Assert.assertEquals(Id.create("n1", Node.class), path.nodes.get(1).getId()); Assert.assertEquals(Id.create("n2", Node.class), path.nodes.get(2).getId()); Assert.assertEquals(Id.create("n3", Node.class), path.nodes.get(3).getId()); - + Assert.assertEquals(3, path.links.size()); Assert.assertEquals(Id.create("l0", Link.class), path.links.get(0).getId()); Assert.assertEquals(Id.create("l1", Link.class), path.links.get(1).getId()); Assert.assertEquals(Id.create("l2", Link.class), path.links.get(2).getId()); - + /* * test constructPath method which uses data from the previous routing operation */ path = dijkstra.constructPath(fromNode, toNode, 3600.0); - + Assert.assertEquals(1.0, path.travelCost, 0.0); Assert.assertEquals(300.0, path.travelTime, 0.0); - + Assert.assertEquals(4, path.nodes.size()); Assert.assertEquals(Id.create("n0", Node.class), path.nodes.get(0).getId()); Assert.assertEquals(Id.create("n1", Node.class), path.nodes.get(1).getId()); Assert.assertEquals(Id.create("n2", Node.class), path.nodes.get(2).getId()); Assert.assertEquals(Id.create("n3", Node.class), path.nodes.get(3).getId()); - + Assert.assertEquals(3, path.links.size()); Assert.assertEquals(Id.create("l0", Link.class), path.links.get(0).getId()); Assert.assertEquals(Id.create("l1", Link.class), path.links.get(1).getId()); Assert.assertEquals(Id.create("l2", Link.class), path.links.get(2).getId()); } - + @Test public void testFastMultiNodeDijkstra_OneToMany() { - + Config config = ConfigUtils.createConfig(); - config.plansCalcRoute().setRoutingRandomness( 0. ); + config.routing().setRoutingRandomness( 0. ); Scenario scenario = ScenarioUtils.createScenario(config); - + createNetwork(scenario); TravelTime travelTime = new FreeSpeedTravelTime(); @@ -122,7 +122,7 @@ public void testFastMultiNodeDijkstra_OneToMany() { config ).createTravelDisutility(travelTime ); FastMultiNodeDijkstra dijkstra = (FastMultiNodeDijkstra) new FastMultiNodeDijkstraFactory(false). createPathCalculator(scenario.getNetwork(), travelDisutility, travelTime); - + Node fromNode = scenario.getNetwork().getNodes().get(Id.create("n0", Node.class)); Node toNode1 = scenario.getNetwork().getNodes().get(Id.create("n3", Node.class)); Node toNode2 = scenario.getNetwork().getNodes().get(Id.create("n4", Node.class)); @@ -132,80 +132,80 @@ public void testFastMultiNodeDijkstra_OneToMany() { toNodes.add(new InitialNode(toNode2, 0.0, 0.0)); toNodes.add(new InitialNode(toNode3, 0.0, 0.0)); Node toNode = dijkstra.createImaginaryNode(toNodes); - + /* * test calcLeastCostPath method */ Path path = dijkstra.calcLeastCostPath(fromNode, toNode, 3600.0, null, null); - + Assert.assertEquals(1.0, path.travelCost, 0.0); Assert.assertEquals(300.0, path.travelTime, 0.0); - + Assert.assertEquals(4, path.nodes.size()); Assert.assertEquals(Id.create("n0", Node.class), path.nodes.get(0).getId()); Assert.assertEquals(Id.create("n1", Node.class), path.nodes.get(1).getId()); Assert.assertEquals(Id.create("n2", Node.class), path.nodes.get(2).getId()); Assert.assertEquals(Id.create("n3", Node.class), path.nodes.get(3).getId()); - + Assert.assertEquals(3, path.links.size()); Assert.assertEquals(Id.create("l0", Link.class), path.links.get(0).getId()); Assert.assertEquals(Id.create("l1", Link.class), path.links.get(1).getId()); Assert.assertEquals(Id.create("l2", Link.class), path.links.get(2).getId()); - + /* * test constructPath method which uses data from the previous routing operation - toNode1 */ path = dijkstra.constructPath(fromNode, toNode1, 3600.0); - + Assert.assertEquals(1.0, path.travelCost, 0.0); Assert.assertEquals(300.0, path.travelTime, 0.0); - + Assert.assertEquals(4, path.nodes.size()); Assert.assertEquals(Id.create("n0", Node.class), path.nodes.get(0).getId()); Assert.assertEquals(Id.create("n1", Node.class), path.nodes.get(1).getId()); Assert.assertEquals(Id.create("n2", Node.class), path.nodes.get(2).getId()); Assert.assertEquals(Id.create("n3", Node.class), path.nodes.get(3).getId()); - + Assert.assertEquals(3, path.links.size()); Assert.assertEquals(Id.create("l0", Link.class), path.links.get(0).getId()); Assert.assertEquals(Id.create("l1", Link.class), path.links.get(1).getId()); Assert.assertEquals(Id.create("l2", Link.class), path.links.get(2).getId()); - + /* * test constructPath method which uses data from the previous routing operation - toNode2 */ path = dijkstra.constructPath(fromNode, toNode2, 3600.0); - + Assert.assertEquals(1.333, path.travelCost, 0.001); Assert.assertEquals(400.0, path.travelTime, 0.0); - + Assert.assertEquals(4, path.nodes.size()); Assert.assertEquals(Id.create("n0", Node.class), path.nodes.get(0).getId()); Assert.assertEquals(Id.create("n1", Node.class), path.nodes.get(1).getId()); Assert.assertEquals(Id.create("n2", Node.class), path.nodes.get(2).getId()); Assert.assertEquals(Id.create("n4", Node.class), path.nodes.get(3).getId()); - + Assert.assertEquals(3, path.links.size()); Assert.assertEquals(Id.create("l0", Link.class), path.links.get(0).getId()); Assert.assertEquals(Id.create("l1", Link.class), path.links.get(1).getId()); Assert.assertEquals(Id.create("l3", Link.class), path.links.get(2).getId()); - + /* * test constructPath method which uses data from the previous routing operation - toNode3 */ path = dijkstra.constructPath(fromNode, toNode3, 3600.0); - + Assert.assertNull(path); } - + @Test public void testFastMultiNodeDijkstra_OneToMany_SearchAllNodes() { - + Config config = ConfigUtils.createConfig(); - config.plansCalcRoute().setRoutingRandomness( 0. ); + config.routing().setRoutingRandomness( 0. ); Scenario scenario = ScenarioUtils.createScenario(config); - + createNetwork(scenario); TravelTime travelTime = new FreeSpeedTravelTime(); @@ -213,7 +213,7 @@ public void testFastMultiNodeDijkstra_OneToMany_SearchAllNodes() { config ).createTravelDisutility(travelTime ); FastMultiNodeDijkstra dijkstra = (FastMultiNodeDijkstra) new FastMultiNodeDijkstraFactory(true). createPathCalculator(scenario.getNetwork(), travelDisutility, travelTime); - + Node fromNode = scenario.getNetwork().getNodes().get(Id.create("n0", Node.class)); Node toNode1 = scenario.getNetwork().getNodes().get(Id.create("n3", Node.class)); Node toNode2 = scenario.getNetwork().getNodes().get(Id.create("n4", Node.class)); @@ -223,89 +223,89 @@ public void testFastMultiNodeDijkstra_OneToMany_SearchAllNodes() { toNodes.add(new InitialNode(toNode2, 0.0, 0.0)); toNodes.add(new InitialNode(toNode3, 0.0, 0.0)); Node toNode = dijkstra.createImaginaryNode(toNodes); - + /* * test calcLeastCostPath method */ Path path = dijkstra.calcLeastCostPath(fromNode, toNode, 3600.0, null, null); - + Assert.assertEquals(1.0, path.travelCost, 0.0); Assert.assertEquals(300.0, path.travelTime, 0.0); - + Assert.assertEquals(4, path.nodes.size()); Assert.assertEquals(Id.create("n0", Node.class), path.nodes.get(0).getId()); Assert.assertEquals(Id.create("n1", Node.class), path.nodes.get(1).getId()); Assert.assertEquals(Id.create("n2", Node.class), path.nodes.get(2).getId()); Assert.assertEquals(Id.create("n3", Node.class), path.nodes.get(3).getId()); - + Assert.assertEquals(3, path.links.size()); Assert.assertEquals(Id.create("l0", Link.class), path.links.get(0).getId()); Assert.assertEquals(Id.create("l1", Link.class), path.links.get(1).getId()); Assert.assertEquals(Id.create("l2", Link.class), path.links.get(2).getId()); - + /* * test constructPath method which uses data from the previous routing operation - toNode1 */ path = dijkstra.constructPath(fromNode, toNode1, 3600.0); - + Assert.assertEquals(1.0, path.travelCost, 0.0); Assert.assertEquals(300.0, path.travelTime, 0.0); - + Assert.assertEquals(4, path.nodes.size()); Assert.assertEquals(Id.create("n0", Node.class), path.nodes.get(0).getId()); Assert.assertEquals(Id.create("n1", Node.class), path.nodes.get(1).getId()); Assert.assertEquals(Id.create("n2", Node.class), path.nodes.get(2).getId()); Assert.assertEquals(Id.create("n3", Node.class), path.nodes.get(3).getId()); - + Assert.assertEquals(3, path.links.size()); Assert.assertEquals(Id.create("l0", Link.class), path.links.get(0).getId()); Assert.assertEquals(Id.create("l1", Link.class), path.links.get(1).getId()); Assert.assertEquals(Id.create("l2", Link.class), path.links.get(2).getId()); - + /* * test constructPath method which uses data from the previous routing operation - toNode2 */ path = dijkstra.constructPath(fromNode, toNode2, 3600.0); - + Assert.assertEquals(1.333, path.travelCost, 0.001); Assert.assertEquals(400.0, path.travelTime, 0.0); - + Assert.assertEquals(4, path.nodes.size()); Assert.assertEquals(Id.create("n0", Node.class), path.nodes.get(0).getId()); Assert.assertEquals(Id.create("n1", Node.class), path.nodes.get(1).getId()); Assert.assertEquals(Id.create("n2", Node.class), path.nodes.get(2).getId()); Assert.assertEquals(Id.create("n4", Node.class), path.nodes.get(3).getId()); - + Assert.assertEquals(3, path.links.size()); Assert.assertEquals(Id.create("l0", Link.class), path.links.get(0).getId()); Assert.assertEquals(Id.create("l1", Link.class), path.links.get(1).getId()); Assert.assertEquals(Id.create("l3", Link.class), path.links.get(2).getId()); - + /* * test constructPath method which uses data from the previous routing operation - toNode3 */ path = dijkstra.constructPath(fromNode, toNode3, 3600.0); - + Assert.assertEquals(2.0, path.travelCost, 0.0); Assert.assertEquals(600.0, path.travelTime, 0.0); - + Assert.assertEquals(5, path.nodes.size()); Assert.assertEquals(Id.create("n0", Node.class), path.nodes.get(0).getId()); Assert.assertEquals(Id.create("n1", Node.class), path.nodes.get(1).getId()); Assert.assertEquals(Id.create("n2", Node.class), path.nodes.get(2).getId()); Assert.assertEquals(Id.create("n4", Node.class), path.nodes.get(3).getId()); Assert.assertEquals(Id.create("n5", Node.class), path.nodes.get(4).getId()); - + Assert.assertEquals(4, path.links.size()); Assert.assertEquals(Id.create("l0", Link.class), path.links.get(0).getId()); Assert.assertEquals(Id.create("l1", Link.class), path.links.get(1).getId()); Assert.assertEquals(Id.create("l3", Link.class), path.links.get(2).getId()); Assert.assertEquals(Id.create("l4", Link.class), path.links.get(3).getId()); } - + /* * Network structure - * + * * n0---l0---n1---l1---n2---l2---n3 * | * | @@ -333,7 +333,7 @@ private static void createNetwork( Scenario scenario ) { Node n4 = scenario.getNetwork().getFactory().createNode(Id.create("n4", Node.class), new Coord(2000.0, y1)); double y = -4000.0; Node n5 = scenario.getNetwork().getFactory().createNode(Id.create("n5", Node.class), new Coord(2000.0, y)); - + /* * create links */ @@ -342,7 +342,7 @@ private static void createNetwork( Scenario scenario ) { Link l2 = scenario.getNetwork().getFactory().createLink(Id.create("l2", Link.class), n2, n3); Link l3 = scenario.getNetwork().getFactory().createLink(Id.create("l3", Link.class), n2, n4); Link l4 = scenario.getNetwork().getFactory().createLink(Id.create("l4", Link.class), n4, n5); - + /* * set link parameter */ @@ -351,13 +351,13 @@ private static void createNetwork( Scenario scenario ) { l2.setLength(1000.0); l3.setLength(2000.0); l4.setLength(2000.0); - + l0.setFreespeed(10.0); l1.setFreespeed(10.0); l2.setFreespeed(10.0); l3.setFreespeed(10.0); l4.setFreespeed(10.0); - + /* * add nodes to network */ @@ -367,7 +367,7 @@ private static void createNetwork( Scenario scenario ) { scenario.getNetwork().addNode(n3); scenario.getNetwork().addNode(n4); scenario.getNetwork().addNode(n5); - + /* * add links to network */ diff --git a/contribs/matrixbasedptrouter/src/test/java/org/matsim/contrib/matrixbasedptrouter/MatrixBasedPtRouterIT.java b/contribs/matrixbasedptrouter/src/test/java/org/matsim/contrib/matrixbasedptrouter/MatrixBasedPtRouterIT.java index a7d4aaf5ddd..2e10edddfa8 100644 --- a/contribs/matrixbasedptrouter/src/test/java/org/matsim/contrib/matrixbasedptrouter/MatrixBasedPtRouterIT.java +++ b/contribs/matrixbasedptrouter/src/test/java/org/matsim/contrib/matrixbasedptrouter/MatrixBasedPtRouterIT.java @@ -18,7 +18,7 @@ * *********************************************************************** */ /** - * + * */ package org.matsim.contrib.matrixbasedptrouter; @@ -65,19 +65,19 @@ public class MatrixBasedPtRouterIT { */ @Test public void testIntegration() throws IOException { - + String path = utils.getOutputDirectory(); - - - + + + //a dummy network is created and written into the output directory Network network = CreateTestNetwork.createTestNetwork(); new NetworkWriter(network).write(path+"network.xml"); - + //a dummy population of one person is created and written into the output directory Population population = CreateTestPopulation.createTestPtPopulation(1, new Coord((double) 0, (double) 0), new Coord((double) 0, (double) 200)); new PopulationWriter(population, network).write(path+"plans.xml"); - + //dummy csv files for pt stops, travel times and travel distances fitting into the dummy network are created String stopsLocation = CreateTestNetwork.createTestPtStationCSVFile(folder.newFile("ptStops.csv")); String timesLocation = CreateTestNetwork.createTestPtTravelTimesAndDistancesCSVFile(folder.newFile("ptTravelInfo.csv")); @@ -95,40 +95,40 @@ public void testIntegration() throws IOException { config.addModule(matrixBasedPtRouterConfigGroup) ; - + //modification of the config according to what's needed - config.controler().setMobsim("qsim"); - config.controler().setFirstIteration(0); - config.controler().setLastIteration(0); - config.controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles); + config.controller().setMobsim("qsim"); + config.controller().setFirstIteration(0); + config.controller().setLastIteration(0); + config.controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles); config.network().setInputFile(path+"network.xml"); config.plans().setInputFile(path+"plans.xml"); //add home and work activity to plansCalcScoreConfigGroup - config.planCalcScore().addParam("activityType_0", "home"); - config.planCalcScore().addParam("activityTypicalDuration_0", "43200"); - config.planCalcScore().addParam("activityType_1", "work"); - config.planCalcScore().addParam("activityTypicalDuration_1", "28800"); + config.scoring().addParam("activityType_0", "home"); + config.scoring().addParam("activityTypicalDuration_0", "43200"); + config.scoring().addParam("activityType_1", "work"); + config.scoring().addParam("activityTypicalDuration_1", "28800"); Scenario scenario = ScenarioUtils.loadScenario(config); BoundingBox nbb = BoundingBox.createBoundingBox(network); - final PtMatrix ptMatrix = PtMatrix.createPtMatrix(config.plansCalcRoute(), nbb, ConfigUtils.addOrGetModule(config, MatrixBasedPtRouterConfigGroup.GROUP_NAME, MatrixBasedPtRouterConfigGroup.class)); + final PtMatrix ptMatrix = PtMatrix.createPtMatrix(config.routing(), nbb, ConfigUtils.addOrGetModule(config, MatrixBasedPtRouterConfigGroup.GROUP_NAME, MatrixBasedPtRouterConfigGroup.class)); Controler controler = new Controler(scenario) ; controler.addOverridingModule(new MatrixBasedPtModule()); controler.run(); - + // compute the travel time from home to work activity double ttime = ptMatrix.getTotalTravelTime_seconds(new Coord((double) 0, (double) 0), new Coord((double) 0, (double) 200)); // get the actual travel time from the person's plan Person person = controler.getScenario().getPopulation().getPersons().values().iterator().next(); double actualTtime = ((Leg)person.getSelectedPlan().getPlanElements().get(1)).getTravelTime().seconds(); - + //compare computed and actual travel time Assert.assertEquals(ttime, actualTtime, 0); - + } } diff --git a/contribs/matrixbasedptrouter/src/test/java/org/matsim/contrib/matrixbasedptrouter/PtMatrixTest.java b/contribs/matrixbasedptrouter/src/test/java/org/matsim/contrib/matrixbasedptrouter/PtMatrixTest.java index aeebf4c30e7..0b029d1f749 100644 --- a/contribs/matrixbasedptrouter/src/test/java/org/matsim/contrib/matrixbasedptrouter/PtMatrixTest.java +++ b/contribs/matrixbasedptrouter/src/test/java/org/matsim/contrib/matrixbasedptrouter/PtMatrixTest.java @@ -18,7 +18,7 @@ * *********************************************************************** */ /** - * + * */ package org.matsim.contrib.matrixbasedptrouter; @@ -46,30 +46,30 @@ /** * This class tests the pt simulation of MATSim for a simple network created with CreateTestNetwork.java. * It checks the values of pt distances and times from the pt matrix for this network. - * + * * MATSim always calculates the total pt time and distance respectively between origin and destination facility as a sum of the following three values: * 1. the walk time and distance respectively from the origin facility to the nearest pt stop, * 2. the pt time and distance respectively between this origin pt stop and the destination pt stop, which is the nearest one from the destination facility, * 3. the walk time and distance respectively from this destination pt stop to the destination facility. - * + * * MATSim offers to possibilities to use pt simulation, which differ in the information you have to provide: * 1. The calculation of pt times and distances only from the information about the coordinates of pt stops and facilities. * For this calculation the euclidean distance between the pt stops and a given pt speed is used. * 2. The pt simulation with the additional information about the pt times and distances between all possible pt stops. - * + * * The walk distances always are calculated as the euclidean distances between facilities and pt stops. The walk times corresponds to these distances for a given walk speed. - * + * * In our test network the euclidean distance between a facility and its nearest pt stop is always 50 m. So the total walk distance always is 100 m. * If origin and destination pt stop coincide, the agents still have to walk via the pt stop to their destination. Even if origin and destination facility are the same. * Moreover there are four pt stops ordered as a square with an euclidean distance of 180 m as the distance between to neighboring pt stops. * There are four facilities, each corresponding to one of the four pt stop. * The distance between to facilities is always bigger than the distance between their corresponding pt stops. So the euclidean distance between to facilities is an upper bound for the distance between to pt stops. - * + * * @author thomas * @author tthunig */ public class PtMatrixTest { - + private static final Logger log = LogManager.getLogger(PtMatrixTest.class); @Rule @@ -81,30 +81,30 @@ public void setUp() throws Exception { // (collect log messages internally before they can be written to file. Can be called multiple times without harm.) } - + /** * tests the pt matrix for the first case, when only the coordinates of the pt stops are known - * @throws IOException + * @throws IOException */ @Test public void testPtMatrixStops() throws IOException{ log.info("Start testing the pt matrix with information about the pt stops."); long start = System.currentTimeMillis(); - - + + // some default values double defaultWalkSpeed = 1.; // in m/s double defaultPtSpeed = 10.; // in m/s double beelineDistanceFactor = 2.; // a multiplier for the pt travel distance Config config = ConfigUtils.createConfig() ; - config.plansCalcRoute().setBeelineDistanceFactor(beelineDistanceFactor ) ; - config.plansCalcRoute().setTeleportedModeSpeed(TransportMode.walk, defaultWalkSpeed) ; - config.plansCalcRoute().setTeleportedModeSpeed(TransportMode.pt, defaultPtSpeed ) ; + config.routing().setBeelineDistanceFactor(beelineDistanceFactor ) ; + config.routing().setTeleportedModeSpeed(TransportMode.walk, defaultWalkSpeed) ; + config.routing().setTeleportedModeSpeed(TransportMode.pt, defaultPtSpeed ) ; Network network = CreateTestNetwork.createTestNetwork(); // creates a dummy network String location = CreateTestNetwork.createTestPtStationCSVFile(folder.newFile("ptStops.csv")); // creates a dummy csv file with pt stops fitting into the dummy network - + MatrixBasedPtRouterConfigGroup module = new MatrixBasedPtRouterConfigGroup(); module.setPtStopsInputFile(location); // this is to be compatible with real code config.addModule(module) ; @@ -112,98 +112,98 @@ public void testPtMatrixStops() throws IOException{ // determining the bounds minX/minY -- maxX/maxY. For optimal performance of the QuadTree. All pt stops should be evenly distributed within this rectangle. BoundingBox nbb = BoundingBox.createBoundingBox(network); // call and init the pt matrix - PtMatrix ptm = PtMatrix.createPtMatrix(config.plansCalcRoute(), nbb, module); + PtMatrix ptm = PtMatrix.createPtMatrix(config.routing(), nbb, module); // test the matrix List facilityList = CreateTestNetwork.getTestFacilityLocations(); - + for(int origin = 0; origin < facilityList.size(); origin++){ for(int destination = 0; destination < facilityList.size(); destination++){ - + // calculate travel times double totalTravelTime = ptm.getTotalTravelTime_seconds(facilityList.get( origin ), facilityList.get( destination )); double walkTravelTime = ptm.getTotalWalkTravelTime_seconds(facilityList.get( origin ), facilityList.get( destination )); double ptTravelTime = ptm.getPtTravelTime_seconds(facilityList.get( origin ), facilityList.get( destination )); - + // calculate travel distances double totalTravelDistance= ptm.getTotalTravelDistance_meter(facilityList.get( origin ), facilityList.get( destination )); double walkTravelDistance = ptm.getTotalWalkTravelDistance_meter(facilityList.get( origin ), facilityList.get( destination )); double ptTravelDistance = ptm.getPtTravelDistance_meter(facilityList.get( origin ), facilityList.get( destination )); - + log.info("From: " + facilityList.get( origin ).getX()+":"+facilityList.get( origin ).getY() + ", To: " + facilityList.get( destination ).getX()+":"+facilityList.get( destination ).getY() + ", TravelTime: " + totalTravelTime + ", Travel Distance: " + totalTravelDistance); - + // test travel time and distance for same origins and destinations // the agents will walk 50 m to the nearest pt stop and 50 m back to their origin facility, so the total travel distance have to be 100 m. if(origin == destination){ - + Assert.assertTrue(totalTravelTime == 100./defaultWalkSpeed); Assert.assertTrue(totalTravelDistance == 100.); } - + // test travel time and distance for neighboring origins and destinations else if( (origin + 1) % 4 == destination || (origin + 3) % 4 == destination){ - + // test total walk travel distance and time // in the test network the total walk distance always is 100 m, because the euclidean distance between a facility and its nearest pt stop always is 50 m Assert.assertTrue(walkTravelDistance == 100.); Assert.assertTrue(walkTravelTime == 100./defaultWalkSpeed); - + // test pt travel distance and time // in the test network the euclidean distance between neighboring pt stops always is 180 m Assert.assertTrue(ptTravelDistance == 180.*beelineDistanceFactor); Assert.assertTrue(ptTravelTime == (180./defaultPtSpeed)*beelineDistanceFactor); } - + // test travel times and distances for diagonal origin destination pairs else { // In our test network pt stops are closer to each other than facilities. // So an upper bound for the pt travel distance is the euclidean distance between the facilities (analog for the travel time). // A lower bound for pt travel distance and time are the values of neighboring origin destination pairs. - + double euclideanDistance= CoordUtils.calcEuclideanDistance(facilityList.get( origin ), facilityList.get( destination )); - + // test total walk travel distance and time // in the test network the total walk distance always is 100 m, because the euclidean distance between a facility and its nearest pt stop always is 50 m Assert.assertTrue(walkTravelDistance == 100.); Assert.assertTrue(walkTravelTime == 100./defaultWalkSpeed); - + // test upper bounds for pt travel distance and time (as described above) Assert.assertTrue(ptTravelDistance <= euclideanDistance*beelineDistanceFactor); Assert.assertTrue(ptTravelTime <= (euclideanDistance/defaultPtSpeed)*beelineDistanceFactor); - + // test lower bounds for pt travel distance and time (as described above) Assert.assertTrue(ptTravelDistance >= 180.*beelineDistanceFactor); Assert.assertTrue(ptTravelTime >= (180./defaultPtSpeed)*beelineDistanceFactor); } } } - + log.info("Creating pt matrix took " + ((System.currentTimeMillis() - start)/60000) + " minutes. Computation done!"); } - - + + /** * tests the pt matrix for the second case, when pt stops and pt travel times and distances are known - * + * * the values for the pt distances and times are given from a csv-file created with CreateTestNetwork.java - * For reasons of simplification we use the same csv-file for both informations (times and distances). Between all pt stops we set the pt distance to 100 m and the pt travel time to 100 min, except pairs of same pt stops, where we set both informations to zero. - * @throws IOException + * For reasons of simplification we use the same csv-file for both informations (times and distances). Between all pt stops we set the pt distance to 100 m and the pt travel time to 100 min, except pairs of same pt stops, where we set both informations to zero. + * @throws IOException */ @Test public void testPtMatrixTimesAndDistances() throws IOException{ log.info("Start testing the pt matrix with information about the pt stops, pt travel times and distances."); long start = System.currentTimeMillis(); - - + + // some default values double defaultWalkSpeed = 1.; // in m/s double defaultPtSpeed = 10.; // in m/s double beelineDistanceFactor = 2.; // a multiplier for the pt travel distance - + Config config = ConfigUtils.createConfig() ; - config.plansCalcRoute().setBeelineDistanceFactor(beelineDistanceFactor ) ; - config.plansCalcRoute().setTeleportedModeSpeed(TransportMode.walk, defaultWalkSpeed) ; - config.plansCalcRoute().setTeleportedModeSpeed(TransportMode.pt, defaultPtSpeed ) ; + config.routing().setBeelineDistanceFactor(beelineDistanceFactor ) ; + config.routing().setTeleportedModeSpeed(TransportMode.walk, defaultWalkSpeed) ; + config.routing().setTeleportedModeSpeed(TransportMode.pt, defaultPtSpeed ) ; Network network = CreateTestNetwork.createTestNetwork(); // creates a dummy network @@ -213,49 +213,49 @@ public void testPtMatrixTimesAndDistances() throws IOException{ MatrixBasedPtRouterConfigGroup module = new MatrixBasedPtRouterConfigGroup(); module.setUsingPtStops(true); module.setUsingTravelTimesAndDistances(true); - module.setPtStopsInputFile(stopsLocation); - module.setPtTravelTimesInputFile(timesLocation); + module.setPtStopsInputFile(stopsLocation); + module.setPtTravelTimesInputFile(timesLocation); module.setPtTravelDistancesInputFile(timesLocation); // determining the bounds minX/minY -- maxX/maxY. For optimal performance of the QuadTree. All pt stops should be evenly distributed within this rectangle. BoundingBox nbb = BoundingBox.createBoundingBox(network); // call and init the pt matrix - PtMatrix ptm = PtMatrix.createPtMatrix(config.plansCalcRoute(), nbb, module); + PtMatrix ptm = PtMatrix.createPtMatrix(config.routing(), nbb, module); // test the matrix List facilityList = CreateTestNetwork.getTestFacilityLocations(); - + for(int origin = 0; origin < facilityList.size(); origin++){ for(int destination = 0; destination < facilityList.size(); destination++){ - + // calculate travel times double totalTravelTime = ptm.getTotalTravelTime_seconds(facilityList.get( origin ), facilityList.get( destination )); double walkTravelTime = ptm.getTotalWalkTravelTime_seconds(facilityList.get( origin ), facilityList.get( destination )); double ptTravelTime = ptm.getPtTravelTime_seconds(facilityList.get( origin ), facilityList.get( destination )); - + // calculate travel distances double totalTravelDistance= ptm.getTotalTravelDistance_meter(facilityList.get( origin ), facilityList.get( destination )); double walkTravelDistance = ptm.getTotalWalkTravelDistance_meter(facilityList.get( origin ), facilityList.get( destination )); double ptTravelDistance = ptm.getPtTravelDistance_meter(facilityList.get( origin ), facilityList.get( destination )); - + log.info("From: " + facilityList.get( origin ).getX()+":"+facilityList.get( origin ).getY() + ", To: " + facilityList.get( destination ).getX()+":"+facilityList.get( destination ).getY() + ", TravelTime: " + totalTravelTime + ", Travel Distance: " + totalTravelDistance); - + // test travel time and distance for same origins and destinations // the agents will walk 50 m to the nearest pt stop and 50 m back to their origin facility, so the total travel distance have to be 100 m. if(origin == destination){ - + Assert.assertTrue(totalTravelDistance == 100.); Assert.assertTrue(totalTravelTime == 100./defaultWalkSpeed); } - + // test travel time and distance for different origins and destinations else { - + // test total walk travel distance and time // in the test network the total walk distance always is 100 m, because the euclidean distance between a facility and its nearest pt stop always is 50 m Assert.assertTrue(walkTravelDistance == 100.); Assert.assertTrue(walkTravelTime == 100./defaultWalkSpeed); - + // test pt travel distance and time // in the csv-file the pt travel distance is given as 100 m; the pt travel time as 100 min Assert.assertTrue(ptTravelDistance == 100.); @@ -263,8 +263,8 @@ public void testPtMatrixTimesAndDistances() throws IOException{ } } } - + log.info("Creating pt matrix took " + ((System.currentTimeMillis() - start)/60000) + " minutes. Computation done!"); } -} \ No newline at end of file +} diff --git a/contribs/minibus/src/main/java/org/matsim/contrib/minibus/RunConfigurableMinibusExample.java b/contribs/minibus/src/main/java/org/matsim/contrib/minibus/RunConfigurableMinibusExample.java index 1b0eb2e684b..399088ffdb7 100644 --- a/contribs/minibus/src/main/java/org/matsim/contrib/minibus/RunConfigurableMinibusExample.java +++ b/contribs/minibus/src/main/java/org/matsim/contrib/minibus/RunConfigurableMinibusExample.java @@ -26,9 +26,6 @@ import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; -import org.matsim.contrib.minibus.fare.StageContainer; -import org.matsim.contrib.minibus.fare.TicketMachineDefaultImpl; -import org.matsim.contrib.minibus.fare.TicketMachineI; import org.matsim.contrib.minibus.hook.PModule; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; @@ -39,7 +36,7 @@ /** * Entry point, registers all necessary hooks - * + * * @author aneumann */ public final class RunConfigurableMinibusExample { @@ -55,16 +52,16 @@ public static void main(final String[] args) { } Config config = ConfigUtils.loadConfig( args[0], new PConfigGroup() ) ; - final PConfigGroup pConfig = ConfigUtils.addOrGetModule(config, PConfigGroup.class) ; + final PConfigGroup pConfig = ConfigUtils.addOrGetModule(config, PConfigGroup.class) ; Scenario scenario = ScenarioUtils.loadScenario(config); final Set> subsidizedStops = new TreeSet<>() ; // subsidizedStops.add(...) ; // add subsidized stops - + Controler controler = new Controler(scenario); - controler.getConfig().controler().setCreateGraphs(false); - + controler.getConfig().controller().setCreateGraphs(false); + if ( true ) { throw new RuntimeException("the following is not possibly any more; just copy PModule and modify it to your needs. kai, jan'17") ; } @@ -73,18 +70,18 @@ public static void main(final String[] args) { // @Override public double getFare(StageContainer stageContainer) { // double fare = delegate.getFare(stageContainer) ; // if ( subsidizedStops.contains( stageContainer.getStopEntered() ) ) { -// fare+=1. ; +// fare+=1. ; // // this would increase the fare for the subsidized stops ... // // ... but I fear that this also means that the passengers have to pay this. kai, jan'17 // } // return fare ; // } // }) ; - - + + controler.addOverridingModule(new PModule()) ; controler.run(); - } -} \ No newline at end of file + } +} diff --git a/contribs/minibus/src/main/java/org/matsim/contrib/minibus/hook/PBox.java b/contribs/minibus/src/main/java/org/matsim/contrib/minibus/hook/PBox.java index df5a721b2e1..795398d69fe 100644 --- a/contribs/minibus/src/main/java/org/matsim/contrib/minibus/hook/PBox.java +++ b/contribs/minibus/src/main/java/org/matsim/contrib/minibus/hook/PBox.java @@ -129,7 +129,7 @@ void notifyStartup(StartupEvent event) { this.operators.addAll(operatorsFromSchedule); // init initial set of operators - reduced by the number of preset operators - LinkedList initialOperators = this.operatorInitializer.createAdditionalOperators(this.strategyManager, event.getServices().getConfig().controler().getFirstIteration(), (this.pConfig.getNumberOfOperators() - operatorsFromSchedule.size())); + LinkedList initialOperators = this.operatorInitializer.createAdditionalOperators(this.strategyManager, event.getServices().getConfig().controller().getFirstIteration(), (this.pConfig.getNumberOfOperators() - operatorsFromSchedule.size())); this.operators.addAll(initialOperators); // collect the transit schedules from all operators diff --git a/contribs/minibus/src/main/java/org/matsim/contrib/minibus/hook/PControlerListener.java b/contribs/minibus/src/main/java/org/matsim/contrib/minibus/hook/PControlerListener.java index ee1e253771a..efe0a4c45e3 100644 --- a/contribs/minibus/src/main/java/org/matsim/contrib/minibus/hook/PControlerListener.java +++ b/contribs/minibus/src/main/java/org/matsim/contrib/minibus/hook/PControlerListener.java @@ -53,7 +53,7 @@ /** * Hook to register paratransit black box with MATSim - * + * * @author aneumann */ final class PControlerListener implements IterationStartsListener, StartupListener, ScoringListener { @@ -66,7 +66,7 @@ final class PControlerListener implements IterationStartsListener, StartupListen private final POperators operators ; @Inject(optional=true) private PersonReRouteStuckFactory stuckFactory; - + @Inject private TimeInterpretation timeInterpretation; @@ -92,7 +92,7 @@ public void notifyStartup(StartupEvent event) { public void notifyIterationStarts(IterationStartsEvent event) { PBox pBox = (PBox) operators ; final MatsimServices controler = event.getServices(); - if(event.getIteration() == controler.getConfig().controler().getFirstIteration()){ + if(event.getIteration() == controler.getConfig().controller().getFirstIteration()){ log.info("This is the first iteration. All lines were added by notifyStartup event."); } else { pBox.notifyIterationStarts(event); diff --git a/contribs/minibus/src/main/java/org/matsim/contrib/minibus/stats/Line2GexfPStat.java b/contribs/minibus/src/main/java/org/matsim/contrib/minibus/stats/Line2GexfPStat.java index 9da373eb053..f711a97b72b 100644 --- a/contribs/minibus/src/main/java/org/matsim/contrib/minibus/stats/Line2GexfPStat.java +++ b/contribs/minibus/src/main/java/org/matsim/contrib/minibus/stats/Line2GexfPStat.java @@ -120,7 +120,7 @@ public void notifyIterationEnds(IterationEndsEvent event) { public void notifyShutdown(ShutdownEvent event) { // call shutdown for all remaining gexf for (SimpleGexfPStat gexf : this.lineId2GexfPStat.values()) { - gexf.notifyShutdown(event.getServices().getConfig().controler().getLastIteration()); + gexf.notifyShutdown(event.getServices().getConfig().controller().getLastIteration()); } log.info("terminated the last " + this.lineId2GexfPStat.values().size() + " gexf handlers..."); } diff --git a/contribs/minibus/src/main/java/org/matsim/contrib/minibus/stats/PStatsOverview.java b/contribs/minibus/src/main/java/org/matsim/contrib/minibus/stats/PStatsOverview.java index 97fb6ea8fe5..29bbb3292c2 100644 --- a/contribs/minibus/src/main/java/org/matsim/contrib/minibus/stats/PStatsOverview.java +++ b/contribs/minibus/src/main/java/org/matsim/contrib/minibus/stats/PStatsOverview.java @@ -155,8 +155,8 @@ public void notifyStartup(final StartupEvent event) { this.pStatsWriter = null; } - this.minIteration = controler.getConfig().controler().getFirstIteration(); - int maxIter = controler.getConfig().controler().getLastIteration(); + this.minIteration = controler.getConfig().controller().getFirstIteration(); + int maxIter = controler.getConfig().controller().getLastIteration(); int iterations = maxIter - this.minIteration; if (iterations > 10000) iterations = 10000; // limit the history size this.history = new double[29][iterations+1]; diff --git a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/integration/PControlerTestIT.java b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/integration/PControlerTestIT.java index e61556b89b6..57506248366 100644 --- a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/integration/PControlerTestIT.java +++ b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/integration/PControlerTestIT.java @@ -21,7 +21,6 @@ import java.io.File; import java.util.ArrayList; -import java.util.Arrays; import java.util.LinkedList; import java.util.List; @@ -43,7 +42,7 @@ /** * Integration test of the minibus package - * + * * @author aneumann */ public class PControlerTestIT implements TabularFileHandler{ @@ -63,23 +62,23 @@ public final void testPControler() { final String outputPath = utils.getOutputDirectory() + scenarioName + "/"; final String configFile = inputPath + "config_" + scenarioName + ".xml"; - + // --- Config config = ConfigUtils.loadConfig(configFile, new PConfigGroup()); - config.controler().setLastIteration(numberOfIterations); - config.controler().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); - config.controler().setCreateGraphs(false); - config.controler().setOutputDirectory(outputPath); - + config.controller().setLastIteration(numberOfIterations); + config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); + config.controller().setCreateGraphs(false); + config.controller().setOutputDirectory(outputPath); + // --- Scenario scenario = ScenarioUtils.createScenario(config); ScenarioUtils.loadScenario(scenario); - + // --- - + Controler controler = new Controler(scenario); // manipulate config @@ -90,7 +89,7 @@ public final void testPControler() { controler.run(); - // Check standard output files + // Check standard output files List filesToCheckFor = new LinkedList<>(); filesToCheckFor.add(outputPath + scenarioName + ".0.actsFromParatransitUsers.txt"); filesToCheckFor.add(outputPath + scenarioName + ".pOperatorLogger.txt"); @@ -145,6 +144,6 @@ public final void testPControler() { @Override public void startRow(String[] row) { - this.pStatsResults.add(row); - } + this.pStatsResults.add(row); + } } diff --git a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/integration/SubsidyContextTestIT.java b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/integration/SubsidyContextTestIT.java index c23722e3123..1f4676a8458 100644 --- a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/integration/SubsidyContextTestIT.java +++ b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/integration/SubsidyContextTestIT.java @@ -42,43 +42,43 @@ import org.matsim.testcases.MatsimTestUtils; /** - * + * * Tests the functionality of adding subsidies to the operator's score. - * + * * @author ikaddoura */ public class SubsidyContextTestIT implements TabularFileHandler { - + @Rule public MatsimTestUtils utils = new MatsimTestUtils(); private final ArrayList pStatsResults = new ArrayList<>(); private String gridScenarioDirectory ="../../example-scenario/input/"; - + @Ignore @Test public final void testDefaultPControler() { - + Config config1 = ConfigUtils.loadConfig( utils.getClassInputDirectory() + "config.xml", new PConfigGroup() ) ; - + config1.network().setInputFile(gridScenarioDirectory + "network.xml"); config1.transit().setVehiclesFile(gridScenarioDirectory + "transitVehicles.xml"); config1.transit().setTransitScheduleFile(gridScenarioDirectory + "transitSchedule_10min.xml"); config1.plans().setInputFile(gridScenarioDirectory + "population_1000_per_hour_each_from_6_to_10.xml.gz"); - config1.controler().setOutputDirectory(utils.getOutputDirectory()); - - Scenario scenario1 = ScenarioUtils.loadScenario(config1); + config1.controller().setOutputDirectory(utils.getOutputDirectory()); + + Scenario scenario1 = ScenarioUtils.loadScenario(config1); Controler controler1 = new Controler(scenario1); - - controler1.getConfig().controler().setCreateGraphs(true); - controler1.getConfig().controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists ); - + + controler1.getConfig().controller().setCreateGraphs(true); + controler1.getConfig().controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists ); + controler1.addOverridingModule(new PModule()) ; controler1.run(); - - // Check standard output files - + + // Check standard output files + List filesToCheckFor = new LinkedList<>(); filesToCheckFor.add(utils.getOutputDirectory() + "0.actsFromParatransitUsers.txt"); filesToCheckFor.add(utils.getOutputDirectory() + "pOperatorLogger.txt"); @@ -112,35 +112,35 @@ public final void testDefaultPControler() { Assert.assertEquals("Number of +coops (final iteration)", "4", this.pStatsResults.get(31)[2]); Assert.assertEquals("Number of +routes (final iteration)", "6", this.pStatsResults.get(31)[4]); Assert.assertEquals("Number of +pax (final iteration)", "3610", this.pStatsResults.get(31)[6]); - Assert.assertEquals("Number of +veh (final iteration)", "16", this.pStatsResults.get(31)[8]); + Assert.assertEquals("Number of +veh (final iteration)", "16", this.pStatsResults.get(31)[8]); } - + @Ignore @Test public final void testSubsidyPControler() { - + Config config2 = ConfigUtils.loadConfig( utils.getClassInputDirectory() + "config.xml", new PConfigGroup() ) ; - + PConfigGroup pConfig2 = (PConfigGroup) config2.getModules().get(PConfigGroup.GROUP_NAME); pConfig2.setSubsidyApproach("perPassenger"); - + config2.network().setInputFile(gridScenarioDirectory + "network.xml"); config2.transit().setVehiclesFile(gridScenarioDirectory + "transitVehicles.xml"); config2.transit().setTransitScheduleFile(gridScenarioDirectory + "transitSchedule_10min.xml"); config2.plans().setInputFile(gridScenarioDirectory + "population_1000_per_hour_each_from_6_to_10.xml.gz"); - config2.controler().setOutputDirectory(utils.getOutputDirectory()); - - Scenario scenario2 = ScenarioUtils.loadScenario(config2); + config2.controller().setOutputDirectory(utils.getOutputDirectory()); + + Scenario scenario2 = ScenarioUtils.loadScenario(config2); Controler controler2 = new Controler(scenario2); - - controler2.getConfig().controler().setCreateGraphs(true); - controler2.getConfig().controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists ); - + + controler2.getConfig().controller().setCreateGraphs(true); + controler2.getConfig().controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists ); + controler2.addOverridingModule(new PModule()) ; controler2.run(); - - // Check standard output files - + + // Check standard output files + List filesToCheckFor = new LinkedList<>(); filesToCheckFor.add(utils.getOutputDirectory() + "0.actsFromParatransitUsers.txt"); filesToCheckFor.add(utils.getOutputDirectory() + "pOperatorLogger.txt"); @@ -175,13 +175,13 @@ public final void testSubsidyPControler() { Assert.assertEquals("Number of +coops (final iteration)", "4", this.pStatsResults.get(31)[2]); Assert.assertEquals("Number of +routes (final iteration)", "51", this.pStatsResults.get(31)[4]); Assert.assertEquals("Number of +pax (final iteration)", "9951", this.pStatsResults.get(31)[6]); - Assert.assertEquals("Number of +veh (final iteration)", "260", this.pStatsResults.get(31)[8]); + Assert.assertEquals("Number of +veh (final iteration)", "260", this.pStatsResults.get(31)[8]); } - + @Override public void startRow(String[] row) { - this.pStatsResults.add(row); + this.pStatsResults.add(row); } - + } diff --git a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/integration/SubsidyTestIT.java b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/integration/SubsidyTestIT.java index 10116f29b0c..c188c22fae6 100644 --- a/contribs/minibus/src/test/java/org/matsim/contrib/minibus/integration/SubsidyTestIT.java +++ b/contribs/minibus/src/test/java/org/matsim/contrib/minibus/integration/SubsidyTestIT.java @@ -42,21 +42,21 @@ import org.matsim.testcases.MatsimTestUtils; /** - * + * * Tests the functionality of adding subsidies to the operator's score. - * + * * @author ikaddoura */ public class SubsidyTestIT implements TabularFileHandler { - + @Rule public MatsimTestUtils utils = new MatsimTestUtils(); private final ArrayList pStatsResults = new ArrayList<>(); @Test public final void testSubsidyPControler() { - + Config config = ConfigUtils.loadConfig( utils.getClassInputDirectory() + "config.xml", new PConfigGroup() ) ; config.transit().setRoutingAlgorithmType(TransitRoutingAlgorithmType.DijkstraBased); @@ -67,20 +67,20 @@ public final void testSubsidyPControler() { config.transit().setVehiclesFile(gridScenarioDirectory + "transitVehicles.xml"); config.transit().setTransitScheduleFile(gridScenarioDirectory + "transitSchedule_10min.xml"); config.plans().setInputFile(gridScenarioDirectory + "population_1000_per_hour_each_from_6_to_10.xml.gz"); - config.controler().setOutputDirectory(utils.getOutputDirectory()); - config.controler().setWriteEventsInterval(0); - Scenario scenario = ScenarioUtils.loadScenario(config); + config.controller().setOutputDirectory(utils.getOutputDirectory()); + config.controller().setWriteEventsInterval(0); + Scenario scenario = ScenarioUtils.loadScenario(config); Controler controler = new Controler(scenario); - - controler.getConfig().controler().setCreateGraphs(true); - - controler.getConfig().controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists ); - + + controler.getConfig().controller().setCreateGraphs(true); + + controler.getConfig().controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists ); + controler.addOverridingModule(new PModule()) ; controler.run(); - - // Check standard output files - + + // Check standard output files + List filesToCheckFor = new LinkedList<>(); filesToCheckFor.add(utils.getOutputDirectory() + "0.actsFromParatransitUsers.txt"); filesToCheckFor.add(utils.getOutputDirectory() + "pOperatorLogger.txt"); @@ -107,11 +107,11 @@ public final void testSubsidyPControler() { // Check final iteration Assert.assertEquals("Number of budget (final iteration)", "202319997.4909444700", this.pStatsResults.get(2)[9]); } - + @Override public void startRow(String[] row) { - this.pStatsResults.add(row); + this.pStatsResults.add(row); } - + } diff --git a/contribs/multimodal/src/main/java/org/matsim/contrib/multimodal/MultiModalModule.java b/contribs/multimodal/src/main/java/org/matsim/contrib/multimodal/MultiModalModule.java index 9a89542b2af..2b6d39a2ec0 100644 --- a/contribs/multimodal/src/main/java/org/matsim/contrib/multimodal/MultiModalModule.java +++ b/contribs/multimodal/src/main/java/org/matsim/contrib/multimodal/MultiModalModule.java @@ -63,8 +63,8 @@ public void install() { // would just operate on that sub-network. // kai, dec'19 - RoutingConfigGroup routingConfigGroup = getConfig().plansCalcRoute(); - ScoringConfigGroup cnScoringGroup = getConfig().planCalcScore(); + RoutingConfigGroup routingConfigGroup = getConfig().routing(); + ScoringConfigGroup cnScoringGroup = getConfig().scoring(); MultiModalConfigGroup multiModalConfigGroup = (MultiModalConfigGroup) getConfig().getModule(MultiModalConfigGroup.GROUP_NAME); Set simulatedModes = CollectionUtils.stringToSet(multiModalConfigGroup.getSimulatedModes()); for (String mode : simulatedModes) { diff --git a/contribs/multimodal/src/main/java/org/matsim/contrib/multimodal/router/util/MultiModalTravelTimeFactory.java b/contribs/multimodal/src/main/java/org/matsim/contrib/multimodal/router/util/MultiModalTravelTimeFactory.java index a896cc33271..008b9d58406 100644 --- a/contribs/multimodal/src/main/java/org/matsim/contrib/multimodal/router/util/MultiModalTravelTimeFactory.java +++ b/contribs/multimodal/src/main/java/org/matsim/contrib/multimodal/router/util/MultiModalTravelTimeFactory.java @@ -79,7 +79,7 @@ public Map createTravelTimes() { private void initMultiModalTravelTimeFactories(Config config) { - RoutingConfigGroup routingConfigGroup = config.plansCalcRoute(); + RoutingConfigGroup routingConfigGroup = config.routing(); MultiModalConfigGroup multiModalConfigGroup = (MultiModalConfigGroup) config.getModule(MultiModalConfigGroup.GROUP_NAME); Set simulatedModes = CollectionUtils.stringToSet(multiModalConfigGroup.getSimulatedModes()); diff --git a/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/MultiModalControlerListenerTest.java b/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/MultiModalControlerListenerTest.java index 5d2a16b4c06..28c96b9e39d 100644 --- a/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/MultiModalControlerListenerTest.java +++ b/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/MultiModalControlerListenerTest.java @@ -89,10 +89,10 @@ static void runSimpleScenario(int numberOfThreads) { config.qsim().setEndTime(24 * 3600); - config.controler().setLastIteration(0); + config.controller().setLastIteration(0); // doesn't matter - MultiModalModule sets the mobsim unconditionally. it just can't be something // which the ControlerDefaultsModule knows about. Try it, you will get an error. Quite safe. - config.controler().setMobsim("myMobsim"); + config.controller().setMobsim("myMobsim"); MultiModalConfigGroup multiModalConfigGroup = new MultiModalConfigGroup(); multiModalConfigGroup.setMultiModalSimulationEnabled(true); @@ -102,19 +102,19 @@ static void runSimpleScenario(int numberOfThreads) { ActivityParams homeParams = new ActivityParams("home"); homeParams.setTypicalDuration(16*3600); - config.planCalcScore().addActivityParams(homeParams); + config.scoring().addActivityParams(homeParams); // set default walk speed; according to Weidmann 1.34 [m/s] double defaultWalkSpeed = 1.34; - config.plansCalcRoute().setTeleportedModeSpeed(TransportMode.walk, defaultWalkSpeed); + config.routing().setTeleportedModeSpeed(TransportMode.walk, defaultWalkSpeed); // set default bike speed; Parkin and Rotheram according to 6.01 [m/s] double defaultBikeSpeed = 6.01; - config.plansCalcRoute().setTeleportedModeSpeed(TransportMode.bike, defaultBikeSpeed); + config.routing().setTeleportedModeSpeed(TransportMode.bike, defaultBikeSpeed); // set unkown mode speed double unknownModeSpeed = 2.0; - config.plansCalcRoute().setTeleportedModeSpeed("other", unknownModeSpeed); + config.routing().setTeleportedModeSpeed("other", unknownModeSpeed); config.travelTimeCalculator().setFilterModes(true); @@ -164,10 +164,10 @@ static void runSimpleScenario(int numberOfThreads) { scenario.getPopulation().addPerson(createPerson(scenario, "p3", "other")); Controler controler = new Controler(scenario); - controler.getConfig().controler().setCreateGraphs(false); - controler.getConfig().controler().setDumpDataAtEnd(false); - controler.getConfig().controler().setWriteEventsInterval(0); - controler.getConfig().controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles); + controler.getConfig().controller().setCreateGraphs(false); + controler.getConfig().controller().setDumpDataAtEnd(false); + controler.getConfig().controller().setWriteEventsInterval(0); + controler.getConfig().controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles); // controler listener that initializes the multi-modal simulation controler.addOverridingModule(new MultiModalModule()); @@ -211,11 +211,11 @@ void runBerlinScenario(int numberOfThreads) { Config config = ConfigUtils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("berlin"), "config.xml")); ConfigUtils.loadConfig(config, inputDir + "config_berlin_multimodal.xml"); config.addModule(new MultiModalConfigGroup()); - config.controler().setOutputDirectory(this.utils.getOutputDirectory()); + config.controller().setOutputDirectory(this.utils.getOutputDirectory()); // doesn't matter - MultiModalModule sets the mobsim unconditionally. it just can't be something // which the ControlerDefaultsModule knows about. Try it, you will get an error. Quite safe. - config.controler().setMobsim("myMobsim"); + config.controller().setMobsim("myMobsim"); // config.qsim().setRemoveStuckVehicles(true); // but why? kai, feb'16 config.qsim().setRemoveStuckVehicles(false); @@ -251,10 +251,10 @@ void runBerlinScenario(int numberOfThreads) { PrepareMultiModalScenario.run(scenario); Controler controler = new Controler(scenario); - controler.getConfig().controler().setCreateGraphs(false); - controler.getConfig().controler().setDumpDataAtEnd(false); - controler.getConfig().controler().setWriteEventsInterval(0); - controler.getConfig().controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles); + controler.getConfig().controller().setCreateGraphs(false); + controler.getConfig().controller().setDumpDataAtEnd(false); + controler.getConfig().controller().setWriteEventsInterval(0); + controler.getConfig().controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles); // controler listener that initializes the multi-modal simulation controler.addOverridingModule(new MultiModalModule()); @@ -310,7 +310,7 @@ public void install() { LogManager.getLogger( this.getClass() ).warn( "carTravelTime: " + carTravelTime ) ; LogManager.getLogger( this.getClass() ).warn( "bikeTravelTime: " + bikeTravelTime ) ; LogManager.getLogger( this.getClass() ).warn( "walkTravelTime: " + walkTravelTime ) ; - if ( !config.plansCalcRoute().getAccessEgressType().equals(RoutingConfigGroup.AccessEgressType.none) ) { + if ( !config.routing().getAccessEgressType().equals(RoutingConfigGroup.AccessEgressType.none) ) { Assert.assertEquals( "unexpected total travel time for car mode with number of threads "+numberOfThreads, 1.1186864E8, carTravelTime, MatsimTestUtils.EPSILON); diff --git a/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/MultiModalTripRouterTest.java b/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/MultiModalTripRouterTest.java index 3158238cf68..45c6e6ece37 100644 --- a/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/MultiModalTripRouterTest.java +++ b/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/MultiModalTripRouterTest.java @@ -68,13 +68,13 @@ public class MultiModalTripRouterTest { public void testRouteLeg() { final Config config = ConfigUtils.createConfig(); - config.plansCalcRoute().addParam("teleportedModeSpeed_bike", "6.01"); - config.plansCalcRoute().addParam("teleportedModeFreespeedFactor_pt", "2.0"); - config.plansCalcRoute().addParam("teleportedModeSpeed_ride", "15.0"); - config.plansCalcRoute().addParam("teleportedModeSpeed_undefined", "13.88888888888889"); - config.plansCalcRoute().addParam("teleportedModeSpeed_walk", "1.34"); + config.routing().addParam("teleportedModeSpeed_bike", "6.01"); + config.routing().addParam("teleportedModeFreespeedFactor_pt", "2.0"); + config.routing().addParam("teleportedModeSpeed_ride", "15.0"); + config.routing().addParam("teleportedModeSpeed_undefined", "13.88888888888889"); + config.routing().addParam("teleportedModeSpeed_walk", "1.34"); - config.planCalcScore().addModeParams( new ScoringConfigGroup.ModeParams( TransportMode.ride ) ); + config.scoring().addModeParams( new ScoringConfigGroup.ModeParams( TransportMode.ride ) ); final Scenario scenario = ScenarioUtils.createScenario(config); createNetwork(scenario); diff --git a/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/pt/MultiModalPTCombinationTest.java b/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/pt/MultiModalPTCombinationTest.java index ebbb7f03389..c4bb7388e2c 100644 --- a/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/pt/MultiModalPTCombinationTest.java +++ b/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/pt/MultiModalPTCombinationTest.java @@ -84,7 +84,7 @@ public void testMultiModalPtCombination() { Scenario scenario = f.scenario; Config config = scenario.getConfig(); - config.controler().setOutputDirectory(utils.getOutputDirectory()); + config.controller().setOutputDirectory(utils.getOutputDirectory()); MultiModalConfigGroup mmcg = new MultiModalConfigGroup(); mmcg.setMultiModalSimulationEnabled(true); @@ -93,29 +93,29 @@ public void testMultiModalPtCombination() { config.qsim().setEndTime(24*3600); - config.controler().setLastIteration(0); + config.controller().setLastIteration(0); // doesn't matter - MultiModalModule sets the mobsim unconditionally. it just can't be something // which the ControlerDefaultsModule knows about. Try it, you will get an error. Quite safe. - config.controler().setMobsim("myMobsim"); + config.controller().setMobsim("myMobsim"); ActivityParams homeParams = new ActivityParams("home"); homeParams.setTypicalDuration(16*3600); - config.planCalcScore().addActivityParams(homeParams); + config.scoring().addActivityParams(homeParams); // set default walk speed; according to Weidmann 1.34 [m/s] double defaultWalkSpeed = 1.34; - config.plansCalcRoute().setTeleportedModeSpeed(TransportMode.walk, defaultWalkSpeed); + config.routing().setTeleportedModeSpeed(TransportMode.walk, defaultWalkSpeed); final RoutingConfigGroup.TeleportedModeParams pt = new RoutingConfigGroup.TeleportedModeParams( TransportMode.pt ); pt.setTeleportedModeFreespeedFactor( 2.0 ); - config.plansCalcRoute().addParameterSet( pt ); + config.routing().addParameterSet( pt ); config.travelTimeCalculator().setFilterModes(true); Controler controler = new Controler(scenario); - controler.getConfig().controler().setCreateGraphs(false); - controler.getConfig().controler().setDumpDataAtEnd(false); - controler.getConfig().controler().setWriteEventsInterval(0); + controler.getConfig().controller().setCreateGraphs(false); + controler.getConfig().controller().setDumpDataAtEnd(false); + controler.getConfig().controller().setWriteEventsInterval(0); // controler.setOverwriteFiles(true); controler.addOverridingModule(new MultiModalModule()); @@ -133,7 +133,7 @@ public void testMultiModalPtCombination() { Assert.assertEquals(ptPlan.getPlanElements().toString(), 7, ptPlan.getPlanElements().size()); Plan walkPlan = walkPerson.getSelectedPlan(); - if ( !config.plansCalcRoute().getAccessEgressType().equals(RoutingConfigGroup.AccessEgressType.none) ) { + if ( !config.routing().getAccessEgressType().equals(RoutingConfigGroup.AccessEgressType.none) ) { Assert.assertEquals(walkPlan.getPlanElements().toString(), 7, walkPlan.getPlanElements().size()); } else { Assert.assertEquals(walkPlan.getPlanElements().toString(), 3, walkPlan.getPlanElements().size()); diff --git a/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/router/util/BikeTravelTimeTest.java b/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/router/util/BikeTravelTimeTest.java index 412825f7af3..7f95d342870 100644 --- a/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/router/util/BikeTravelTimeTest.java +++ b/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/router/util/BikeTravelTimeTest.java @@ -75,11 +75,11 @@ public class BikeTravelTimeTest { // set default walk speed; according to Weidmann 1.34 [m/s] double defaultWalkSpeed = 1.34; - scenario.getConfig().plansCalcRoute().setTeleportedModeSpeed(TransportMode.walk, defaultWalkSpeed); + scenario.getConfig().routing().setTeleportedModeSpeed(TransportMode.walk, defaultWalkSpeed); // set default bike speed; Prakin and Rotheram according to 6.01 [m/s] double defaultBikeSpeed = 6.01; - scenario.getConfig().plansCalcRoute().setTeleportedModeSpeed(TransportMode.bike, defaultBikeSpeed); + scenario.getConfig().routing().setTeleportedModeSpeed(TransportMode.bike, defaultBikeSpeed); BikeTravelTime bikeTravelTime; @@ -88,7 +88,7 @@ public class BikeTravelTimeTest { double calculatedTravelTime; // reference speed * person factor * slope factor - bikeTravelTime = new BikeTravelTime(scenario.getConfig().plansCalcRoute(), linkSlopes); + bikeTravelTime = new BikeTravelTime(scenario.getConfig().routing(), linkSlopes); calculatedTravelTime = bikeTravelTime.getLinkTravelTime(link, 0.0, person, null); speed = defaultBikeSpeed * bikeTravelTime.personFactorCache.get() * 1.0; expectedTravelTime = link.getLength() / speed; @@ -98,7 +98,7 @@ public class BikeTravelTimeTest { // increase age PersonUtils.setAge(person, 80); - bikeTravelTime = new BikeTravelTime(scenario.getConfig().plansCalcRoute(), linkSlopes); + bikeTravelTime = new BikeTravelTime(scenario.getConfig().routing(), linkSlopes); calculatedTravelTime = bikeTravelTime.getLinkTravelTime(link, 0.0, person, null); speed = defaultBikeSpeed * bikeTravelTime.personFactorCache.get() * 1.0; expectedTravelTime = link.getLength() / speed; @@ -108,7 +108,7 @@ public class BikeTravelTimeTest { // change gender PersonUtils.setSex(person, "f"); - bikeTravelTime = new BikeTravelTime(scenario.getConfig().plansCalcRoute(), linkSlopes); + bikeTravelTime = new BikeTravelTime(scenario.getConfig().routing(), linkSlopes); calculatedTravelTime = bikeTravelTime.getLinkTravelTime(link, 0.0, person, null); speed = defaultBikeSpeed * bikeTravelTime.personFactorCache.get() * 1.0; expectedTravelTime = link.getLength() / speed; @@ -120,7 +120,7 @@ public class BikeTravelTimeTest { h2 = 0.1; slope = 100 * (h2 - h1) / link.getLength(); linkSlopes.put(link.getId(), slope); - bikeTravelTime = new BikeTravelTime(scenario.getConfig().plansCalcRoute(), linkSlopes); + bikeTravelTime = new BikeTravelTime(scenario.getConfig().routing(), linkSlopes); calculatedTravelTime = bikeTravelTime.getLinkTravelTime(link, 0.0, person, null); double slope2 = bikeTravelTime.getSlope(link); @@ -135,7 +135,7 @@ public class BikeTravelTimeTest { h2 = -0.1; slope = 100 * (h2 - h1) / link.getLength(); linkSlopes.put(link.getId(), slope); - bikeTravelTime = new BikeTravelTime(scenario.getConfig().plansCalcRoute(), linkSlopes); + bikeTravelTime = new BikeTravelTime(scenario.getConfig().routing(), linkSlopes); calculatedTravelTime = bikeTravelTime.getLinkTravelTime(link, 0.0, person, null); slope2 = bikeTravelTime.getSlope(link); @@ -150,9 +150,9 @@ public class BikeTravelTimeTest { h2 = 0.25; slope = 100 * (h2 - h1) / link.getLength(); linkSlopes.put(link.getId(), slope); - bikeTravelTime = new BikeTravelTime(scenario.getConfig().plansCalcRoute(), linkSlopes); + bikeTravelTime = new BikeTravelTime(scenario.getConfig().routing(), linkSlopes); - WalkTravelTime walkTravelTime = new WalkTravelTime(scenario.getConfig().plansCalcRoute(), linkSlopes); + WalkTravelTime walkTravelTime = new WalkTravelTime(scenario.getConfig().routing(), linkSlopes); calculatedTravelTime = bikeTravelTime.getLinkTravelTime(link, 0.0, person, null); expectedTravelTime = walkTravelTime.getLinkTravelTime(link, 0.0, person, null); printInfo(person, expectedTravelTime, calculatedTravelTime, slope); @@ -211,7 +211,7 @@ private void printInfo(Person p, double expected, double calculated, double slop double slope = 100 * (h2 - h1) / link.getLength(); linkSlopes.put(link.getId(), slope); - BikeTravelTime bikeTravelTime = new BikeTravelTime(config.plansCalcRoute(), linkSlopes); + BikeTravelTime bikeTravelTime = new BikeTravelTime(config.routing(), linkSlopes); double tt1 = bikeTravelTime.getLinkTravelTime(link, 0.0, p1, null); double tt2 = bikeTravelTime.getLinkTravelTime(link, 0.0, p2, null); diff --git a/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/router/util/WalkTravelTimeTest.java b/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/router/util/WalkTravelTimeTest.java index 5c79bf513e1..ca66b5a25d5 100644 --- a/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/router/util/WalkTravelTimeTest.java +++ b/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/router/util/WalkTravelTimeTest.java @@ -75,10 +75,10 @@ public class WalkTravelTimeTest { // set default walk speed; according to Weidmann 1.34 [m/s] double defaultWalkSpeed = 1.34; - scenario.getConfig().plansCalcRoute().setTeleportedModeSpeed(TransportMode.walk, defaultWalkSpeed); + scenario.getConfig().routing().setTeleportedModeSpeed(TransportMode.walk, defaultWalkSpeed); WalkTravelTime walkTravelTime; - walkTravelTime = new WalkTravelTime(scenario.getConfig().plansCalcRoute(), linkSlopes); + walkTravelTime = new WalkTravelTime(scenario.getConfig().routing(), linkSlopes); double speed; double expectedTravelTime; @@ -95,7 +95,7 @@ public class WalkTravelTimeTest { // increase age PersonUtils.setAge(person, 80); - walkTravelTime = new WalkTravelTime(scenario.getConfig().plansCalcRoute(), linkSlopes); + walkTravelTime = new WalkTravelTime(scenario.getConfig().routing(), linkSlopes); calculatedTravelTime = walkTravelTime.getLinkTravelTime(link, 0.0, person, null); speed = defaultWalkSpeed * walkTravelTime.personFactors.get(person.getId()) * 1.0; expectedTravelTime = link.getLength() / speed; @@ -105,7 +105,7 @@ public class WalkTravelTimeTest { // change gender PersonUtils.setSex(person, "f"); - walkTravelTime = new WalkTravelTime(scenario.getConfig().plansCalcRoute(), linkSlopes); + walkTravelTime = new WalkTravelTime(scenario.getConfig().routing(), linkSlopes); calculatedTravelTime = walkTravelTime.getLinkTravelTime(link, 0.0, person, null); speed = defaultWalkSpeed * walkTravelTime.personFactors.get(person.getId()) * 1.0; expectedTravelTime = link.getLength() / speed; @@ -117,7 +117,7 @@ public class WalkTravelTimeTest { h2 = -0.1; slope = 100 * (h2 - h1) / link.getLength(); linkSlopes.put(link.getId(), slope); - walkTravelTime = new WalkTravelTime(scenario.getConfig().plansCalcRoute(), linkSlopes); + walkTravelTime = new WalkTravelTime(scenario.getConfig().routing(), linkSlopes); double slope2 = walkTravelTime.getSlope(link); double slopeFactor = walkTravelTime.getSlopeFactor(slope2); calculatedTravelTime = walkTravelTime.getLinkTravelTime(link, 0.0, person, null); @@ -131,7 +131,7 @@ public class WalkTravelTimeTest { h2 = 0.1; slope = 100 * (h2 - h1) / link.getLength(); linkSlopes.put(link.getId(), slope); - walkTravelTime = new WalkTravelTime(scenario.getConfig().plansCalcRoute(), linkSlopes); + walkTravelTime = new WalkTravelTime(scenario.getConfig().routing(), linkSlopes); slopeFactor = walkTravelTime.getSlopeFactor(slope); calculatedTravelTime = walkTravelTime.getLinkTravelTime(link, 0.0, person, null); speed = defaultWalkSpeed * walkTravelTime.personFactors.get(person.getId()) * slopeFactor; @@ -192,7 +192,7 @@ private void printInfo(Person p, double expected, double calculated, double slop double slope = 100 * (h2 - h1) / link.getLength(); linkSlopes.put(link.getId(), slope); - WalkTravelTime walkTravelTime = new WalkTravelTime(config.plansCalcRoute(), linkSlopes); + WalkTravelTime walkTravelTime = new WalkTravelTime(config.routing(), linkSlopes); double tt1 = walkTravelTime.getLinkTravelTime(link, 0.0, p1, null); double tt2 = walkTravelTime.getLinkTravelTime(link, 0.0, p2, null); diff --git a/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/simengine/StuckAgentTest.java b/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/simengine/StuckAgentTest.java index 921f5fba36d..ffb8924a15c 100644 --- a/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/simengine/StuckAgentTest.java +++ b/contribs/multimodal/src/test/java/org/matsim/contrib/multimodal/simengine/StuckAgentTest.java @@ -68,14 +68,14 @@ public class StuckAgentTest { @Test public void testStuckEvents() { Config config = ConfigUtils.createConfig(); - config.controler().setOutputDirectory(utils.getOutputDirectory()); + config.controller().setOutputDirectory(utils.getOutputDirectory()); config.qsim().setEndTime(24*3600); - config.controler().setLastIteration(0); + config.controller().setLastIteration(0); // doesn't matter - MultiModalModule sets the mobsim unconditionally. it just can't be something // which the ControlerDefaultsModule knows about. Try it, you will get an error. Quite safe. - config.controler().setMobsim("myMobsim"); + config.controller().setMobsim("myMobsim"); MultiModalConfigGroup multiModalConfigGroup = new MultiModalConfigGroup(); @@ -85,19 +85,19 @@ public void testStuckEvents() { ActivityParams homeParams = new ActivityParams("home"); homeParams.setTypicalDuration(16*3600); - config.planCalcScore().addActivityParams(homeParams); + config.scoring().addActivityParams(homeParams); // set default walk speed; according to Weidmann 1.34 [m/s] double defaultWalkSpeed = 1.34; - config.plansCalcRoute().setTeleportedModeSpeed(TransportMode.walk, defaultWalkSpeed); + config.routing().setTeleportedModeSpeed(TransportMode.walk, defaultWalkSpeed); // set default bike speed; Parkin and Rotheram according to 6.01 [m/s] double defaultBikeSpeed = 6.01; - config.plansCalcRoute().setTeleportedModeSpeed(TransportMode.bike, defaultBikeSpeed); + config.routing().setTeleportedModeSpeed(TransportMode.bike, defaultBikeSpeed); // set unkown mode speed double unknownModeSpeed = 2.0; - config.plansCalcRoute().setTeleportedModeSpeed("other", unknownModeSpeed); + config.routing().setTeleportedModeSpeed("other", unknownModeSpeed); config.travelTimeCalculator().setFilterModes(true); @@ -148,9 +148,9 @@ public void testStuckEvents() { scenario.getPopulation().addPerson(createPerson(scenario, "p4", "walk", null, 24.5*3600)); // departs after simulation has ended Controler controler = new Controler(scenario); - controler.getConfig().controler().setCreateGraphs(false); - controler.getConfig().controler().setDumpDataAtEnd(false); - controler.getConfig().controler().setWriteEventsInterval(0); + controler.getConfig().controller().setCreateGraphs(false); + controler.getConfig().controller().setDumpDataAtEnd(false); + controler.getConfig().controller().setWriteEventsInterval(0); controler.addOverridingModule(new MultiModalModule()); diff --git a/contribs/noise/src/main/java/org/matsim/contrib/noise/NoiseCalculationOnline.java b/contribs/noise/src/main/java/org/matsim/contrib/noise/NoiseCalculationOnline.java index 5be0fa5465b..5a9f11d301e 100644 --- a/contribs/noise/src/main/java/org/matsim/contrib/noise/NoiseCalculationOnline.java +++ b/contribs/noise/src/main/java/org/matsim/contrib/noise/NoiseCalculationOnline.java @@ -18,7 +18,7 @@ * *********************************************************************** */ /** - * + * */ package org.matsim.contrib.noise; @@ -35,24 +35,24 @@ /** - * + * * @author ikaddoura * */ final class NoiseCalculationOnline implements BeforeMobsimListener, AfterMobsimListener, StartupListener { private static final Logger log = LogManager.getLogger(NoiseCalculationOnline.class); - + @Inject private NoiseContext noiseContext; - + @Inject private NoiseTimeTracker timeTracker; - + @Override public void notifyStartup(StartupEvent event) { - NoiseWriter.writeReceiverPoints(noiseContext, event.getServices().getConfig().controler().getOutputDirectory() + "/receiverPoints/", false); + NoiseWriter.writeReceiverPoints(noiseContext, event.getServices().getConfig().controller().getOutputDirectory() + "/receiverPoints/", false); } - + @Override public void notifyBeforeMobsim(BeforeMobsimEvent event) { @@ -60,12 +60,12 @@ public void notifyBeforeMobsim(BeforeMobsimEvent event) { this.noiseContext.getNoiseLinks().clear(); this.noiseContext.getTimeInterval2linkId2noiseLinks().clear(); - + for (NoiseReceiverPoint rp : this.noiseContext.getReceiverPoints().values()) { rp.reset(); } } - + @Override public void notifyAfterMobsim(AfterMobsimEvent event) { timeTracker.computeFinalTimeIntervals(); @@ -75,5 +75,5 @@ public void notifyAfterMobsim(AfterMobsimEvent event) { NoiseContext getNoiseContext() { return noiseContext; } - + } diff --git a/contribs/noise/src/main/java/org/matsim/contrib/noise/NoiseOfflineCalculation.java b/contribs/noise/src/main/java/org/matsim/contrib/noise/NoiseOfflineCalculation.java index 62ea785acf9..8f54b37c270 100644 --- a/contribs/noise/src/main/java/org/matsim/contrib/noise/NoiseOfflineCalculation.java +++ b/contribs/noise/src/main/java/org/matsim/contrib/noise/NoiseOfflineCalculation.java @@ -110,10 +110,10 @@ public void run() { EventWriterXML eventWriter = null; if (noiseContext.getNoiseParams().isThrowNoiseEventsAffected() || noiseContext.getNoiseParams().isThrowNoiseEventsCaused()) { String eventsFile; - if (this.scenario.getConfig().controler().getRunId() == null || this.scenario.getConfig().controler().getRunId().equals("")) { + if (this.scenario.getConfig().controller().getRunId() == null || this.scenario.getConfig().controller().getRunId().equals("")) { eventsFile = outputFilePath + "noise.output_events.offline.xml.gz"; } else { - eventsFile = outputFilePath + this.scenario.getConfig().controler().getRunId() + ".noise.output_events.offline.xml.gz"; + eventsFile = outputFilePath + this.scenario.getConfig().controller().getRunId() + ".noise.output_events.offline.xml.gz"; } eventWriter = new EventWriterXML(eventsFile); events.addHandler(eventWriter); @@ -123,10 +123,10 @@ public void run() { log.info("Reading events file..."); MatsimEventsReader reader = new MatsimEventsReader(events); String eventsFile; - if (this.scenario.getConfig().controler().getRunId() == null || this.scenario.getConfig().controler().getRunId().equals("")) { - eventsFile = this.scenario.getConfig().controler().getOutputDirectory() + "output_events.xml.gz"; + if (this.scenario.getConfig().controller().getRunId() == null || this.scenario.getConfig().controller().getRunId().equals("")) { + eventsFile = this.scenario.getConfig().controller().getOutputDirectory() + "output_events.xml.gz"; } else { - eventsFile = this.scenario.getConfig().controler().getOutputDirectory() + this.scenario.getConfig().controler().getRunId() + ".output_events.xml.gz"; + eventsFile = this.scenario.getConfig().controller().getOutputDirectory() + this.scenario.getConfig().controller().getRunId() + ".output_events.xml.gz"; } reader.readFile(eventsFile); log.info("Reading events file... Done."); diff --git a/contribs/noise/src/main/java/org/matsim/contrib/noise/NoiseTimeTracker.java b/contribs/noise/src/main/java/org/matsim/contrib/noise/NoiseTimeTracker.java index ff31f713b26..de6589fa205 100644 --- a/contribs/noise/src/main/java/org/matsim/contrib/noise/NoiseTimeTracker.java +++ b/contribs/noise/src/main/java/org/matsim/contrib/noise/NoiseTimeTracker.java @@ -18,7 +18,7 @@ * *********************************************************************** */ /** - * + * */ package org.matsim.contrib.noise; @@ -50,7 +50,7 @@ /** * A handler which computes noise emissions, immisions, affected agent units and damages for each receiver point and time interval. * Throws noise damage events for each affected and causing agent. - * + * * @author ikaddoura * */ @@ -58,12 +58,12 @@ class NoiseTimeTracker implements VehicleEntersTrafficEventHandler, PersonEnters private static final Logger log = LogManager.getLogger(NoiseTimeTracker.class); private static final boolean printLog = true; - + private NoiseContext noiseContext; private String outputDirectory; private int iteration; - + private boolean useCompression = false ; private int cWarn1 = 0; @@ -127,15 +127,15 @@ private void setRelevantLinkInfo() { @Override public void reset(int iteration) { - - String outputDir = noiseContext.getScenario().getConfig().controler().getOutputDirectory(); + + String outputDir = noiseContext.getScenario().getConfig().controller().getOutputDirectory(); if (!outputDir.endsWith("/")) { outputDir = outputDir + "/"; } - + this.outputDirectory = outputDir + "ITERS/" + "it." + iteration + "/"; log.info("Setting the output directory to " + outputDirectory); - + this.iteration = iteration; this.damageCalculation.reset(iteration); this.noiseContext.reset(); @@ -144,16 +144,16 @@ public void reset(int iteration) { rp.reset(); } } - + private void resetCurrentTimeIntervalInfo() { this.noiseContext.getNoiseLinks().clear(); for (NoiseReceiverPoint rp : this.noiseContext.getReceiverPoints().values()) { rp.resetTimeInterval(); } } - + private void processTimeBin() { - + if (printLog) { log.info("##############################################"); } @@ -184,12 +184,12 @@ private void updateActivityInformation() { for (NoiseReceiverPoint rp : this.noiseContext.getReceiverPoints().values()) { for (Id personId : rp.getPersonId2actInfos().keySet()) { rp.getPersonId2actInfos().get(personId).removeIf(personActivityInfo -> personActivityInfo.getEndTime() < (timeBinEnd)); - } + } } } private void computeNoiseForCurrentTimeInterval() { - + if (printLog) { log.info("Calculating noise emissions..."); } @@ -214,7 +214,7 @@ private void computeNoiseForCurrentTimeInterval() { } } } - + private boolean writeOutput() { if (this.noiseContext.getNoiseParams().getWriteOutputIteration() == 0) { return false; @@ -230,7 +230,7 @@ private void updateCurrentTimeInterval() { + this.noiseContext.getNoiseParams().getTimeBinSizeNoiseComputation(); this.noiseContext.setCurrentTimeBinEndTime(newTimeInterval); } - + /* * Emission */ @@ -269,7 +269,7 @@ private void calculateNoiseImmissionsAndDamages() { void computeFinalTimeIntervals() { while (this.noiseContext.getCurrentTimeBinEndTime() <= Math.max(24. * 3600., this.noiseContext.getScenario().getConfig().qsim().getEndTime().orElse(0))) { - processTimeBin(); + processTimeBin(); } } diff --git a/contribs/noise/src/main/java/org/matsim/contrib/noise/NoiseTollTimeDistanceTravelDisutilityFactory.java b/contribs/noise/src/main/java/org/matsim/contrib/noise/NoiseTollTimeDistanceTravelDisutilityFactory.java index 926ed2b0441..ae2773363d9 100644 --- a/contribs/noise/src/main/java/org/matsim/contrib/noise/NoiseTollTimeDistanceTravelDisutilityFactory.java +++ b/contribs/noise/src/main/java/org/matsim/contrib/noise/NoiseTollTimeDistanceTravelDisutilityFactory.java @@ -51,7 +51,7 @@ public final TravelDisutility createTravelDisutility(TravelTime timeCalculator) return new NoiseTollTimeDistanceTravelDisutility( travelDisutilityFactoryDelegate.createTravelDisutility(timeCalculator ), - new NoiseTollCalculator(noiseContext), this.noiseContext.getScenario().getConfig().planCalcScore().getMarginalUtilityOfMoney(), + new NoiseTollCalculator(noiseContext), this.noiseContext.getScenario().getConfig().scoring().getMarginalUtilityOfMoney(), routingConfigGroup.getRoutingRandomness()!=0. ); } diff --git a/contribs/noise/src/main/java/org/matsim/contrib/noise/examples/NoiseOfflineCalculationExample.java b/contribs/noise/src/main/java/org/matsim/contrib/noise/examples/NoiseOfflineCalculationExample.java index 91827345ec8..27628d7c405 100644 --- a/contribs/noise/src/main/java/org/matsim/contrib/noise/examples/NoiseOfflineCalculationExample.java +++ b/contribs/noise/src/main/java/org/matsim/contrib/noise/examples/NoiseOfflineCalculationExample.java @@ -29,43 +29,43 @@ import org.matsim.core.scenario.ScenarioUtils; /** - * - * An example how to compute noise levels, damages etc. for a single iteration (= offline noise computation). - * + * + * An example how to compute noise levels, damages etc. for a single iteration (= offline noise computation). + * * @author ikaddoura * */ public class NoiseOfflineCalculationExample { - + private static String runDirectory = "pathTo/RunDirectory/"; private static String outputDirectory = "pathTo/analysis-output-directory/"; private static String runId = "runXYZ"; - + public static void main(String[] args) { - + Config config = ConfigUtils.createConfig(new NoiseConfigGroup()); - config.controler().setRunId(runId); + config.controller().setRunId(runId); config.network().setInputFile(runDirectory + runId + ".output_network.xml.gz"); config.plans().setInputFile(runDirectory + runId + ".output_plans.xml.gz"); - config.controler().setOutputDirectory(runDirectory); - + config.controller().setOutputDirectory(runDirectory); + // adjust the default noise parameters NoiseConfigGroup noiseParameters = ConfigUtils.addOrGetModule(config,NoiseConfigGroup.class) ; noiseParameters.setReceiverPointGap(12345789.); // ... - + Scenario scenario = ScenarioUtils.loadScenario(config); - + NoiseOfflineCalculation noiseCalculation = new NoiseOfflineCalculation(scenario, outputDirectory); noiseCalculation.run(); - + // some processing of the output data if (!outputDirectory.endsWith("/")) outputDirectory = outputDirectory + "/"; - + String outputFilePath = outputDirectory + "noise-analysis/"; ProcessNoiseImmissions process = new ProcessNoiseImmissions(outputFilePath + "immissions/", outputFilePath + "receiverPoints/receiverPoints.csv", noiseParameters.getReceiverPointGap()); process.run(); - + final String[] labels = { "immission", "consideredAgentUnits" , "damages_receiverPoint" }; final String[] workingDirectories = { outputFilePath + "/immissions/" , outputFilePath + "/consideredAgentUnits/" , outputFilePath + "/damages_receiverPoint/" }; diff --git a/contribs/noise/src/main/java/org/matsim/contrib/noise/examples/NoiseOnlineControlerExample.java b/contribs/noise/src/main/java/org/matsim/contrib/noise/examples/NoiseOnlineControlerExample.java index 5aa94aaa304..4f8fb1a59bf 100644 --- a/contribs/noise/src/main/java/org/matsim/contrib/noise/examples/NoiseOnlineControlerExample.java +++ b/contribs/noise/src/main/java/org/matsim/contrib/noise/examples/NoiseOnlineControlerExample.java @@ -18,7 +18,7 @@ * *********************************************************************** */ /** - * + * */ package org.matsim.contrib.noise.examples; @@ -34,35 +34,35 @@ /** * An example how to use the noise module during a MATSim run (= online noise computation). - * + * * The {@link NoiseConfigGroup} specifies parameters that are relevant for the noise computation and if noise damages are internalized. * For the internalization of noise damages, there is an average and a marginal cost pricing approach, see {@link NoiseConfigGroup.NoiseAllocationApproach}. - * - * For an example of how to compute noise levels, damages etc. for a final iteration (= offline noise computation), see {@link NoiseOfflineCalculationExample}. - * + * + * For an example of how to compute noise levels, damages etc. for a final iteration (= offline noise computation), see {@link NoiseOfflineCalculationExample}. + * * @author ikaddoura * */ public class NoiseOnlineControlerExample { - + private static final String configFile = "./contribs/noise/test/input/org/matsim/contrib/noise/config.xml"; public static void main(String[] args) { - + Config config = ConfigUtils.loadConfig(configFile, new NoiseConfigGroup()); Scenario scenario = ScenarioUtils.loadScenario(config); - + Controler controler = new Controler(scenario); controler.addOverridingModule(new NoiseModule()); - - controler.getConfig().controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists); + + controler.getConfig().controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists); controler.run(); - + // optionally process the output data - String workingDirectory = controler.getConfig().controler().getOutputDirectory() + "/ITERS/it." + controler.getConfig().controler().getLastIteration() + "/immissions/"; - String receiverPointsFile = controler.getConfig().controler().getOutputDirectory() + "/receiverPoints/receiverPoints.csv"; + String workingDirectory = controler.getConfig().controller().getOutputDirectory() + "/ITERS/it." + controler.getConfig().controller().getLastIteration() + "/immissions/"; + String receiverPointsFile = controler.getConfig().controller().getOutputDirectory() + "/receiverPoints/receiverPoints.csv"; NoiseConfigGroup noiseParameters = ConfigUtils.addOrGetModule(config, NoiseConfigGroup.class ) ; ProcessNoiseImmissions processNoiseImmissions = new ProcessNoiseImmissions(workingDirectory, receiverPointsFile, noiseParameters.getReceiverPointGap()); - processNoiseImmissions.run(); + processNoiseImmissions.run(); } } diff --git a/contribs/noise/src/test/java/org/matsim/contrib/noise/NoiseConfigGroupIT.java b/contribs/noise/src/test/java/org/matsim/contrib/noise/NoiseConfigGroupIT.java index 512440cab25..7e07654ace8 100644 --- a/contribs/noise/src/test/java/org/matsim/contrib/noise/NoiseConfigGroupIT.java +++ b/contribs/noise/src/test/java/org/matsim/contrib/noise/NoiseConfigGroupIT.java @@ -18,7 +18,7 @@ * *********************************************************************** */ /** - * + * */ package org.matsim.contrib.noise; @@ -39,58 +39,58 @@ */ public class NoiseConfigGroupIT { - + @Rule public MatsimTestUtils testUtils = new MatsimTestUtils(); - + @Test public final void test0(){ - + String configFile = testUtils.getPackageInputDirectory() + "NoiseConfigGroupTest/config0.xml"; Config config = ConfigUtils.loadConfig(configFile, new NoiseConfigGroup()); - config.controler().setOutputDirectory(testUtils.getOutputDirectory()); - + config.controller().setOutputDirectory(testUtils.getOutputDirectory()); + NoiseConfigGroup noiseParameters = (NoiseConfigGroup) config.getModule("noise"); // test the config parameters Assert.assertEquals("wrong config parameter", 12345., noiseParameters.getReceiverPointGap(), MatsimTestUtils.EPSILON); - + String actForRecPtGrid = noiseParameters.getConsideredActivitiesForReceiverPointGridArray()[0] + "," + noiseParameters.getConsideredActivitiesForReceiverPointGridArray()[1] + "," + noiseParameters.getConsideredActivitiesForReceiverPointGridArray()[2]; - Assert.assertEquals("wrong config parameter", "home,sleep,eat", actForRecPtGrid); - + Assert.assertEquals("wrong config parameter", "home,sleep,eat", actForRecPtGrid); + String actForSpatFct = noiseParameters.getConsideredActivitiesForDamageCalculationArray()[0] + "," + noiseParameters.getConsideredActivitiesForDamageCalculationArray()[1] + "," + noiseParameters.getConsideredActivitiesForDamageCalculationArray()[2]; - Assert.assertEquals("wrong config parameter", "work,leisure,other", actForSpatFct); - + Assert.assertEquals("wrong config parameter", "work,leisure,other", actForSpatFct); + Assert.assertEquals("wrong config parameter", 12345789., noiseParameters.getRelevantRadius(), MatsimTestUtils.EPSILON); Assert.assertFalse("wrong config parameter", noiseParameters.isComputeNoiseDamages()); String hgvIdPrefixes = noiseParameters.getHgvIdPrefixesArray()[0] + "," + noiseParameters.getHgvIdPrefixesArray()[1] + "," + noiseParameters.getHgvIdPrefixesArray()[2] + "," + noiseParameters.getHgvIdPrefixesArray()[3]; - Assert.assertEquals("wrong config parameter", "lkw,LKW,HGV,hgv", hgvIdPrefixes); - + Assert.assertEquals("wrong config parameter", "lkw,LKW,HGV,hgv", hgvIdPrefixes); + String tunnelLinkIds = noiseParameters.getTunnelLinkIDsSet().toArray()[0] + "," + noiseParameters.getTunnelLinkIDsSet().toArray()[1]; Assert.assertEquals("wrong config parameter", "link1,link2", tunnelLinkIds); } - + @Test public final void test1(){ - + String configFile = testUtils.getPackageInputDirectory() + "NoiseConfigGroupTest/config1.xml"; Config config = ConfigUtils.loadConfig(configFile, new NoiseConfigGroup()); - config.controler().setOutputDirectory(testUtils.getOutputDirectory()); - + config.controller().setOutputDirectory(testUtils.getOutputDirectory()); + NoiseConfigGroup noiseParameters = (NoiseConfigGroup) config.getModule("noise"); - + // see if the custom config group is written into the output config file Scenario scenario = ScenarioUtils.loadScenario(config); Controler controler = new Controler(scenario); controler.addOverridingModule(new NoiseModule()); - controler.getConfig().controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists); + controler.getConfig().controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists); controler.run(); - - Config outputConfig = ConfigUtils.loadConfig(controler.getConfig().controler().getOutputDirectory() + "/output_config.xml", new NoiseConfigGroup()); + + Config outputConfig = ConfigUtils.loadConfig(controler.getConfig().controller().getOutputDirectory() + "/output_config.xml", new NoiseConfigGroup()); NoiseConfigGroup outputNoiseParameters = (NoiseConfigGroup) outputConfig.getModule("noise"); - + Assert.assertEquals("input and output config parameters are not the same", noiseParameters.toString(), outputNoiseParameters.toString()); } diff --git a/contribs/noise/src/test/java/org/matsim/contrib/noise/NoiseIT.java b/contribs/noise/src/test/java/org/matsim/contrib/noise/NoiseIT.java index 1fe1a7e866a..aa179afd113 100644 --- a/contribs/noise/src/test/java/org/matsim/contrib/noise/NoiseIT.java +++ b/contribs/noise/src/test/java/org/matsim/contrib/noise/NoiseIT.java @@ -82,7 +82,7 @@ public final void test1(){ String configFile = testUtils.getPackageInputDirectory() + "NoiseTest/config1.xml"; Config config = ConfigUtils.loadConfig(configFile, new NoiseConfigGroup()); - config.controler().setOutputDirectory(testUtils.getOutputDirectory()); + config.controller().setOutputDirectory(testUtils.getOutputDirectory()); Scenario scenario = ScenarioUtils.loadScenario(config); @@ -154,8 +154,8 @@ public final void test2a(){ // start a simple MATSim run with a single iteration String configFile = testUtils.getPackageInputDirectory() + "NoiseTest/config2.xml"; Config config = ConfigUtils.loadConfig(configFile ) ; - config.controler().setOutputDirectory(testUtils.getOutputDirectory()); - config.plansCalcRoute().setAccessEgressType(RoutingConfigGroup.AccessEgressType.none); + config.controller().setOutputDirectory(testUtils.getOutputDirectory()); + config.routing().setAccessEgressType(RoutingConfigGroup.AccessEgressType.none); runTest2a( config ) ; } @Test @@ -163,8 +163,8 @@ public final void test2aWAccessEgress(){ // start a simple MATSim run with a single iteration String configFile = testUtils.getPackageInputDirectory() + "NoiseTest/config2.xml"; Config config = ConfigUtils.loadConfig(configFile ) ; - config.controler().setOutputDirectory(testUtils.getOutputDirectory()); - config.plansCalcRoute().setAccessEgressType(AccessEgressType.accessEgressModeToLink); + config.controller().setOutputDirectory(testUtils.getOutputDirectory()); + config.routing().setAccessEgressType(AccessEgressType.accessEgressModeToLink); // { // ModeRoutingParams params = new ModeRoutingParams( TransportMode.non_network_walk ); // params.setTeleportedModeSpeed( 2.0 ); @@ -176,19 +176,19 @@ public final void test2aWAccessEgress(){ private static void runTest2a( Config runConfig ) { Controler controler = new Controler(runConfig); - controler.getConfig().controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists ); + controler.getConfig().controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists ); controler.run(); // run the noise analysis for the final iteration (offline) - String runDirectory = controler.getConfig().controler().getOutputDirectory(); + String runDirectory = controler.getConfig().controller().getOutputDirectory(); if (!runDirectory.endsWith("/")) runDirectory = runDirectory + "/"; Config config = ConfigUtils.createConfig(new NoiseConfigGroup()); config.network().setInputFile(runDirectory + "output_network.xml.gz"); config.plans().setInputFile(runDirectory + "output_plans.xml.gz"); - config.controler().setOutputDirectory(runDirectory); - config.controler().setLastIteration(controler.getConfig().controler().getLastIteration()); + config.controller().setOutputDirectory(runDirectory); + config.controller().setLastIteration(controler.getConfig().controller().getLastIteration()); NoiseConfigGroup noiseParameters = (NoiseConfigGroup) config.getModules().get(NoiseConfigGroup.GROUP_NAME); @@ -249,7 +249,7 @@ public void handleEvent(ActivityEndEvent event) { events.initProcessing(); MatsimEventsReader reader = new MatsimEventsReader(events); - reader.readFile(runDirectory + "ITERS/it." + config.controler().getLastIteration() + "/" + config.controler().getLastIteration() + ".events.xml.gz"); + reader.readFile(runDirectory + "ITERS/it." + config.controller().getLastIteration() + "/" + config.controller().getLastIteration() + ".events.xml.gz"); events.finishProcessing(); // ############################ @@ -411,7 +411,7 @@ else if(event.getActType().equals("work")){ affectedPersons = ( unitsThisPersonActivityInfo * noiseParameters.getScaleFactor() ); int outOfHomeActIdx = 2 ; - if ( !runConfig.plansCalcRoute().getAccessEgressType().equals(RoutingConfigGroup.AccessEgressType.none) ) { + if ( !runConfig.routing().getAccessEgressType().equals(RoutingConfigGroup.AccessEgressType.none) ) { outOfHomeActIdx = 6 ; } Coord coord = actInfo.getActivityType().equals("home") ? @@ -440,7 +440,7 @@ else if(event.getActType().equals("work")){ if(currentTimeSlot == endTime){ - if ( !runConfig.plansCalcRoute().getAccessEgressType().equals(AccessEgressType.none) ) { + if ( !runConfig.routing().getAccessEgressType().equals(AccessEgressType.none) ) { Assert.assertEquals("Wrong number of affected persons at receiver point 16", 2.3447222222222224, affectedPersonsPerReceiverPointTest.get(Id.create("16", ReceiverPoint.class)), MatsimTestUtils.EPSILON); // result changed after changing where agents are walking to in access/egress (July 20) @@ -473,7 +473,7 @@ else if(event.getActType().equals("work")){ log.warn( "receiverPointId:" + receiverPointId ); log.warn( "affected:" + list ) ; } - if ( !!runConfig.plansCalcRoute().getAccessEgressType().equals(AccessEgressType.none) ) { + if ( !!runConfig.routing().getAccessEgressType().equals(AccessEgressType.none) ) { Assert.assertEquals("Wrong number of affected persons", expected, actual, MatsimTestUtils.EPSILON); } else { Assert.assertEquals("Wrong number of affected persons", expected, actual, MatsimTestUtils.EPSILON); @@ -684,7 +684,7 @@ else if(event.getActType().equals("work")){ } - if ( !!runConfig.plansCalcRoute().getAccessEgressType().equals(AccessEgressType.none) ) { + if ( !!runConfig.routing().getAccessEgressType().equals(AccessEgressType.none) ) { Assert.assertEquals("Wrong damage!", 0.0664164095284536, damagesPerReceiverPointId.get(Id.create("16", ReceiverPoint.class)), MatsimTestUtils.EPSILON); } else { @@ -738,7 +738,7 @@ else if(event.getActType().equals("work")){ e.printStackTrace(); } - if ( !!runConfig.plansCalcRoute().getAccessEgressType().equals(AccessEgressType.none) ) { + if ( !!runConfig.routing().getAccessEgressType().equals(AccessEgressType.none) ) { Assert.assertEquals("Wrong link's damage contribution!", 0.00079854651258, damagesPerlinkId.get(Id.create("link2", Link.class)), MatsimTestUtils.EPSILON); Assert.assertEquals("Wrong link's damage contribution!", 0.06561786301587, @@ -788,7 +788,7 @@ else if(event.getActType().equals("work")){ e.printStackTrace(); } - if ( !!runConfig.plansCalcRoute().getAccessEgressType().equals(AccessEgressType.none) ) { + if ( !!runConfig.routing().getAccessEgressType().equals(AccessEgressType.none) ) { Assert.assertEquals("Wrong damage per car per link!", 0.00079854651258 / 2.0, damagesPerCar.get(Id.create("link2", Link.class)), MatsimTestUtils.EPSILON); Assert.assertEquals("Wrong damage per car per link!", 0.06561786301587 / 2.0, @@ -835,7 +835,7 @@ else if(event.getActType().equals("work")){ e.printStackTrace(); } - if ( !!runConfig.plansCalcRoute().getAccessEgressType().equals(AccessEgressType.none) ) { + if ( !!runConfig.routing().getAccessEgressType().equals(AccessEgressType.none) ) { Assert.assertEquals("Wrong damage per car per link!", 0.00011994155845965193, marginaldamagesPerCar.get(Id.create("link2", Link.class)), MatsimTestUtils.EPSILON); Assert.assertEquals("Wrong damage per car per link!", 0.008531432493391652, @@ -861,7 +861,7 @@ else if(event.getActType().equals("work")){ tested = true; if (event.getTimeBinEndTime() == 11 * 3600. && event.getLinkId().toString().equals(Id.create("linkA5", Link.class).toString()) && event.getCausingVehicleId().toString().equals((Id.create("person_car_test1", Vehicle.class).toString()))) { - if ( !!runConfig.plansCalcRoute().getAccessEgressType().equals(AccessEgressType.none) ) { + if ( !!runConfig.routing().getAccessEgressType().equals(AccessEgressType.none) ) { Assert.assertEquals("wrong cost per car for the given link and time interval", 0.0328089315079348, event.getAmount(), MatsimTestUtils.EPSILON); } else { @@ -870,7 +870,7 @@ else if(event.getActType().equals("work")){ } counter++; } else if (event.getTimeBinEndTime() == 11 * 3600. && event.getLinkId().toString().equals(Id.create("linkA5", Link.class).toString()) && event.getCausingVehicleId().toString().equals((Id.create("person_car_test2", Vehicle.class).toString()))) { - if ( !!runConfig.plansCalcRoute().getAccessEgressType().equals(AccessEgressType.none) ) { + if ( !!runConfig.routing().getAccessEgressType().equals(AccessEgressType.none) ) { Assert.assertEquals("wrong cost per car for the given link and time interval", 0.0328089315079348, event.getAmount(), MatsimTestUtils.EPSILON); } else { @@ -879,7 +879,7 @@ else if(event.getActType().equals("work")){ } counter++; } else if (event.getTimeBinEndTime() == 11 * 3600. && event.getLinkId().toString().equals(Id.create("link2", Link.class).toString()) && event.getCausingVehicleId().toString().equals((Id.create("person_car_test1", Vehicle.class).toString()))) { - if ( !!runConfig.plansCalcRoute().getAccessEgressType().equals(AccessEgressType.none) ) { + if ( !!runConfig.routing().getAccessEgressType().equals(AccessEgressType.none) ) { Assert.assertEquals("wrong cost per car for the given link and time interval", 3.992732562920194E-4, event.getAmount(), MatsimTestUtils.EPSILON); } else { @@ -888,7 +888,7 @@ else if(event.getActType().equals("work")){ } counter++; } else if (event.getTimeBinEndTime() == 11 * 3600. && event.getLinkId().toString().equals(Id.create("link2", Link.class).toString()) && event.getCausingVehicleId().toString().equals((Id.create("person_car_test2", Vehicle.class).toString()))) { - if ( !!runConfig.plansCalcRoute().getAccessEgressType().equals(AccessEgressType.none) ) { + if ( !!runConfig.routing().getAccessEgressType().equals(AccessEgressType.none) ) { Assert.assertEquals("wrong cost per car for the given link and time interval", 3.992732562920194E-4, event.getAmount(), MatsimTestUtils.EPSILON); } else { @@ -910,7 +910,7 @@ else if(event.getActType().equals("work")){ tested2 = true; if (event.getTimeBinEndTime() == 11 * 3600. && event.getrReceiverPointId().toString().equals(Id.create("16", ReceiverPoint.class).toString()) && event.getAffectedAgentId().toString().equals((Id.create("person_car_test1", Person.class).toString())) && event.getActType().equals("work") ) { - if ( !!runConfig.plansCalcRoute().getAccessEgressType().equals(AccessEgressType.none) ) { + if ( !!runConfig.routing().getAccessEgressType().equals(AccessEgressType.none) ) { Assert.assertEquals("wrong cost per car for the given link and time interval", 0.020745817449213576, event.getAmount(), MatsimTestUtils.EPSILON); } else { @@ -919,7 +919,7 @@ else if(event.getActType().equals("work")){ } counter2++; } else if (event.getTimeBinEndTime() == 11 * 3600. && event.getrReceiverPointId().toString().equals(Id.create("16", ReceiverPoint.class).toString()) && event.getAffectedAgentId().toString().equals((Id.create("person_car_test2", Person.class).toString())) && event.getActType().equals("work")) { - if ( !!runConfig.plansCalcRoute().getAccessEgressType().equals(AccessEgressType.none) ) { + if ( !!runConfig.routing().getAccessEgressType().equals(AccessEgressType.none) ) { Assert.assertEquals("wrong cost per car for the given link and time interval", 0.017444990107520864, event.getAmount(), MatsimTestUtils.EPSILON); } else { @@ -928,7 +928,7 @@ else if(event.getActType().equals("work")){ } counter2++; } else if (event.getTimeBinEndTime() == 11 * 3600. && event.getrReceiverPointId().toString().equals(Id.create("16", ReceiverPoint.class).toString()) && event.getAffectedAgentId().toString().equals((Id.create("person_car_test3", Person.class).toString())) && event.getActType().equals("home")) { - if ( !!runConfig.plansCalcRoute().getAccessEgressType().equals(AccessEgressType.none) ) { + if ( !!runConfig.routing().getAccessEgressType().equals(AccessEgressType.none) ) { Assert.assertEquals("wrong cost per car for the given link and time interval", 0.028225601971719153, event.getAmount(), MatsimTestUtils.EPSILON); } else { @@ -956,17 +956,17 @@ public final void test2b(){ // start a simple MATSim run with a single iteration String configFile = testUtils.getPackageInputDirectory() + "NoiseTest/config2.xml"; Config runConfig = ConfigUtils.loadConfig( configFile ) ; - runConfig.controler().setOutputDirectory(testUtils.getOutputDirectory()); + runConfig.controller().setOutputDirectory(testUtils.getOutputDirectory()); - runConfig.plansCalcRoute().setAccessEgressType(RoutingConfigGroup.AccessEgressType.none); + runConfig.routing().setAccessEgressType(RoutingConfigGroup.AccessEgressType.none); // I made test2a test both versions, but I don't really want to do that work again myself. kai, feb'16 Controler controler = new Controler(runConfig); - controler.getConfig().controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists ); + controler.getConfig().controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists ); controler.run(); - runDirectory = controler.getConfig().controler().getOutputDirectory() + "/"; - lastIteration = controler.getConfig().controler().getLastIteration(); + runDirectory = controler.getConfig().controller().getOutputDirectory() + "/"; + lastIteration = controler.getConfig().controller().getLastIteration(); } // run the noise analysis for the final iteration (offline) @@ -974,8 +974,8 @@ public final void test2b(){ Config config = ConfigUtils.createConfig(); config.network().setInputFile(runDirectory + "output_network.xml.gz"); config.plans().setInputFile(runDirectory + "output_plans.xml.gz"); - config.controler().setOutputDirectory(runDirectory); - config.controler().setLastIteration(lastIteration); + config.controller().setOutputDirectory(runDirectory); + config.controller().setLastIteration(lastIteration); // adjust the default noise parameters NoiseConfigGroup noiseParameters = ConfigUtils.addOrGetModule(config, NoiseConfigGroup.class); @@ -1052,19 +1052,19 @@ public final void test2c(){ // start a simple MATSim run with a single iteration String configFile = testUtils.getPackageInputDirectory() + "NoiseTest/config2.xml"; Controler controler = new Controler(configFile); - controler.getConfig().controler().setOutputDirectory(testUtils.getOutputDirectory()); - controler.getConfig().controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists ); + controler.getConfig().controller().setOutputDirectory(testUtils.getOutputDirectory()); + controler.getConfig().controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists ); controler.run(); // run the noise analysis for the final iteration (offline) - String runDirectory = controler.getConfig().controler().getOutputDirectory() + "/"; + String runDirectory = controler.getConfig().controller().getOutputDirectory() + "/"; Config config = ConfigUtils.createConfig(new NoiseConfigGroup()); config.network().setInputFile(runDirectory + "output_network.xml.gz"); config.plans().setInputFile(runDirectory + "output_plans.xml.gz"); - config.controler().setOutputDirectory(runDirectory); - config.controler().setLastIteration(controler.getConfig().controler().getLastIteration()); + config.controller().setOutputDirectory(runDirectory); + config.controller().setLastIteration(controler.getConfig().controller().getLastIteration()); // adjust the default noise parameters NoiseConfigGroup noiseParameters = (NoiseConfigGroup) config.getModules().get(NoiseConfigGroup.GROUP_NAME); @@ -1122,7 +1122,7 @@ public void handleEvent(ActivityEndEvent event) { }); MatsimEventsReader reader = new MatsimEventsReader(events); - reader.readFile(runDirectory + "ITERS/it." + config.controler().getLastIteration() + "/" + config.controler().getLastIteration() + ".events.xml.gz"); + reader.readFile(runDirectory + "ITERS/it." + config.controller().getLastIteration() + "/" + config.controller().getLastIteration() + ".events.xml.gz"); double endTime = 39600; diff --git a/contribs/noise/src/test/java/org/matsim/contrib/noise/NoiseOnlineExampleIT.java b/contribs/noise/src/test/java/org/matsim/contrib/noise/NoiseOnlineExampleIT.java index 71cee7bb30c..c03d5d04e57 100644 --- a/contribs/noise/src/test/java/org/matsim/contrib/noise/NoiseOnlineExampleIT.java +++ b/contribs/noise/src/test/java/org/matsim/contrib/noise/NoiseOnlineExampleIT.java @@ -18,7 +18,7 @@ * *********************************************************************** */ /** - * + * */ package org.matsim.contrib.noise; @@ -53,7 +53,7 @@ public class NoiseOnlineExampleIT { private static final Logger log = LogManager.getLogger( NoiseOnlineExampleIT.class ) ; - + @Rule public MatsimTestUtils testUtils = new MatsimTestUtils(); @@ -62,8 +62,8 @@ public final void test0(){ String configFile = testUtils.getPackageInputDirectory() + "config.xml"; Config config = ConfigUtils.loadConfig(configFile, new NoiseConfigGroup()); - config.controler().setLastIteration(1); - config.controler().setOutputDirectory( testUtils.getOutputDirectory() ); + config.controller().setLastIteration(1); + config.controller().setOutputDirectory( testUtils.getOutputDirectory() ); NoiseConfigGroup noiseParameters = (NoiseConfigGroup) config.getModule("noise"); noiseParameters.setWriteOutputIteration(1); @@ -73,8 +73,8 @@ public final void test0(){ controler.addOverridingModule(new NoiseModule()); controler.run(); - String workingDirectory = controler.getConfig().controler().getOutputDirectory() + "/ITERS/it." + controler.getConfig().controler().getLastIteration() + "/immissions/"; - String receiverPointsFile = controler.getConfig().controler().getOutputDirectory() + "/receiverPoints/receiverPoints.csv"; + String workingDirectory = controler.getConfig().controller().getOutputDirectory() + "/ITERS/it." + controler.getConfig().controller().getLastIteration() + "/immissions/"; + String receiverPointsFile = controler.getConfig().controller().getOutputDirectory() + "/receiverPoints/receiverPoints.csv"; ProcessNoiseImmissions processNoiseImmissions = new ProcessNoiseImmissions(workingDirectory, receiverPointsFile, noiseParameters.getReceiverPointGap()); processNoiseImmissions.run(); } @@ -83,8 +83,8 @@ public final void test0(){ public final void testOnTheFlyAggregationTerms() { String configFile = testUtils.getPackageInputDirectory() + "config.xml"; Config config = ConfigUtils.loadConfig(configFile, new NoiseConfigGroup()); - config.controler().setLastIteration(1); - config.controler().setOutputDirectory( testUtils.getOutputDirectory() ); + config.controller().setLastIteration(1); + config.controller().setOutputDirectory( testUtils.getOutputDirectory() ); NoiseConfigGroup noiseParameters = (NoiseConfigGroup) config.getModule("noise"); noiseParameters.setWriteOutputIteration(1); @@ -127,12 +127,12 @@ public final void testOnTheFlyAggregationTerms() { controler.run(); //run file based noise processing as reference - String workingDirectory = controler.getConfig().controler().getOutputDirectory() + "/ITERS/it." + controler.getConfig().controler().getLastIteration() + "/immissions/"; - String receiverPointsFile = controler.getConfig().controler().getOutputDirectory() + "/receiverPoints/receiverPoints.csv"; + String workingDirectory = controler.getConfig().controller().getOutputDirectory() + "/ITERS/it." + controler.getConfig().controller().getLastIteration() + "/immissions/"; + String receiverPointsFile = controler.getConfig().controller().getOutputDirectory() + "/receiverPoints/receiverPoints.csv"; ProcessNoiseImmissions processNoiseImmissions = new ProcessNoiseImmissions(workingDirectory, receiverPointsFile, noiseParameters.getReceiverPointGap()); processNoiseImmissions.run(); - String pathToImmissionsFile = controler.getConfig().controler().getOutputDirectory() + "/ITERS/it." + controler.getConfig().controler().getLastIteration() + "/immissions/immission_processed.csv"; + String pathToImmissionsFile = controler.getConfig().controller().getOutputDirectory() + "/ITERS/it." + controler.getConfig().controller().getLastIteration() + "/immissions/immission_processed.csv"; //store file based noise aggregation terms by receiver Map, Double> ldenByRp = new HashMap<>(); @@ -183,8 +183,8 @@ public final void testOnTheFlyAggregationTerms() { public final void testNoiseListener(){ Config config = ConfigUtils.loadConfig( testUtils.getPackageInputDirectory() + "config.xml", new NoiseConfigGroup() ); - config.controler().setLastIteration(1); - config.controler().setOutputDirectory( testUtils.getOutputDirectory() ); + config.controller().setLastIteration(1); + config.controller().setOutputDirectory( testUtils.getOutputDirectory() ); NoiseConfigGroup noiseParameters = (NoiseConfigGroup) config.getModule("noise"); noiseParameters.setWriteOutputIteration(1); @@ -206,8 +206,8 @@ public final void testNoiseListener(){ controler.run(); - String workingDirectory = controler.getConfig().controler().getOutputDirectory() + "/ITERS/it." + controler.getConfig().controler().getLastIteration() + "/immissions/"; - String receiverPointsFile = controler.getConfig().controler().getOutputDirectory() + "/receiverPoints/receiverPoints.csv"; + String workingDirectory = controler.getConfig().controller().getOutputDirectory() + "/ITERS/it." + controler.getConfig().controller().getLastIteration() + "/immissions/"; + String receiverPointsFile = controler.getConfig().controller().getOutputDirectory() + "/receiverPoints/receiverPoints.csv"; ProcessNoiseImmissions processNoiseImmissions = new ProcessNoiseImmissions(workingDirectory, receiverPointsFile, noiseParameters.getReceiverPointGap()); processNoiseImmissions.addListener( new NoiseModule.NoiseListener() { @Override public void newRecord( XYTRecord record ) { log.warn( record ) ; } diff --git a/contribs/otfvis/src/main/java/org/matsim/contrib/otfvis/OTFVisFileWriterModule.java b/contribs/otfvis/src/main/java/org/matsim/contrib/otfvis/OTFVisFileWriterModule.java index 0d4ca15b752..7ea8fb8d7d5 100644 --- a/contribs/otfvis/src/main/java/org/matsim/contrib/otfvis/OTFVisFileWriterModule.java +++ b/contribs/otfvis/src/main/java/org/matsim/contrib/otfvis/OTFVisFileWriterModule.java @@ -33,7 +33,7 @@ public class OTFVisFileWriterModule extends AbstractModule { @Override public void install() { ConfigUtils.addOrGetModule(getConfig(), OTFVisConfigGroup.GROUP_NAME, OTFVisConfigGroup.class); - if (getConfig().controler().getSnapshotFormat().contains( SnapshotFormat.otfvis )) { + if (getConfig().controller().getSnapshotFormat().contains( SnapshotFormat.otfvis )) { addSnapshotWriterBinding().toProvider(OTFFileWriterFactory.class); } } diff --git a/contribs/otfvis/src/test/java/org/matsim/contrib/otfvis/OTFVisIT.java b/contribs/otfvis/src/test/java/org/matsim/contrib/otfvis/OTFVisIT.java index 5675aa0a980..d713edcd6ab 100644 --- a/contribs/otfvis/src/test/java/org/matsim/contrib/otfvis/OTFVisIT.java +++ b/contribs/otfvis/src/test/java/org/matsim/contrib/otfvis/OTFVisIT.java @@ -67,20 +67,20 @@ public void testConvert() { @Test public void testOTFVisSnapshotWriterOnQSim() { final Config config = ConfigUtils.loadConfig("test/scenarios/equil/config_plans1.xml"); - config.controler().setLastIteration(2); - config.controler().setWriteEventsInterval(0); - config.controler().setWritePlansInterval(0); - config.controler().setMobsim("qsim"); - config.controler().setSnapshotFormat( Collections.singletonList( SnapshotFormat.otfvis ) ); + config.controller().setLastIteration(2); + config.controller().setWriteEventsInterval(0); + config.controller().setWritePlansInterval(0); + config.controller().setMobsim("qsim"); + config.controller().setSnapshotFormat( Collections.singletonList( SnapshotFormat.otfvis ) ); QSimConfigGroup qSimConfigGroup = config.qsim(); qSimConfigGroup.setSnapshotPeriod(600); qSimConfigGroup.setSnapshotStyle( SnapshotStyle.equiDist ) ;; final Controler controler = new Controler(config); controler.addOverridingModule(new OTFVisFileWriterModule()); - controler.getConfig().controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles); - controler.getConfig().controler().setCreateGraphs(false); - controler.getConfig().controler().setDumpDataAtEnd(false); + controler.getConfig().controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles); + controler.getConfig().controller().setCreateGraphs(false); + controler.getConfig().controller().setDumpDataAtEnd(false); controler.run(); Assert.assertTrue(new File(controler.getControlerIO().getIterationFilename(0, "otfvis.mvi")).exists()); diff --git a/contribs/otfvis/src/test/java/org/matsim/vis/otfvis/checklists/T2_RunControlerWithMovieOutput.java b/contribs/otfvis/src/test/java/org/matsim/vis/otfvis/checklists/T2_RunControlerWithMovieOutput.java index 2cfc0f5e895..0469294ebc4 100644 --- a/contribs/otfvis/src/test/java/org/matsim/vis/otfvis/checklists/T2_RunControlerWithMovieOutput.java +++ b/contribs/otfvis/src/test/java/org/matsim/vis/otfvis/checklists/T2_RunControlerWithMovieOutput.java @@ -1,6 +1,6 @@ /* *********************************************************************** * * project: org.matsim.* - * + * * * * *********************************************************************** * * * @@ -31,10 +31,10 @@ public class T2_RunControlerWithMovieOutput { public static void main(String[] args) { Controler con = new Controler("test/scenarios/equil/config-qsim.xml"); - con.getConfig().controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles); + con.getConfig().controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles); con.addOverridingModule(new OTFVisFileWriterModule()); con.run(); - System.out.println("\n QSim is done. Output:" + con.getConfig().controler().getOutputDirectory()); + System.out.println("\n QSim is done. Output:" + con.getConfig().controller().getOutputDirectory()); } } diff --git a/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingchoice/PC2/scoring/ParkingScoreManager.java b/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingchoice/PC2/scoring/ParkingScoreManager.java index a25725940c1..49fd0109768 100644 --- a/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingchoice/PC2/scoring/ParkingScoreManager.java +++ b/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingchoice/PC2/scoring/ParkingScoreManager.java @@ -60,7 +60,7 @@ public double calcWalkScore(Coord destCoord, PC2Parking parking, Id pers double linkLength = link.getLength(); double walkDistance = CoordUtils.calcEuclideanDistance(destCoord, parking.getCoordinate()) - * scenario.getConfig().plansCalcRoute().getBeelineDistanceFactors().get("walk")* beelineDistanceFactor; + * scenario.getConfig().routing().getBeelineDistanceFactors().get("walk")* beelineDistanceFactor; double walkSpeed = linkLength / this.walkTravelTime.getLinkTravelTime(link, 0, person, null); diff --git a/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingchoice/run/RunParkingChoiceExample.java b/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingchoice/run/RunParkingChoiceExample.java index 35113f4625a..e53da13e52d 100644 --- a/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingchoice/run/RunParkingChoiceExample.java +++ b/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingchoice/run/RunParkingChoiceExample.java @@ -44,8 +44,8 @@ /** * @author jbischoff * Sample main file for setting up an Matsim run with parking. Check the output events for Parking events and the scores. - * - * + * + * */ public class RunParkingChoiceExample { @@ -58,12 +58,12 @@ public static void run(Config config) { Scenario scenario = ScenarioUtils.loadScenario(config); Controler controler = new Controler(scenario); - controler.getConfig().controler().setOverwriteFileSetting( OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles ); + controler.getConfig().controller().setOverwriteFileSetting( OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles ); // --- // we need some settings to walk from parking to destination: - ParkingScore parkingScoreManager = new ParkingScoreManager(new WalkTravelTime(controler.getConfig().plansCalcRoute()), scenario); + ParkingScore parkingScoreManager = new ParkingScoreManager(new WalkTravelTime(controler.getConfig().routing()), scenario); parkingScoreManager.setParkingScoreScalingFactor(1); parkingScoreManager.setParkingBetas(new ParkingBetaExample()); diff --git a/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingcost/module/ParkingCostModule.java b/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingcost/module/ParkingCostModule.java index a28c002a198..ae27638cb26 100644 --- a/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingcost/module/ParkingCostModule.java +++ b/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingcost/module/ParkingCostModule.java @@ -35,7 +35,7 @@ public class ParkingCostModule extends AbstractModule { public void install() { ParkingCostConfigGroup parkingCostConfigGroup = ConfigUtils.addOrGetModule(getConfig(), ParkingCostConfigGroup.class); if (parkingCostConfigGroup.useParkingCost) { - Collection mainModes = switch (getConfig().controler().getMobsim()) { + Collection mainModes = switch (getConfig().controller().getMobsim()) { case "qsim" -> getConfig().qsim().getMainModes(); case "hermes" -> getConfig().hermes().getMainModes(); default -> throw new RuntimeException("ParkingCosts are currently supported for Qsim and Hermes"); diff --git a/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingproxy/run/RunWithParkingProxy.java b/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingproxy/run/RunWithParkingProxy.java index 0239f36bd11..9603f5a23ce 100644 --- a/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingproxy/run/RunWithParkingProxy.java +++ b/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingproxy/run/RunWithParkingProxy.java @@ -36,9 +36,9 @@ public static void main(String[] args) { Config config = ConfigUtils.loadConfig(args, parkingConfig); //config.controler().setLastIteration(100); - config.controler().setOverwriteFileSetting(OverwriteFileSetting.overwriteExistingFiles); - config.plansCalcRoute().setAccessEgressType(AccessEgressType.accessEgressModeToLink); - config.planCalcScore().setWriteExperiencedPlans(true); + config.controller().setOverwriteFileSetting(OverwriteFileSetting.overwriteExistingFiles); + config.routing().setAccessEgressType(AccessEgressType.accessEgressModeToLink); + config.scoring().setWriteExperiencedPlans(true); Scenario scen = ScenarioUtils.loadScenario(config); diff --git a/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingsearch/RunParkingSearchExample.java b/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingsearch/RunParkingSearchExample.java index 0d0554b739f..bf76aceb42b 100644 --- a/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingsearch/RunParkingSearchExample.java +++ b/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingsearch/RunParkingSearchExample.java @@ -18,7 +18,7 @@ * *********************************************************************** */ /** - * + * */ package org.matsim.contrib.parking.parkingsearch; @@ -45,10 +45,10 @@ public class RunParkingSearchExample { public static void main(String[] args) { - + Config config = ConfigUtils.loadConfig("parkingsearch/config.xml", new ParkingSearchConfigGroup()); //all further input files are set in the config. - + //get the parking search config group to set some parameters, like agent's search strategy or average parking slot length ParkingSearchConfigGroup configGroup = (ParkingSearchConfigGroup) config.getModules().get(ParkingSearchConfigGroup.GROUP_NAME); configGroup.setParkingSearchStrategy(ParkingSearchStrategy.Benenson); @@ -56,9 +56,9 @@ public static void main(String[] args) { // set to false, if you don't require visualisation, then the example will run for 10 iterations, with OTFVis, only one iteration is performed. boolean otfvis = false; if (otfvis) { - config.controler().setLastIteration(0); + config.controller().setLastIteration(0); } else { - config.controler().setLastIteration(10); + config.controller().setLastIteration(10); } new RunParkingSearchExample().run(config,otfvis); @@ -75,9 +75,9 @@ public void run(Config config, boolean otfvis) { Controler controler = new Controler(scenario); config.qsim().setSnapshotStyle(SnapshotStyle.withHoles); - + controler.addOverridingModule(new AbstractModule() { - + @Override public void install() { ParkingSlotVisualiser visualiser = new ParkingSlotVisualiser(scenario); diff --git a/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingsearch/evaluation/ZoneParkingOccupationListener.java b/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingsearch/evaluation/ZoneParkingOccupationListener.java index 1dbf981bcc1..e8f4e8dfcaa 100644 --- a/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingsearch/evaluation/ZoneParkingOccupationListener.java +++ b/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingsearch/evaluation/ZoneParkingOccupationListener.java @@ -1,5 +1,5 @@ /** - * + * */ package org.matsim.contrib.parking.parkingsearch.evaluation; @@ -29,22 +29,22 @@ * */ public class ZoneParkingOccupationListener implements MobsimBeforeCleanupListener, MobsimAfterSimStepListener{ - + private final ZoneParkingManager zoneManager; private Logger log = LogManager.getLogger(ZoneParkingOccupationListener.class); - private HashMap> zoneOccupationPerTime; + private HashMap> zoneOccupationPerTime; private MatsimServices services; int iteration; - + private TreeSet allMonitoredTimeStamps; - + /** - * + * */ @Inject public ZoneParkingOccupationListener(ParkingSearchManager manager, MatsimServices services, Config config) { this.zoneManager = (ZoneParkingManager) manager; - iteration = config.controler().getFirstIteration(); + iteration = config.controller().getFirstIteration(); this.services = services; this.zoneOccupationPerTime = new HashMap>(); for(String zone : zoneManager.getZones()){ @@ -56,14 +56,14 @@ public ZoneParkingOccupationListener(ParkingSearchManager manager, MatsimService @Override public void notifyMobsimAfterSimStep(MobsimAfterSimStepEvent e) { if( (e.getSimulationTime()%900) == 0 && !(e.getSimulationTime() == 0)){ - + double timeStamp = e.getSimulationTime(); if (!(this.allMonitoredTimeStamps.contains(timeStamp)) ) this.allMonitoredTimeStamps.add(timeStamp); - + for(String zone : this.zoneOccupationPerTime.keySet()){ double occ = this.zoneManager.getOccupancyRatioOfZone(zone); ParkingTuple tuple = new ParkingTuple(timeStamp, occ); - this.zoneOccupationPerTime.get(zone).add(tuple); + this.zoneOccupationPerTime.get(zone).add(tuple); } } } @@ -81,10 +81,10 @@ public void notifyMobsimBeforeCleanup(MobsimBeforeCleanupEvent e) { this.zoneOccupationPerTime.put(zone, tSet); this.allMonitoredTimeStamps.clear(); this.allMonitoredTimeStamps.add(-1.0); - } + } iteration++; } - + private void writeStats(String fileName) { log.error("WRITING OCCUPANCY STATS TO " + fileName); @@ -92,7 +92,7 @@ private void writeStats(String fileName) { for(double d : this.allMonitoredTimeStamps){ head += "" + d +";"; } - + BufferedWriter bw = IOUtils.getBufferedWriter(fileName); try { bw.write(head); @@ -104,10 +104,10 @@ private void writeStats(String fileName) { TreeSet timeSet = new TreeSet(); timeSet.addAll(allMonitoredTimeStamps); double oldOcc = -5.0; - + int zoneSize = currentSet.size(); int timeSize = timeSet.size(); - + for(int i = 0; i < zoneSize; i++){ ParkingTuple ff = currentSet.pollFirst(); for(int zz = 0; zz < timeSize; zz ++ ){ @@ -135,7 +135,7 @@ else if( time == ff.getTime()){ // TODO Auto-generated catch block e.printStackTrace(); } - + log.error("FINISHED WRITING OCCUPANCY STATS"); } @@ -145,34 +145,34 @@ private void writeStatsVertical(String fileName) { String head = ";;"; String capacityLine = "TotalCapacity;;"; String subheader = "SlotNr;SimTime;"; - + ArrayList zoneColumns = new ArrayList(); int numberOfSlots = this.allMonitoredTimeStamps.size(); double[] slotTimes = new double[numberOfSlots]; int[] slotNumbers = new int[numberOfSlots]; TreeSet timeSet = new TreeSet(); timeSet.addAll(allMonitoredTimeStamps); - + for (int timeSlot = 0; timeSlot < numberOfSlots; timeSlot ++ ){ double tt = timeSet.pollFirst(); slotTimes[timeSlot] = tt; - slotNumbers[timeSlot] = (int) (tt/900); + slotNumbers[timeSlot] = (int) (tt/900); } - + for(String zone : this.zoneManager.getZones()){ head += zone +";"; capacityLine += this.zoneManager.getTotalCapacityOfZone(zone) + ";"; subheader += "OccRatio;"; - - + + double[] ratios = new double[numberOfSlots]; - - TreeSet ratioSet = this.zoneOccupationPerTime.get(zone); - + + TreeSet ratioSet = this.zoneOccupationPerTime.get(zone); + double oldRatio = 0.0; for(int i = 0; i < numberOfSlots; i++){ - - ParkingTuple tuple = ratioSet.pollFirst(); + + ParkingTuple tuple = ratioSet.pollFirst(); if(slotTimes[i] == tuple.getTime()){ ratios[i] = tuple.getOccupancy(); oldRatio = tuple.getOccupancy(); @@ -184,10 +184,10 @@ else if(slotTimes[i] < tuple.getTime()){ throw new RuntimeException("timeSlot number is higher than recorded time. timeSlot: " + slotTimes[i] + "\t time: " + tuple.getTime()); } } - - zoneColumns.add(ratios); + + zoneColumns.add(ratios); } - + BufferedWriter bw = IOUtils.getBufferedWriter(fileName); try { bw.write(head); @@ -195,27 +195,27 @@ else if(slotTimes[i] < tuple.getTime()){ bw.write(capacityLine); bw.newLine(); bw.write(subheader); - + DecimalFormat df = new DecimalFormat("##.##"); - + for(int z = 0; z < numberOfSlots; z++){ bw.newLine(); - + String line = "" + slotNumbers[z] + ";" + df.format(slotTimes[z]) + ";"; for(int p = 0; p < this.zoneManager.getZones().size(); p++){ line += "" + df.format(zoneColumns.get(p)[z]) + ";"; } - + bw.write(line); } - + bw.flush(); bw.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } - + log.error("FINISHED WRITING OCCUPANCY STATS"); } diff --git a/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingsearch/manager/WalkLegFactory.java b/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingsearch/manager/WalkLegFactory.java index 0fef2946523..4498dc80fa5 100644 --- a/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingsearch/manager/WalkLegFactory.java +++ b/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingsearch/manager/WalkLegFactory.java @@ -43,8 +43,8 @@ public class WalkLegFactory { @Inject public WalkLegFactory(Network network, Config config) { this.network = network; - this.beelinedistancefactor = config.plansCalcRoute().getBeelineDistanceFactors().get("walk"); - this.walkspeed = config.plansCalcRoute().getTeleportedModeSpeeds().get("walk"); + this.beelinedistancefactor = config.routing().getBeelineDistanceFactors().get("walk"); + this.walkspeed = config.routing().getTeleportedModeSpeeds().get("walk"); } diff --git a/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingsearch/manager/vehicleteleportationlogic/VehicleTeleportationToNearbyParking.java b/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingsearch/manager/vehicleteleportationlogic/VehicleTeleportationToNearbyParking.java index 7b6eab754c9..c0a22d93ade 100644 --- a/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingsearch/manager/vehicleteleportationlogic/VehicleTeleportationToNearbyParking.java +++ b/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingsearch/manager/vehicleteleportationlogic/VehicleTeleportationToNearbyParking.java @@ -34,23 +34,23 @@ /** * teleports vehicle to a location near the agent, if vehicle is more than a certain threshold in metres away * @author jbischoff - * + * */ public class VehicleTeleportationToNearbyParking implements VehicleTeleportationLogic { - + private double maximumWalkDistance = 2000; //TODO: Make this configurable - + private double beelineDistanceFactor; @Inject ParkingSearchManager manager; - - ParkingSearchLogic parkingLogic; + + ParkingSearchLogic parkingLogic; Network network; - + @Inject public VehicleTeleportationToNearbyParking(Config config, Network network) { - this.beelineDistanceFactor = config.plansCalcRoute().getModeRoutingParams().get(TransportMode.walk).getBeelineDistanceFactor(); + this.beelineDistanceFactor = config.routing().getModeRoutingParams().get(TransportMode.walk).getBeelineDistanceFactor(); this.parkingLogic = new RandomParkingSearchLogic(network); this.network = network; } @@ -60,7 +60,7 @@ public Id getVehicleLocation(Id agentLinkId, Id vehicleId, double walkDistance = CoordUtils.calcEuclideanDistance(network.getLinks().get(vehicleLinkId).getCoord(), network.getLinks().get(agentLinkId).getCoord()) * this.beelineDistanceFactor; if (walkDistance<=this.maximumWalkDistance){ return vehicleLinkId; - } + } Id parkingLinkId = agentLinkId; while (!this.manager.reserveSpaceIfVehicleCanParkHere(vehicleId, parkingLinkId)){ parkingLinkId = parkingLogic.getNextLink(parkingLinkId, vehicleId, mode); @@ -68,5 +68,5 @@ public Id getVehicleLocation(Id agentLinkId, Id vehicleId, manager.parkVehicleHere(vehicleId, parkingLinkId, time); return parkingLinkId; } - + } diff --git a/contribs/parking/src/test/java/org/matsim/contrib/parking/run/RunParkingChoiceExampleIT.java b/contribs/parking/src/test/java/org/matsim/contrib/parking/run/RunParkingChoiceExampleIT.java index 6ea09f92030..57792fb205d 100644 --- a/contribs/parking/src/test/java/org/matsim/contrib/parking/run/RunParkingChoiceExampleIT.java +++ b/contribs/parking/src/test/java/org/matsim/contrib/parking/run/RunParkingChoiceExampleIT.java @@ -31,17 +31,17 @@ */ public class RunParkingChoiceExampleIT { @Rule public MatsimTestUtils utils = new MatsimTestUtils() ; - + /** * Test method for {@link org.matsim.contrib.parking.parkingchoice.run.RunParkingChoiceExample#run(org.matsim.core.config.Config)}. */ @Test public final void testRun() { Config config = ConfigUtils.loadConfig("./src/main/resources/parkingchoice/config.xml"); - config.controler().setOutputDirectory( utils.getOutputDirectory() ); - config.controler().setLastIteration(0); + config.controller().setOutputDirectory( utils.getOutputDirectory() ); + config.controller().setLastIteration(0); RunParkingChoiceExample.run(config); - + } } diff --git a/contribs/parking/src/test/java/org/matsim/contrib/parking/run/RunParkingSearchScenarioIT.java b/contribs/parking/src/test/java/org/matsim/contrib/parking/run/RunParkingSearchScenarioIT.java index f4f357e61bc..eef6af3f609 100644 --- a/contribs/parking/src/test/java/org/matsim/contrib/parking/run/RunParkingSearchScenarioIT.java +++ b/contribs/parking/src/test/java/org/matsim/contrib/parking/run/RunParkingSearchScenarioIT.java @@ -18,7 +18,7 @@ * *********************************************************************** */ /** - * + * */ package org.matsim.contrib.parking.run; @@ -42,13 +42,13 @@ public class RunParkingSearchScenarioIT { public void testRunParking() { String configFile = "./src/main/resources/parkingsearch/config.xml"; Config config = ConfigUtils.loadConfig(configFile, new ParkingSearchConfigGroup()); - config.controler().setLastIteration(0); - config.controler().setOutputDirectory( utils.getOutputDirectory() ); + config.controller().setLastIteration(0); + config.controller().setOutputDirectory( utils.getOutputDirectory() ); ParkingSearchConfigGroup configGroup = (ParkingSearchConfigGroup) config.getModules().get(ParkingSearchConfigGroup.GROUP_NAME); configGroup.setParkingSearchStrategy(ParkingSearchStrategy.Benenson); - + new RunParkingSearchExample().run(config,false); - + } } diff --git a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/ChoiceGenerationControler.java b/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/ChoiceGenerationControler.java index 00fc950cbcc..a2e0fe0c253 100644 --- a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/ChoiceGenerationControler.java +++ b/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/ChoiceGenerationControler.java @@ -43,9 +43,9 @@ public class ChoiceGenerationControler implements BeforeMobsimListener{ Scenario scenario; public ChoiceGenerationControler(String[] args) { config = ConfigUtils.loadConfig(args[0]); - config.parallelEventHandling().setSynchronizeOnSimSteps(false); - config.parallelEventHandling().setNumberOfThreads(1); - config.planCalcScore().setWriteExperiencedPlans(true); + config.eventsManager().setSynchronizeOnSimSteps(false); + config.eventsManager().setNumberOfThreads(1); + config.scoring().setWriteExperiencedPlans(true); scenario = ScenarioUtils.loadScenario(config); controler = new Controler(scenario); diff --git a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/MobSimSwitcher.java b/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/MobSimSwitcher.java index f5a902e178e..71cdaf37a41 100644 --- a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/MobSimSwitcher.java +++ b/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/MobSimSwitcher.java @@ -3,12 +3,10 @@ import com.google.inject.Inject; 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.Scenario; import org.matsim.api.core.v01.population.Person; import org.matsim.api.core.v01.population.Plan; -import org.matsim.contrib.pseudosimulation.mobsim.PSimProvider; import org.matsim.contrib.pseudosimulation.replanning.PlanCatcher; import org.matsim.core.controler.events.BeforeMobsimEvent; import org.matsim.core.controler.events.IterationEndsEvent; @@ -70,7 +68,7 @@ public void notifyIterationStarts(IterationStartsEvent event) { private boolean determineIfQSimIter(int iteration) { - if (iteration == scenario.getConfig().controler().getLastIteration() || iteration == scenario.getConfig().controler().getFirstIteration() ) { + if (iteration == scenario.getConfig().controller().getLastIteration() || iteration == scenario.getConfig().controller().getFirstIteration() ) { isQSimIteration = true; return isQSimIteration; } diff --git a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/RunPSim.java b/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/RunPSim.java index 3df6ab05ecf..17525dbfa5e 100644 --- a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/RunPSim.java +++ b/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/RunPSim.java @@ -61,8 +61,8 @@ public RunPSim(Config config, PSimConfigGroup pSimConfigGroup) { //The following line will make the controler use the events manager that doesn't check for event order. //This is essential for pseudo-simulation as the PSim module generates events on a person-basis, //not a system basis - config.parallelEventHandling().setSynchronizeOnSimSteps(false); - config.parallelEventHandling().setNumberOfThreads(1); + config.eventsManager().setSynchronizeOnSimSteps(false); + config.eventsManager().setNumberOfThreads(1); this.matsimControler = new Controler(scenario); @@ -104,7 +104,7 @@ public void install() { public static void main(String args[]) { Config config = ConfigUtils.loadConfig(args[0]); - config.controler().setCreateGraphs(false); + config.controller().setCreateGraphs(false); PSimConfigGroup pSimConfigGroup = new PSimConfigGroup(); config.addModule(pSimConfigGroup); diff --git a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/distributed/MasterControler.java b/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/distributed/MasterControler.java index 7883813d134..209bb2e5fd9 100644 --- a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/distributed/MasterControler.java +++ b/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/distributed/MasterControler.java @@ -204,7 +204,7 @@ public void install() { - matsimControler.getConfig().controler().setOverwriteFileSetting( + matsimControler.getConfig().controller().setOverwriteFileSetting( OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles); // true ? // OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles : @@ -223,14 +223,14 @@ public void install() { * @param borrowingRate */ private void setReplanningWeights(Config config, double masterMutationRate, double borrowingRate) { - int disableAfterIteration = config.controler().getLastIteration(); + int disableAfterIteration = config.controller().getLastIteration(); int maximumIterationForMutationDisabling = -1; if (borrowingRate + masterMutationRate >= 1) { borrowingRate = 0.9999 * borrowingRate / (masterMutationRate + borrowingRate); masterMutationRate = 0.9999 * masterMutationRate / (masterMutationRate + borrowingRate); } List strategySettings = new ArrayList<>(); - strategySettings.addAll(config.strategy().getStrategySettings()); + strategySettings.addAll(config.replanning().getStrategySettings()); Map selectors = new HashMap<>(); Map mutators = new HashMap<>(); for (int i = 0; i < strategySettings.size(); i++) { @@ -253,16 +253,16 @@ private void setReplanningWeights(Config config, double masterMutationRate, doub strategySettings.get(entry.getKey()).setWeight(masterMutationRate * entry.getValue() / mutatorSum); } //put it back in the config - config.strategy().clearStrategySettings(); + config.replanning().clearStrategySettings(); for (ReplanningConfigGroup.StrategySettings strategySetting : strategySettings) { - config.strategy().addStrategySettings(strategySetting); + config.replanning().addStrategySettings(strategySetting); } // add the borrowing rate entry ReplanningConfigGroup.StrategySettings borrowingSetting = new ReplanningConfigGroup.StrategySettings(); borrowingSetting.setWeight(borrowingRate); borrowingSetting.setStrategyName("ReplacePlanFromSlave"); borrowingSetting.setDisableAfter(maximumIterationForMutationDisabling > 0 ? maximumIterationForMutationDisabling : disableAfterIteration); - config.strategy().addStrategySettings(borrowingSetting); + config.replanning().addStrategySettings(borrowingSetting); this.innovationEndsAtIter = maximumIterationForMutationDisabling > 0 ? maximumIterationForMutationDisabling : disableAfterIteration; } @@ -394,7 +394,7 @@ public void notifyAfterMobsim(AfterMobsimEvent event) { startSlaveHandlersInMode(CommunicationsMode.TRANSMIT_SCORES); waitForSlaveThreads(); } - boolean isLoadBalanceIteration = event.getIteration() > config.controler().getFirstIteration() && + boolean isLoadBalanceIteration = event.getIteration() > config.controller().getFirstIteration() && (event.getIteration() % loadBalanceInterval == 0 || slavesHaveRequestedShutdown() || hydra.hydraSlaves.size() > 0); @@ -969,7 +969,7 @@ private void initializeSlave(SlaveHandler slaveHandler, int i, boolean initialRo slaveHandler.sendNumber(slaveIterationsPerMasterIteration); slaveHandler.sendNumber(slaveNumberOfPlans); slaveHandler.sendDouble(slaveMutationRate); - slaveHandler.sendNumber(config.controler().getLastIteration() * slaveIterationsPerMasterIteration); + slaveHandler.sendNumber(config.controller().getLastIteration() * slaveIterationsPerMasterIteration); slaveHandler.sendBoolean(initialRoutingOnSlaves); slaveHandler.sendBoolean(QuickReplanning); slaveHandler.sendBoolean(fullTransitPerformanceTransmission); diff --git a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/distributed/SlaveControler.java b/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/distributed/SlaveControler.java index 02a8fd67231..cd8595a9208 100644 --- a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/distributed/SlaveControler.java +++ b/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/distributed/SlaveControler.java @@ -151,7 +151,7 @@ public SlaveControler(String[] args) throws IOException, ClassNotFoundException, final DistributedSimConfigGroup distributedSimConfigGroup = ConfigUtils.addOrGetModule(this.config,DistributedSimConfigGroup.GROUP_NAME,DistributedSimConfigGroup.class); //The following line will make the controler use the events manager that doesn't check for event order - config.parallelEventHandling().setSynchronizeOnSimSteps(false); + config.eventsManager().setSynchronizeOnSimSteps(false); //if you don't set the number of threads, org.matsim.core.events.EventsUtils will just use the simstepmanager int numThreads = config.global().getNumberOfThreads(); if (commandLine.hasOption("t")) @@ -166,7 +166,7 @@ public SlaveControler(String[] args) throws IOException, ClassNotFoundException, System.err.println("Will use the number of threads in config for simulation."); } config.global().setNumberOfThreads(numThreads); - config.parallelEventHandling().setNumberOfThreads(1); + config.eventsManager().setNumberOfThreads(1); String hostname = "localhost"; if (commandLine.hasOption("h")) { @@ -208,7 +208,7 @@ public SlaveControler(String[] args) throws IOException, ClassNotFoundException, numberOfPlansOnSlave = reader.readInt(); slaveMutationRate = reader.readDouble(); slaveLogger.warn("Running " + numberOfPSimIterationsPerCycle + " PSim iterations for every QSim iter"); - config.controler().setLastIteration(reader.readInt()); + config.controller().setLastIteration(reader.readInt()); initialRouting = reader.readBoolean(); boolean quickReplannning = reader.readBoolean(); fullTransitPerformanceTransmission = reader.readBoolean(); @@ -224,18 +224,18 @@ public SlaveControler(String[] args) throws IOException, ClassNotFoundException, writer.flush(); - config.controler().setOutputDirectory(config.controler().getOutputDirectory() + "_" + myNumber); + config.controller().setOutputDirectory(config.controller().getOutputDirectory() + "_" + myNumber); //limit IO config.linkStats().setWriteLinkStatsInterval(0); - config.controler().setCreateGraphs(false); - config.controler().setWriteEventsInterval(0); - config.controler().setWritePlansInterval(0); - config.controler().setWriteSnapshotsInterval(0); + config.controller().setCreateGraphs(false); + config.controller().setWriteEventsInterval(0); + config.controller().setWritePlansInterval(0); + config.controller().setWriteSnapshotsInterval(0); // don't load plans; receive them from master config.plans().setInputFile(null); // Important, otherwise Psim breaks - config.parallelEventHandling().setSynchronizeOnSimSteps(false); - config.parallelEventHandling().setNumberOfThreads(1); + config.eventsManager().setSynchronizeOnSimSteps(false); + config.eventsManager().setNumberOfThreads(1); if (slaveMutationRate > 0) setReplanningWeights(config, slaveMutationRate); @@ -249,7 +249,7 @@ public SlaveControler(String[] args) throws IOException, ClassNotFoundException, DistributedPlanStrategyTranslationAndRegistration.substituteStrategies(config, quickReplannning, numberOfPSimIterationsPerCycle); matsimControler = new Controler(scenario); DistributedPlanStrategyTranslationAndRegistration.registerStrategiesWithControler(this.matsimControler, plancatcher, quickReplannning, numberOfPSimIterationsPerCycle); - matsimControler.getConfig().controler().setOverwriteFileSetting( + matsimControler.getConfig().controller().setOverwriteFileSetting( true ? OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles : OutputDirectoryHierarchy.OverwriteFileSetting.failIfDirectoryExists); @@ -308,7 +308,7 @@ public void install() { @Override public void install() { bind(TravelTime.class).toInstance(travelTime); - if (scenario.getConfig().strategy().getPlanSelectorForRemoval().equals("DiversityGeneratingPlansRemover")) { + if (scenario.getConfig().replanning().getPlanSelectorForRemoval().equals("DiversityGeneratingPlansRemover")) { bindPlanSelectorForRemoval().toProvider(DiversityGeneratingPlansRemover.Builder.class); } } @@ -319,11 +319,11 @@ public void install() { } if (diversityGeneratingPlanSelection) - matsimControler.getConfig().strategy().setPlanSelectorForRemoval("DiversityGeneratingPlansRemover"); + matsimControler.getConfig().replanning().setPlanSelectorForRemoval("DiversityGeneratingPlansRemover"); //no use for this, if you don't exactly know the communicationsMode of population when something goes wrong. // better to have plans written out every n successful iterations, specified in the config - matsimControler.getConfig().controler().setDumpDataAtEnd(false); - matsimControler.getConfig().strategy().setMaxAgentPlanMemorySize(numberOfPlansOnSlave); + matsimControler.getConfig().controller().setDumpDataAtEnd(false); + matsimControler.getConfig().replanning().setMaxAgentPlanMemorySize(numberOfPlansOnSlave); } public static void main(String[] args) throws IOException, ClassNotFoundException, ParseException, InterruptedException { @@ -631,7 +631,7 @@ private void setReplanningWeights(Config config, double mutationRate) { if (mutationRate > 1) mutationRate = 0.9999; List strategySettings = new ArrayList<>(); - strategySettings.addAll(config.strategy().getStrategySettings()); + strategySettings.addAll(config.replanning().getStrategySettings()); Map selectors = new HashMap<>(); Map mutators = new HashMap<>(); for (int i = 0; i < strategySettings.size(); i++) { @@ -653,9 +653,9 @@ private void setReplanningWeights(Config config, double mutationRate) { strategySettings.get(entry.getKey()).setWeight(mutationRate * entry.getValue() / mutatorSum); } //put it back in the config - config.strategy().clearStrategySettings(); + config.replanning().clearStrategySettings(); for (ReplanningConfigGroup.StrategySettings strategySetting : strategySettings) { - config.strategy().addStrategySettings(strategySetting); + config.replanning().addStrategySettings(strategySetting); } } diff --git a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/distributed/instrumentation/scorestats/SlaveScoreStats.java b/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/distributed/instrumentation/scorestats/SlaveScoreStats.java index 06e0283c0c1..bfdcb73bf86 100644 --- a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/distributed/instrumentation/scorestats/SlaveScoreStats.java +++ b/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/distributed/instrumentation/scorestats/SlaveScoreStats.java @@ -19,8 +19,8 @@ public class SlaveScoreStats implements ScoreStats { int firstIter; public SlaveScoreStats(Config config) { - firstIter = config.controler().getFirstIteration(); - int size = config.controler().getLastIteration() - firstIter+1; + firstIter = config.controller().getFirstIteration(); + int size = config.controller().getLastIteration() - firstIter+1; this.history = new double[4][size]; } @@ -41,6 +41,6 @@ public double[][] getScoreHistoryAsArray() { public Map> getScoreHistory() { throw new RuntimeException("not implemented") ; } - - + + } diff --git a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/distributed/listeners/controler/GenomeAnalysis.java b/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/distributed/listeners/controler/GenomeAnalysis.java index 901600f9c03..dfa93a6a0c4 100644 --- a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/distributed/listeners/controler/GenomeAnalysis.java +++ b/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/distributed/listeners/controler/GenomeAnalysis.java @@ -37,7 +37,7 @@ public void notifyIterationEnds(IterationEndsEvent event) { Map fullGeneScore = new HashMap<>(); Map fullGeneAltScore = new HashMap<>(); Map, ? extends Person> persons = event.getServices().getScenario().getPopulation().getPersons(); - boolean append = event.getIteration() != event.getServices().getConfig().controler().getFirstIteration(); + boolean append = event.getIteration() != event.getServices().getConfig().controller().getFirstIteration(); try { PrintWriter writer = null; PrintWriter scoreComponentWriter = null; @@ -234,4 +234,4 @@ public SimpleLink(String genome, int count, double score, double altscore) { this.score = score; this.altscore = altscore; } -} \ No newline at end of file +} diff --git a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/distributed/listeners/controler/SlaveScoreWriter.java b/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/distributed/listeners/controler/SlaveScoreWriter.java index 22bac23252a..a4c11ab6293 100644 --- a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/distributed/listeners/controler/SlaveScoreWriter.java +++ b/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/distributed/listeners/controler/SlaveScoreWriter.java @@ -32,7 +32,7 @@ public SlaveScoreWriter(MasterControler controler) { @Override public void notifyIterationEnds(IterationEndsEvent event) { double[][] history = controler.getSlaveScoreHistory(); - int idx = event.getIteration() - controler.getConfig().controler().getFirstIteration(); + int idx = event.getIteration() - controler.getConfig().controller().getFirstIteration(); try { out.write(event.getIteration() + "\t" + history[INDEX_EXECUTED][idx] + "\t" @@ -52,7 +52,7 @@ public void notifyIterationEnds(IterationEndsEvent event) { "iteration", "score"); double[] iterations = new double[idx]; for (int i = 0; i < idx; i++) { - iterations[i] = i + controler.getConfig().controler().getFirstIteration()+1; + iterations[i] = i + controler.getConfig().controller().getFirstIteration()+1; } double[] values = new double[idx]; double[] fullhist = new double[idx]; diff --git a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/mobsim/SwitchingMobsimProvider.java b/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/mobsim/SwitchingMobsimProvider.java index ef6d34a7f32..61de8d12aae 100644 --- a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/mobsim/SwitchingMobsimProvider.java +++ b/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/mobsim/SwitchingMobsimProvider.java @@ -30,8 +30,6 @@ import org.matsim.core.mobsim.framework.Mobsim; import org.matsim.core.mobsim.jdeqsim.JDEQSimConfigGroup; import org.matsim.core.mobsim.jdeqsim.JDEQSimulation; -import org.matsim.core.mobsim.qsim.QSim; -import org.matsim.core.mobsim.qsim.QSimBuilder; import org.matsim.core.mobsim.qsim.QSimProvider; import org.matsim.core.utils.timing.TimeInterpretation; @@ -52,7 +50,7 @@ public class SwitchingMobsimProvider implements Provider { @Override public Mobsim get() { - String mobsim = config.controler().getMobsim(); + String mobsim = config.controller().getMobsim(); if (mobSimSwitcher.isQSimIteration()) { if (mobsim.equals("jdeqsim")) { return new JDEQSimulation(ConfigUtils.addOrGetModule(scenario.getConfig(), JDEQSimConfigGroup.NAME, JDEQSimConfigGroup.class), scenario, eventsManager, timeInterpretation); diff --git a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/replanning/DistributedPlanStrategyTranslationAndRegistration.java b/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/replanning/DistributedPlanStrategyTranslationAndRegistration.java index 4475c332bca..1baf66c5b01 100644 --- a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/replanning/DistributedPlanStrategyTranslationAndRegistration.java +++ b/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/replanning/DistributedPlanStrategyTranslationAndRegistration.java @@ -115,7 +115,7 @@ public static boolean isStrategySupported(String name) { } public static void substituteStrategies(Config config, boolean quickReplanning, int selectionInflationFactor) { - for (ReplanningConfigGroup.StrategySettings settings : config.strategy().getStrategySettings()) { + for (ReplanningConfigGroup.StrategySettings settings : config.replanning().getStrategySettings()) { String classname = settings.getStrategyName(); diff --git a/contribs/pseudosimulation/src/test/java/org/matsim/contrib/pseudosimulation/RunPSimTest.java b/contribs/pseudosimulation/src/test/java/org/matsim/contrib/pseudosimulation/RunPSimTest.java index 6426412c6eb..a07558bddb9 100644 --- a/contribs/pseudosimulation/src/test/java/org/matsim/contrib/pseudosimulation/RunPSimTest.java +++ b/contribs/pseudosimulation/src/test/java/org/matsim/contrib/pseudosimulation/RunPSimTest.java @@ -47,13 +47,13 @@ public class RunPSimTest { @Test public void testA() { config.transit().setRoutingAlgorithmType(TransitRoutingAlgorithmType.DijkstraBased); - config.controler().setCreateGraphs(false); + config.controller().setCreateGraphs(false); PSimConfigGroup pSimConfigGroup = new PSimConfigGroup(); config.addModule(pSimConfigGroup); pSimConfigGroup.setIterationsPerCycle(20); - config.plansCalcRoute().setRoutingRandomness(0.); + config.routing().setRoutingRandomness(0.); //identify selector strategies Field[] selectors = DefaultPlanStrategiesModule.DefaultSelector.class.getDeclaredFields(); @@ -71,7 +71,7 @@ public void testA() { selectorNames.add( DefaultPlanStrategiesModule.DefaultSelector.SelectExpBeta ); //lower the weight of non-selector strategies, as we will run many iters - for( ReplanningConfigGroup.StrategySettings settings : config.strategy().getStrategySettings() ){ + for( ReplanningConfigGroup.StrategySettings settings : config.replanning().getStrategySettings() ){ if( !selectorNames.contains( settings.getStrategyName() ) ){ logger.warn( settings.getStrategyName() ); settings.setWeight( settings.getWeight() * 20 ); @@ -82,8 +82,8 @@ public void testA() { // System.exit( -1); final String outDir = utils.getOutputDirectory(); - config.controler().setOutputDirectory( outDir ); - config.controler().setLastIteration(20); + config.controller().setOutputDirectory( outDir ); + config.controller().setLastIteration(20); // config.controler().setDumpDataAtEnd(false); // config.strategy().setFractionOfIterationsToDisableInnovation( 0.8 ); // crashes @@ -124,11 +124,11 @@ public void install() { @Test public void testB() { config.transit().setRoutingAlgorithmType(TransitRoutingAlgorithmType.DijkstraBased); - config.controler().setOutputDirectory(utils.getOutputDirectory()); - config.controler().setLastIteration(2); - config.controler().setCreateGraphs(false); - config.controler().setDumpDataAtEnd(false); - config.plansCalcRoute().setRoutingRandomness(0.); + config.controller().setOutputDirectory(utils.getOutputDirectory()); + config.controller().setLastIteration(2); + config.controller().setCreateGraphs(false); + config.controller().setDumpDataAtEnd(false); + config.routing().setRoutingRandomness(0.); Controler controler = new Controler(config); ExecScoreTracker execScoreTracker = new ExecScoreTracker(controler); controler.addControlerListener(execScoreTracker); @@ -150,7 +150,7 @@ class ExecScoreTracker implements ShutdownListener { @Override public void notifyShutdown(ShutdownEvent event) { - executedScore = controler.getScoreStats().getScoreHistory().get(ScoreStatsControlerListener.ScoreItem.executed).get(controler.getConfig().controler().getLastIteration()); + executedScore = controler.getScoreStats().getScoreHistory().get(ScoreStatsControlerListener.ScoreItem.executed).get(controler.getConfig().controller().getLastIteration()); } diff --git a/contribs/railsim/src/main/java/ch/sbb/matsim/contrib/railsim/RunRailsimExample.java b/contribs/railsim/src/main/java/ch/sbb/matsim/contrib/railsim/RunRailsimExample.java index 2724b7889b6..e4f69dbb5b7 100644 --- a/contribs/railsim/src/main/java/ch/sbb/matsim/contrib/railsim/RunRailsimExample.java +++ b/contribs/railsim/src/main/java/ch/sbb/matsim/contrib/railsim/RunRailsimExample.java @@ -44,7 +44,7 @@ public static void main(String[] args) { String configFilename = args[0]; Config config = ConfigUtils.loadConfig(configFilename); - config.controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists); + config.controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists); Scenario scenario = ScenarioUtils.loadScenario(config); Controler controler = new Controler(scenario); diff --git a/contribs/railsim/src/main/java/ch/sbb/matsim/contrib/railsim/analysis/linkstates/RailsimLinkStateControlerListener.java b/contribs/railsim/src/main/java/ch/sbb/matsim/contrib/railsim/analysis/linkstates/RailsimLinkStateControlerListener.java index fe37076bfcd..3c5d71264c3 100644 --- a/contribs/railsim/src/main/java/ch/sbb/matsim/contrib/railsim/analysis/linkstates/RailsimLinkStateControlerListener.java +++ b/contribs/railsim/src/main/java/ch/sbb/matsim/contrib/railsim/analysis/linkstates/RailsimLinkStateControlerListener.java @@ -54,7 +54,7 @@ public void notifyIterationStarts(IterationStartsEvent event) { @Override public void notifyIterationEnds(IterationEndsEvent event) { - String railLinkStatesCsvFilename = this.controlerIO.getIterationFilename(event.getIteration(), "railsimLinkStates.csv", this.scenario.getConfig().controler().getCompressionType()); + String railLinkStatesCsvFilename = this.controlerIO.getIterationFilename(event.getIteration(), "railsimLinkStates.csv", this.scenario.getConfig().controller().getCompressionType()); RailsimCsvWriter.writeLinkStatesCsv(this.analysis.events, railLinkStatesCsvFilename); } diff --git a/contribs/railsim/src/main/java/ch/sbb/matsim/contrib/railsim/analysis/trainstates/RailsimTrainStateControlerListener.java b/contribs/railsim/src/main/java/ch/sbb/matsim/contrib/railsim/analysis/trainstates/RailsimTrainStateControlerListener.java index 49934ca9495..60c39494e28 100644 --- a/contribs/railsim/src/main/java/ch/sbb/matsim/contrib/railsim/analysis/trainstates/RailsimTrainStateControlerListener.java +++ b/contribs/railsim/src/main/java/ch/sbb/matsim/contrib/railsim/analysis/trainstates/RailsimTrainStateControlerListener.java @@ -55,7 +55,7 @@ public void notifyIterationStarts(IterationStartsEvent event) { @Override public void notifyIterationEnds(IterationEndsEvent event) { - String railLinkStatesCsvFilename = this.controlerIO.getIterationFilename(event.getIteration(), "railsimTrainStates.csv", this.scenario.getConfig().controler().getCompressionType()); + String railLinkStatesCsvFilename = this.controlerIO.getIterationFilename(event.getIteration(), "railsimTrainStates.csv", this.scenario.getConfig().controller().getCompressionType()); RailsimCsvWriter.writeTrainStatesCsv(this.analysis.events, this.scenario.getNetwork(), railLinkStatesCsvFilename); } diff --git a/contribs/railsim/src/test/java/ch/sbb/matsim/contrib/railsim/integration/RailsimIntegrationTest.java b/contribs/railsim/src/test/java/ch/sbb/matsim/contrib/railsim/integration/RailsimIntegrationTest.java index 7148d935cb3..f49a5b0901c 100644 --- a/contribs/railsim/src/test/java/ch/sbb/matsim/contrib/railsim/integration/RailsimIntegrationTest.java +++ b/contribs/railsim/src/test/java/ch/sbb/matsim/contrib/railsim/integration/RailsimIntegrationTest.java @@ -340,10 +340,10 @@ public void testScenarioKelheim() { URL base = ExamplesUtils.getTestScenarioURL("kelheim"); Config config = ConfigUtils.loadConfig(IOUtils.extendUrl(base, "config.xml")); - config.controler().setLastIteration(0); - config.controler().setOutputDirectory(utils.getOutputDirectory()); - config.controler().setCreateGraphs(false); - config.controler().setDumpDataAtEnd(false); + config.controller().setLastIteration(0); + config.controller().setOutputDirectory(utils.getOutputDirectory()); + config.controller().setCreateGraphs(false); + config.controller().setDumpDataAtEnd(false); Scenario scenario = ScenarioUtils.loadScenario(config); @@ -384,10 +384,10 @@ private EventsCollector runSimulation(File scenarioDir) { private EventsCollector runSimulation(File scenarioDir, Consumer f) { Config config = ConfigUtils.loadConfig(new File(scenarioDir, "config.xml").toString()); - config.controler().setOutputDirectory(utils.getOutputDirectory()); - config.controler().setDumpDataAtEnd(true); - config.controler().setCreateGraphs(false); - config.controler().setLastIteration(0); + config.controller().setOutputDirectory(utils.getOutputDirectory()); + config.controller().setDumpDataAtEnd(true); + config.controller().setCreateGraphs(false); + config.controller().setLastIteration(0); Scenario scenario = ScenarioUtils.loadScenario(config); diff --git a/contribs/railsim/src/test/java/ch/sbb/matsim/contrib/railsim/integration/SnzActivities.java b/contribs/railsim/src/test/java/ch/sbb/matsim/contrib/railsim/integration/SnzActivities.java index 544d770b4bc..ac3a039f5a5 100644 --- a/contribs/railsim/src/test/java/ch/sbb/matsim/contrib/railsim/integration/SnzActivities.java +++ b/contribs/railsim/src/test/java/ch/sbb/matsim/contrib/railsim/integration/SnzActivities.java @@ -74,18 +74,18 @@ public static void addScoringParams(Config config) { for (SnzActivities value : SnzActivities.values()) { for (long ii = 600; ii <= 97200; ii += 600) { - config.planCalcScore().addActivityParams(value.apply(new ScoringConfigGroup.ActivityParams(value.name() + "_" + ii).setTypicalDuration(ii))); + config.scoring().addActivityParams(value.apply(new ScoringConfigGroup.ActivityParams(value.name() + "_" + ii).setTypicalDuration(ii))); } } - config.planCalcScore().addActivityParams(new ScoringConfigGroup.ActivityParams("car interaction").setTypicalDuration(60)); - config.planCalcScore().addActivityParams(new ScoringConfigGroup.ActivityParams("ride interaction").setTypicalDuration(60)); - config.planCalcScore().addActivityParams(new ScoringConfigGroup.ActivityParams("bike interaction").setTypicalDuration(60)); + config.scoring().addActivityParams(new ScoringConfigGroup.ActivityParams("car interaction").setTypicalDuration(60)); + config.scoring().addActivityParams(new ScoringConfigGroup.ActivityParams("ride interaction").setTypicalDuration(60)); + config.scoring().addActivityParams(new ScoringConfigGroup.ActivityParams("bike interaction").setTypicalDuration(60)); - config.planCalcScore().addActivityParams(new ScoringConfigGroup.ActivityParams("other").setTypicalDuration(600 * 3)); + config.scoring().addActivityParams(new ScoringConfigGroup.ActivityParams("other").setTypicalDuration(600 * 3)); - config.planCalcScore().addActivityParams(new ScoringConfigGroup.ActivityParams("freight_start").setTypicalDuration(60 * 15)); - config.planCalcScore().addActivityParams(new ScoringConfigGroup.ActivityParams("freight_end").setTypicalDuration(60 * 15)); + config.scoring().addActivityParams(new ScoringConfigGroup.ActivityParams("freight_start").setTypicalDuration(60 * 15)); + config.scoring().addActivityParams(new ScoringConfigGroup.ActivityParams("freight_end").setTypicalDuration(60 * 15)); } } diff --git a/contribs/roadpricing/src/main/java/org/matsim/contrib/roadpricing/RoadPricingModuleDefaults.java b/contribs/roadpricing/src/main/java/org/matsim/contrib/roadpricing/RoadPricingModuleDefaults.java index 296165c88be..ef3f8c3a02a 100644 --- a/contribs/roadpricing/src/main/java/org/matsim/contrib/roadpricing/RoadPricingModuleDefaults.java +++ b/contribs/roadpricing/src/main/java/org/matsim/contrib/roadpricing/RoadPricingModuleDefaults.java @@ -126,7 +126,7 @@ public TravelDisutilityFactory get() { final Config config = scenario.getConfig(); final TravelDisutilityFactory originalTravelDisutilityFactory = ControlerDefaults.createDefaultTravelDisutilityFactory(scenario); RoadPricingTravelDisutilityFactory travelDisutilityFactory = new RoadPricingTravelDisutilityFactory( originalTravelDisutilityFactory, scheme, config ); - travelDisutilityFactory.setSigma(config.plansCalcRoute().getRoutingRandomness()); + travelDisutilityFactory.setSigma(config.routing().getRoutingRandomness()); return travelDisutilityFactory; } diff --git a/contribs/roadpricing/src/main/java/org/matsim/contrib/roadpricing/RoadPricingTravelDisutilityFactory.java b/contribs/roadpricing/src/main/java/org/matsim/contrib/roadpricing/RoadPricingTravelDisutilityFactory.java index 06217074a2a..a3a85307170 100644 --- a/contribs/roadpricing/src/main/java/org/matsim/contrib/roadpricing/RoadPricingTravelDisutilityFactory.java +++ b/contribs/roadpricing/src/main/java/org/matsim/contrib/roadpricing/RoadPricingTravelDisutilityFactory.java @@ -50,7 +50,7 @@ public RoadPricingTravelDisutilityFactory(TravelDisutilityFactory previousTravel } public RoadPricingTravelDisutilityFactory(TravelDisutilityFactory previousTravelDisutilityFactory, RoadPricingScheme scheme, Config config) { - this( previousTravelDisutilityFactory, scheme, config.planCalcScore().getMarginalUtilityOfMoney() ) ; + this( previousTravelDisutilityFactory, scheme, config.scoring().getMarginalUtilityOfMoney() ) ; } @Override diff --git a/contribs/roadpricing/src/main/java/org/matsim/contrib/roadpricing/TravelDisutilityIncludingToll.java b/contribs/roadpricing/src/main/java/org/matsim/contrib/roadpricing/TravelDisutilityIncludingToll.java index 2654a3d75b3..22106c5ee41 100644 --- a/contribs/roadpricing/src/main/java/org/matsim/contrib/roadpricing/TravelDisutilityIncludingToll.java +++ b/contribs/roadpricing/src/main/java/org/matsim/contrib/roadpricing/TravelDisutilityIncludingToll.java @@ -30,7 +30,7 @@ import org.matsim.vehicles.Vehicle; /** - * Calculates the travel disutility for links, including tolls. Currently + * Calculates the travel disutility for links, including tolls. Currently * supports distance, cordon and area tolls. * * @author mrieser @@ -50,7 +50,7 @@ class TravelDisutilityIncludingToll implements TravelDisutility { TravelDisutilityIncludingToll(final TravelDisutility normalTravelDisutility, final RoadPricingScheme scheme, Config config) { - this( normalTravelDisutility, scheme, config.planCalcScore().getMarginalUtilityOfMoney(), 0. ) ; + this( normalTravelDisutility, scheme, config.scoring().getMarginalUtilityOfMoney(), 0. ) ; // this is using sigma=0 for backwards compatibility (not sure how often this is needed) } @@ -82,7 +82,7 @@ class TravelDisutilityIncludingToll implements TravelDisutility { } @Override - public double getLinkTravelDisutility(final Link link, final double time, final Person person, final Vehicle vehicle) + public double getLinkTravelDisutility(final Link link, final double time, final Person person, final Vehicle vehicle) { double normalTravelDisutilityForLink = this.normalTravelDisutility.getLinkTravelDisutility(link, time, person, vehicle); @@ -94,7 +94,7 @@ public double getLinkTravelDisutility(final Link link, final double time, final // end randomize double tollCost = this.tollCostHandler.getTypicalTollCost(link, time ); - + return normalTravelDisutilityForLink + tollCost*this.marginalUtilityOfMoney*logNormalRnd ; // sign convention: these are all costs (= disutilities), so they are all normally positive. tollCost is positive, marginalUtilityOfMoney as well. } diff --git a/contribs/roadpricing/src/main/java/org/matsim/contrib/roadpricing/run/RunRoadPricingFromCode.java b/contribs/roadpricing/src/main/java/org/matsim/contrib/roadpricing/run/RunRoadPricingFromCode.java index c2e185ee8ca..0c317cb4ff2 100644 --- a/contribs/roadpricing/src/main/java/org/matsim/contrib/roadpricing/run/RunRoadPricingFromCode.java +++ b/contribs/roadpricing/src/main/java/org/matsim/contrib/roadpricing/run/RunRoadPricingFromCode.java @@ -43,8 +43,8 @@ private static void run(String[] args){ parameteres specified) and just remove the road pricing file. */ Config config = ConfigUtils.loadConfig(args[0], RoadPricingUtils.createConfigGroup()); ConfigUtils.addOrGetModule(config, RoadPricingConfigGroup.class).setTollLinksFile(null); - config.controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists); - config.controler().setLastIteration(10); + config.controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists); + config.controller().setLastIteration(10); // prepare scenario: @@ -71,8 +71,8 @@ private static void runFromFile(String[] args){ /* Start with a known config file (with population, network, and scoring parameteres specified) and just remove the road pricing file. */ Config config = ConfigUtils.loadConfig(args[0], RoadPricingUtils.createConfigGroup()); - config.controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists); - config.controler().setLastIteration(10); + config.controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists); + config.controller().setLastIteration(10); // prepare scenario: diff --git a/contribs/roadpricing/src/main/java/org/matsim/contrib/roadpricing/run/RunRoadPricingUsingTollFactorExample.java b/contribs/roadpricing/src/main/java/org/matsim/contrib/roadpricing/run/RunRoadPricingUsingTollFactorExample.java index ecdecf2c373..4f53fa930ea 100644 --- a/contribs/roadpricing/src/main/java/org/matsim/contrib/roadpricing/run/RunRoadPricingUsingTollFactorExample.java +++ b/contribs/roadpricing/src/main/java/org/matsim/contrib/roadpricing/run/RunRoadPricingUsingTollFactorExample.java @@ -49,7 +49,7 @@ public static void main(String[] args) { } else { config = ConfigUtils.loadConfig(TEST_CONFIG, RoadPricingUtils.createConfigGroup()); } - config.controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists); + config.controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists); // "materialize" the road pricing config group: RoadPricingConfigGroup rpConfig = ConfigUtils.addOrGetModule(config, RoadPricingConfigGroup.class); diff --git a/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/AvoidTolledRouteTest.java b/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/AvoidTolledRouteTest.java index 265164b14b5..2f79155d1e4 100644 --- a/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/AvoidTolledRouteTest.java +++ b/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/AvoidTolledRouteTest.java @@ -18,7 +18,7 @@ * *********************************************************************** */ /** - * + * */ package org.matsim.contrib.roadpricing; @@ -40,17 +40,17 @@ import org.matsim.testcases.MatsimTestUtils; /** - * + * * Tests the integration of the roadpricing-package into the Controler. - * + * * Compares a base case (no pricing) against a policy case (link-based pricing) * and tests if all agents adjust their routes in order to avoid the toll payments. - * + * * @author ikaddoura * */ public class AvoidTolledRouteTest { - + @Rule public MatsimTestUtils testUtils = new MatsimTestUtils(); @@ -58,68 +58,68 @@ public class AvoidTolledRouteTest { public final void test1(){ String configFile = testUtils.getClassInputDirectory() + "/config.xml"; - + // baseCase Config config1 = ConfigUtils.loadConfig( configFile, RoadPricingUtils.createConfigGroup()); - config1.controler().setOutputDirectory(testUtils.getOutputDirectory() + "bc"); - + config1.controller().setOutputDirectory(testUtils.getOutputDirectory() + "bc"); + Scenario scenario1 = ScenarioUtils.loadScenario(config1); Controler controler1 = new Controler(scenario1); - + final Map,Integer> linkId2demand1 = new HashMap<>(); controler1.getEvents().addHandler(new LinkLeaveEventHandler() { - + @Override public void reset(int iteration) { linkId2demand1.clear(); } - + @Override public void handleEvent(LinkLeaveEvent event) { if (linkId2demand1.containsKey(event.getLinkId())) { int agents = linkId2demand1.get(event.getLinkId()); linkId2demand1.put(event.getLinkId(), agents + 1); - + } else { linkId2demand1.put(event.getLinkId(), 1); - } + } } }); - - controler1.getConfig().controler().setCreateGraphs(false); + + controler1.getConfig().controller().setCreateGraphs(false); controler1.run(); - + // link-based toll Config config2 = ConfigUtils.loadConfig( configFile, RoadPricingUtils.createConfigGroup()); - config2.controler().setOutputDirectory(testUtils.getOutputDirectory() + "cordon"); - + config2.controller().setOutputDirectory(testUtils.getOutputDirectory() + "cordon"); + Scenario scenario2 = ScenarioUtils.loadScenario(config2); Controler controler2 = new Controler(scenario2); controler2.addOverridingModule(new RoadPricingModule()); - + final Map,Integer> linkId2demand2 = new HashMap, Integer>(); controler2.getEvents().addHandler(new LinkLeaveEventHandler() { - + @Override public void reset(int iteration) { linkId2demand2.clear(); } - + @Override public void handleEvent(LinkLeaveEvent event) { if (linkId2demand2.containsKey(event.getLinkId())) { int agents = linkId2demand2.get(event.getLinkId()); linkId2demand2.put(event.getLinkId(), agents + 1); - + } else { linkId2demand2.put(event.getLinkId(), 1); - } + } } }); - - controler2.getConfig().controler().setCreateGraphs(false); + + controler2.getConfig().controller().setCreateGraphs(false); controler2.run(); - + Assert.assertEquals("Base Case: all agents should use the faster route.", 3, (Integer) linkId2demand1.get(Id.createLinkId("link_4_5")), 0); Assert.assertEquals("Pricing: all agents should use the slow but untolled route.", 3, linkId2demand2.get(Id.createLinkId("link_1_2")), 0); diff --git a/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/ModuleTest.java b/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/ModuleTest.java index 9d6d2066644..118dac01eb9 100644 --- a/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/ModuleTest.java +++ b/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/ModuleTest.java @@ -67,14 +67,14 @@ public void testControlerWithRoadPricingByScenarioWorks() { @Test public void testControlerWithRoadPricingByScenarioWorksTwice() { Config config = utils.loadConfig(utils.getClassInputDirectory() + "/config.xml"); - config.controler().setOutputDirectory(utils.getOutputDirectory()+"/1"); + config.controller().setOutputDirectory(utils.getOutputDirectory()+"/1"); Scenario scenario = ScenarioUtils.loadScenario(config); Controler controler1 = new Controler(scenario); // controler1.setModules(new RoadPricingModuleDefaults()); controler1.addOverridingModule( new RoadPricingModule() ); controler1.run(); - config.controler().setOutputDirectory(utils.getOutputDirectory()+"/2"); + config.controller().setOutputDirectory(utils.getOutputDirectory()+"/2"); Controler controler2 = new Controler(scenario); controler2.addOverridingModule( new RoadPricingModule() ); // controler2.setModules(new RoadPricingModuleDefaults()); diff --git a/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/PlansCalcRouteWithTollOrNotTest.java b/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/PlansCalcRouteWithTollOrNotTest.java index d4ffb4f91fc..df6e547c898 100644 --- a/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/PlansCalcRouteWithTollOrNotTest.java +++ b/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/PlansCalcRouteWithTollOrNotTest.java @@ -74,11 +74,11 @@ public class PlansCalcRouteWithTollOrNotTest { @Test public void testBestAlternatives() { Config config = matsimTestUtils.createConfig(); - config.controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles); + config.controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles); MutableScenario scenario = (MutableScenario) ScenarioUtils.createScenario(config); RoadPricingTestUtils.createNetwork2(scenario); - log.warn( "access/egress?" + config.plansCalcRoute().getAccessEgressType() ); + log.warn( "access/egress?" + config.routing().getAccessEgressType() ); // a basic toll where only the morning hours are tolled RoadPricingSchemeImpl toll = RoadPricingUtils.addOrGetMutableRoadPricingScheme(scenario ); @@ -97,17 +97,17 @@ public void testBestAlternatives() { Id id1 = Id.createPersonId("1"); // case 1: toll only in morning, it is cheaper to drive around - log.warn( "access/egress?" + config.plansCalcRoute().getAccessEgressType() ); + log.warn( "access/egress?" + config.routing().getAccessEgressType() ); runOnAll(testee(scenario, toll), population); - log.warn( "access/egress?" + config.plansCalcRoute().getAccessEgressType() ); + log.warn( "access/egress?" + config.routing().getAccessEgressType() ); RoadPricingTestUtils.compareRoutes("2 3 4 6", (NetworkRoute) getLeg1(config, population, id1).getRoute()); RoadPricingTestUtils.compareRoutes("8 11 12", (NetworkRoute) getLeg3(config, population, id1).getRoute()); // case 2: now add a toll in the afternoon too, so it is cheaper to pay the toll Cost afternoonCost = toll.createAndAddCost(14*3600, 18*3600, 0.12); - log.warn( "access/egress? " + config.plansCalcRoute().getAccessEgressType() ); + log.warn( "access/egress? " + config.routing().getAccessEgressType() ); runOnAll(testee(scenario, toll), population); - log.warn( "access/egress? " + config.plansCalcRoute().getAccessEgressType() ); + log.warn( "access/egress? " + config.routing().getAccessEgressType() ); RoadPricingTestUtils.compareRoutes("2 5 6", (NetworkRoute) getLeg1(config, population, id1).getRoute()); RoadPricingTestUtils.compareRoutes("8 11 12", (NetworkRoute) getLeg3(config, population, id1).getRoute()); @@ -140,7 +140,7 @@ private static Leg getLeg1(Config config, Population population, Id id1) for ( PlanElement pe : planElements ) { log.warn( pe ); } - if ( config.plansCalcRoute().getAccessEgressType().equals(AccessEgressType.none) ) { + if ( config.routing().getAccessEgressType().equals(AccessEgressType.none) ) { return (Leg) (planElements.get(1)); } else { return (Leg) (planElements.get(3)); @@ -229,7 +229,7 @@ public void testAllAlternativesTolled() { private static Leg getLeg3(Config config, Population population, Id id1) { List planElements = population.getPersons().get(id1).getPlans().get(0).getPlanElements() ; - if ( config.plansCalcRoute().getAccessEgressType().equals(AccessEgressType.none) ) { + if ( config.routing().getAccessEgressType().equals(AccessEgressType.none) ) { return (Leg) (planElements.get(3)); } else { List trips = TripStructureUtils.getTrips(planElements) ; diff --git a/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/RoadPricingControlerIT.java b/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/RoadPricingControlerIT.java index a3bb95296bd..e45608b4fbd 100644 --- a/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/RoadPricingControlerIT.java +++ b/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/RoadPricingControlerIT.java @@ -38,42 +38,42 @@ * @author mrieser */ public class RoadPricingControlerIT { - + @Rule public MatsimTestUtils utils = new MatsimTestUtils(); - + @Test public void testPaidTollsEndUpInScores() { // first run basecase Config config = utils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("equil-extended"), "config.xml")); - config.controler().setLastIteration(0); + config.controller().setLastIteration(0); config.plans().setInputFile("plans1.xml"); - config.controler().setOutputDirectory(utils.getOutputDirectory() + "/basecase/"); - config.controler().setWritePlansInterval(0); + config.controller().setOutputDirectory(utils.getOutputDirectory() + "/basecase/"); + config.controller().setWritePlansInterval(0); Controler controler1 = new Controler(config); - controler1.getConfig().controler().setCreateGraphs(false); - controler1.getConfig().controler().setDumpDataAtEnd(false); - controler1.getConfig().controler().setWriteEventsInterval(0); + controler1.getConfig().controller().setCreateGraphs(false); + controler1.getConfig().controller().setDumpDataAtEnd(false); + controler1.getConfig().controller().setWriteEventsInterval(0); controler1.run(); double scoreBasecase = controler1.getScenario().getPopulation().getPersons().get(Id.create("1", Person.class)).getPlans().get(0).getScore(); - + // now run toll case // ConfigUtils.addOrGetModule(config, RoadPricingConfigGroup.GROUP_NAME, RoadPricingConfigGroup.class).setUseRoadpricing(true); // ConfigUtils.addOrGetModule(config, RoadPricingConfigGroup.GROUP_NAME, RoadPricingConfigGroup.class).setTollLinksFile(IOUtils.newUrl(utils.inputResourcePath(), "distanceToll.xml").toString()); ConfigUtils.addOrGetModule(config, RoadPricingConfigGroup.GROUP_NAME, RoadPricingConfigGroup.class).setTollLinksFile( "distanceToll.xml" ) ; - config.controler().setOutputDirectory(utils.getOutputDirectory() + "/tollcase/"); + config.controller().setOutputDirectory(utils.getOutputDirectory() + "/tollcase/"); Controler controler2 = new Controler(config); /* FIXME Check if the following is correct, jwj '19. What's the difference? */ // controler2.setModules(new RoadPricingModuleDefaults()); controler2.addOverridingModule( new RoadPricingModule() ); - controler2.getConfig().controler().setCreateGraphs(false); - controler2.getConfig().controler().setDumpDataAtEnd(false); - controler2.getConfig().controler().setWriteEventsInterval(0); + controler2.getConfig().controller().setCreateGraphs(false); + controler2.getConfig().controller().setDumpDataAtEnd(false); + controler2.getConfig().controller().setWriteEventsInterval(0); controler2.run(); double scoreTollcase = controler2.getScenario().getPopulation().getPersons().get(Id.create("1", Person.class)).getPlans().get(0).getScore(); - + // there should be a score difference Assert.assertEquals(3.0, scoreBasecase - scoreTollcase, MatsimTestUtils.EPSILON); // toll amount: 10000*0.00020 + 5000*0.00020 } - + } diff --git a/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/TollTravelCostCalculatorTest.java b/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/TollTravelCostCalculatorTest.java index b8b3f9acee6..b0c99aab041 100644 --- a/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/TollTravelCostCalculatorTest.java +++ b/contribs/roadpricing/src/test/java/org/matsim/contrib/roadpricing/TollTravelCostCalculatorTest.java @@ -89,7 +89,7 @@ public void testDisutilityResults() { scheme.createAndAddCost(0, 10*3600, 0.0007); - TravelTime timeCalculator = new FreespeedTravelTimeAndDisutility(config.planCalcScore()); + TravelTime timeCalculator = new FreespeedTravelTimeAndDisutility(config.scoring()); double margUtlOfMoney = 1. ; final TravelDisutilityFactory defaultDisutilityFactory = ControlerDefaults.createDefaultTravelDisutilityFactory(scenario); @@ -135,7 +135,7 @@ public void testDistanceTollRouter() { toll.addLink(Id.create("11", Link.class)); RoadPricingTestUtils.createPopulation2(scenario); Population population = scenario.getPopulation(); - TravelTime timeCalc = new FreespeedTravelTimeAndDisutility(config.planCalcScore()); + TravelTime timeCalc = new FreespeedTravelTimeAndDisutility(config.scoring()); // yy note: this returns a combined TravelTime and TravelDisutility object. The TravelDisutility object is used in the next three lines to be wrapped, // and then never again. Would be nice to be able to get them separately ... kai, oct'13 @@ -147,7 +147,7 @@ public void testDistanceTollRouter() { commonRouterData.run(network); int carLegIndex = 1 ; - if ( !config.plansCalcRoute().getAccessEgressType().equals(RoutingConfigGroup.AccessEgressType.none) ) { + if ( !config.routing().getAccessEgressType().equals(RoutingConfigGroup.AccessEgressType.none) ) { carLegIndex = 3 ; } @@ -220,7 +220,7 @@ public void testLinkTollRouter() { toll.addLink(Id.create("11", Link.class)); RoadPricingTestUtils.createPopulation2(scenario); Population population = scenario.getPopulation(); - FreespeedTravelTimeAndDisutility timeCostCalc = new FreespeedTravelTimeAndDisutility(config.planCalcScore()); + FreespeedTravelTimeAndDisutility timeCostCalc = new FreespeedTravelTimeAndDisutility(config.scoring()); TravelDisutility costCalc = new TravelDisutilityIncludingToll(timeCostCalc, toll, config); // we use freespeedTravelCosts as base costs AStarLandmarksFactory routerFactory = new AStarLandmarksFactory(2); @@ -229,7 +229,7 @@ public void testLinkTollRouter() { commonRouterData.run(network); int carLegIndex = 1 ; - if (! config.plansCalcRoute().getAccessEgressType().equals(RoutingConfigGroup.AccessEgressType.none) ) { + if (! config.routing().getAccessEgressType().equals(RoutingConfigGroup.AccessEgressType.none) ) { carLegIndex = 3 ; } @@ -316,13 +316,13 @@ public void testCordonTollRouter() { toll.addLink(Id.create("11", Link.class)); RoadPricingTestUtils.createPopulation2(scenario); Population population = scenario.getPopulation(); - FreespeedTravelTimeAndDisutility timeCostCalc = new FreespeedTravelTimeAndDisutility(config.planCalcScore()); + FreespeedTravelTimeAndDisutility timeCostCalc = new FreespeedTravelTimeAndDisutility(config.scoring()); TravelDisutility costCalc = new TravelDisutilityIncludingToll(timeCostCalc, toll, config); // we use freespeedTravelCosts as base costs AStarLandmarksFactory routerFactory = new AStarLandmarksFactory(2); int carLegIndex = 1 ; - if ( !config.plansCalcRoute().getAccessEgressType().equals(RoutingConfigGroup.AccessEgressType.none) ) { + if ( !config.routing().getAccessEgressType().equals(RoutingConfigGroup.AccessEgressType.none) ) { carLegIndex = 3 ; } diff --git a/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/mobsim/qsim/SBBQSimModuleTest.java b/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/mobsim/qsim/SBBQSimModuleTest.java index f647d8449a1..01253864c17 100644 --- a/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/mobsim/qsim/SBBQSimModuleTest.java +++ b/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/mobsim/qsim/SBBQSimModuleTest.java @@ -55,7 +55,7 @@ public void testIntegration() { Config config = ConfigUtils.createConfig(); new ConfigReader(config).parse(new ByteArrayInputStream(xmlConfig.getBytes(StandardCharsets.UTF_8))); - config.controler().setOutputDirectory(this.utils.getOutputDirectory()); + config.controller().setOutputDirectory(this.utils.getOutputDirectory()); Scenario scenario = ScenarioUtils.createScenario(config); Controler controler = new Controler(scenario); @@ -83,4 +83,4 @@ QSimComponentsConfig provideQSimComponentsConfig() { Assert.assertTrue(config.getModules().get(SBBTransitConfigGroup.GROUP_NAME) instanceof SBBTransitConfigGroup); } -} \ No newline at end of file +} diff --git a/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/mobsim/qsim/pt/SBBTransitQSimEngineIntegrationTest.java b/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/mobsim/qsim/pt/SBBTransitQSimEngineIntegrationTest.java index ee97222a5a2..cb019be8e58 100644 --- a/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/mobsim/qsim/pt/SBBTransitQSimEngineIntegrationTest.java +++ b/contribs/sbb-extensions/src/test/java/ch/sbb/matsim/mobsim/qsim/pt/SBBTransitQSimEngineIntegrationTest.java @@ -31,8 +31,8 @@ public class SBBTransitQSimEngineIntegrationTest { public void testIntegration() { TestFixture f = new TestFixture(); - f.config.controler().setOutputDirectory(this.utils.getOutputDirectory()); - f.config.controler().setLastIteration(0); + f.config.controller().setOutputDirectory(this.utils.getOutputDirectory()); + f.config.controller().setLastIteration(0); Controler controler = new Controler(f.scenario); controler.addOverridingModule(new SBBTransitModule()); @@ -60,8 +60,8 @@ public void testIntegration_misconfiguration() { mainModes.add("car"); mainModes.add("train"); f.config.qsim().setMainModes(mainModes); - f.config.controler().setOutputDirectory(this.utils.getOutputDirectory()); - f.config.controler().setLastIteration(0); + f.config.controller().setOutputDirectory(this.utils.getOutputDirectory()); + f.config.controller().setLastIteration(0); Controler controler = new Controler(f.scenario); controler.addOverridingModule(new SBBTransitModule()); diff --git a/contribs/shared_mobility/src/main/java/org/matsim/contrib/shared_mobility/examples/RunCarsharing.java b/contribs/shared_mobility/src/main/java/org/matsim/contrib/shared_mobility/examples/RunCarsharing.java index 0c5a2951b08..79a013fd40e 100644 --- a/contribs/shared_mobility/src/main/java/org/matsim/contrib/shared_mobility/examples/RunCarsharing.java +++ b/contribs/shared_mobility/src/main/java/org/matsim/contrib/shared_mobility/examples/RunCarsharing.java @@ -61,24 +61,24 @@ static public void main(String[] args) throws ConfigurationException { // We need to add interaction activity types to scoring ActivityParams pickupParams = new ActivityParams(SharingUtils.PICKUP_ACTIVITY); pickupParams.setScoringThisActivityAtAll(false); - config.planCalcScore().addActivityParams(pickupParams); + config.scoring().addActivityParams(pickupParams); ActivityParams dropoffParams = new ActivityParams(SharingUtils.DROPOFF_ACTIVITY); dropoffParams.setScoringThisActivityAtAll(false); - config.planCalcScore().addActivityParams(dropoffParams); + config.scoring().addActivityParams(dropoffParams); ActivityParams bookingParams = new ActivityParams(SharingUtils.BOOKING_ACTIVITY); bookingParams.setScoringThisActivityAtAll(false); - config.planCalcScore().addActivityParams(bookingParams); + config.scoring().addActivityParams(bookingParams); // We need to score car ModeParams carScoringParams = new ModeParams("car"); - config.planCalcScore().addModeParams(carScoringParams); + config.scoring().addModeParams(carScoringParams); // Write out all events (DEBUG) - config.controler().setWriteEventsInterval(1); - config.controler().setWritePlansInterval(1); - config.controler().setLastIteration(10); + config.controller().setWriteEventsInterval(1); + config.controller().setWritePlansInterval(1); + config.controller().setLastIteration(10); // Set up controller (no specific settings needed for scenario) Controler controller = new Controler(config); diff --git a/contribs/shared_mobility/src/main/java/org/matsim/contrib/shared_mobility/examples/RunParisVelib.java b/contribs/shared_mobility/src/main/java/org/matsim/contrib/shared_mobility/examples/RunParisVelib.java index d095a453139..1de6a4f161c 100644 --- a/contribs/shared_mobility/src/main/java/org/matsim/contrib/shared_mobility/examples/RunParisVelib.java +++ b/contribs/shared_mobility/src/main/java/org/matsim/contrib/shared_mobility/examples/RunParisVelib.java @@ -56,15 +56,15 @@ static public void main(String[] args) throws ConfigurationException { // We need to add interaction activity types to scoring ActivityParams pickupParams = new ActivityParams(SharingUtils.PICKUP_ACTIVITY); pickupParams.setScoringThisActivityAtAll(false); - config.planCalcScore().addActivityParams(pickupParams); + config.scoring().addActivityParams(pickupParams); ActivityParams dropoffParams = new ActivityParams(SharingUtils.DROPOFF_ACTIVITY); dropoffParams.setScoringThisActivityAtAll(false); - config.planCalcScore().addActivityParams(dropoffParams); + config.scoring().addActivityParams(dropoffParams); ActivityParams bookingParams = new ActivityParams(SharingUtils.BOOKING_ACTIVITY); bookingParams.setScoringThisActivityAtAll(false); - config.planCalcScore().addActivityParams(bookingParams); + config.scoring().addActivityParams(bookingParams); { // Remove some standard eqasim config groups @@ -74,7 +74,7 @@ static public void main(String[] args) throws ConfigurationException { // Replace some standard eqasim settings - for (StrategySettings strategy : config.strategy().getStrategySettings()) { + for (StrategySettings strategy : config.replanning().getStrategySettings()) { if (strategy.getStrategyName().equals("DiscreteModeChoice")) { strategy.setStrategyName("SubtourModeChoice"); } else if (strategy.getStrategyName().equals("KeepLastSelected")) { @@ -82,15 +82,15 @@ static public void main(String[] args) throws ConfigurationException { } } - config.strategy().setPlanSelectorForRemoval("WorstPlanSelector"); + config.replanning().setPlanSelectorForRemoval("WorstPlanSelector"); config.transit().setUseTransit(true); config.transit().setUsingTransitInMobsim(true); } // Write out all events (DEBUG) - config.controler().setWriteEventsInterval(1); - config.controler().setWritePlansInterval(1); - config.controler().setLastIteration(10); + config.controller().setWriteEventsInterval(1); + config.controller().setWritePlansInterval(1); + config.controller().setLastIteration(10); // Set up controller (no specific settings needed for scenario) Controler controller = new Controler(config); diff --git a/contribs/shared_mobility/src/main/java/org/matsim/contrib/shared_mobility/examples/RunTeleportationBikesharing.java b/contribs/shared_mobility/src/main/java/org/matsim/contrib/shared_mobility/examples/RunTeleportationBikesharing.java index d772f1581f0..1bdaee4a8b8 100644 --- a/contribs/shared_mobility/src/main/java/org/matsim/contrib/shared_mobility/examples/RunTeleportationBikesharing.java +++ b/contribs/shared_mobility/src/main/java/org/matsim/contrib/shared_mobility/examples/RunTeleportationBikesharing.java @@ -37,13 +37,13 @@ static public void main(String[] args) throws ConfigurationException { RoutingConfigGroup.TeleportedModeParams bikeRoutingParams = new RoutingConfigGroup.TeleportedModeParams("bike"); bikeRoutingParams.setTeleportedModeSpeed(5.0); bikeRoutingParams.setBeelineDistanceFactor(1.3); - config.plansCalcRoute().addTeleportedModeParams(bikeRoutingParams); + config.routing().addTeleportedModeParams(bikeRoutingParams); // Walk is deleted by adding bike here, we need to re-add it ... RoutingConfigGroup.TeleportedModeParams walkRoutingParams = new RoutingConfigGroup.TeleportedModeParams("walk"); walkRoutingParams.setTeleportedModeSpeed(2.0); walkRoutingParams.setBeelineDistanceFactor(1.3); - config.plansCalcRoute().addTeleportedModeParams(walkRoutingParams); + config.routing().addTeleportedModeParams(walkRoutingParams); // By default, "bike" will be simulated using teleportation. @@ -79,24 +79,24 @@ static public void main(String[] args) throws ConfigurationException { // We need to add interaction activity types to scoring ActivityParams pickupParams = new ActivityParams(SharingUtils.PICKUP_ACTIVITY); pickupParams.setScoringThisActivityAtAll(false); - config.planCalcScore().addActivityParams(pickupParams); + config.scoring().addActivityParams(pickupParams); ActivityParams dropoffParams = new ActivityParams(SharingUtils.DROPOFF_ACTIVITY); dropoffParams.setScoringThisActivityAtAll(false); - config.planCalcScore().addActivityParams(dropoffParams); + config.scoring().addActivityParams(dropoffParams); ActivityParams bookingParams = new ActivityParams(SharingUtils.BOOKING_ACTIVITY); bookingParams.setScoringThisActivityAtAll(false); - config.planCalcScore().addActivityParams(bookingParams); + config.scoring().addActivityParams(bookingParams); // We need to score bike ModeParams bikeScoringParams = new ModeParams("bike"); - config.planCalcScore().addModeParams(bikeScoringParams); + config.scoring().addModeParams(bikeScoringParams); // Write out all events (DEBUG) - config.controler().setWriteEventsInterval(1); - config.controler().setWritePlansInterval(1); - config.controler().setLastIteration(10); + config.controller().setWriteEventsInterval(1); + config.controller().setWritePlansInterval(1); + config.controller().setLastIteration(10); // Set up controller (no specific settings needed for scenario) Controler controller = new Controler(config); diff --git a/contribs/shared_mobility/src/test/java/org/matsim/contrib/shared_mobility/RunIT.java b/contribs/shared_mobility/src/test/java/org/matsim/contrib/shared_mobility/RunIT.java index 6200a54e88c..f28558a681b 100644 --- a/contribs/shared_mobility/src/test/java/org/matsim/contrib/shared_mobility/RunIT.java +++ b/contribs/shared_mobility/src/test/java/org/matsim/contrib/shared_mobility/RunIT.java @@ -43,9 +43,9 @@ public final void test() throws UncheckedIOException, ConfigurationException, UR Config config = ConfigUtils.loadConfig(ConfigGroup.getInputFileURL(scenarioUrl, "config_default.xml")); - config.controler().setLastIteration(2); + config.controller().setLastIteration(2); - config.controler().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); + config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); // We need to add the sharing config group SharingConfigGroup sharingConfig = new SharingConfigGroup(); config.addModule(sharingConfig); @@ -126,23 +126,23 @@ public final void test() throws UncheckedIOException, ConfigurationException, UR // We need to add interaction activity types to scoring ActivityParams pickupParams = new ActivityParams(SharingUtils.PICKUP_ACTIVITY); pickupParams.setScoringThisActivityAtAll(false); - config.planCalcScore().addActivityParams(pickupParams); + config.scoring().addActivityParams(pickupParams); ActivityParams dropoffParams = new ActivityParams(SharingUtils.DROPOFF_ACTIVITY); dropoffParams.setScoringThisActivityAtAll(false); - config.planCalcScore().addActivityParams(dropoffParams); + config.scoring().addActivityParams(dropoffParams); ActivityParams bookingParams = new ActivityParams(SharingUtils.BOOKING_ACTIVITY); bookingParams.setScoringThisActivityAtAll(false); - config.planCalcScore().addActivityParams(bookingParams); + config.scoring().addActivityParams(bookingParams); // We need to score car ModeParams carScoringParams = new ModeParams("car"); - config.planCalcScore().addModeParams(carScoringParams); + config.scoring().addModeParams(carScoringParams); // We need to score bike ModeParams bikeScoringParams = new ModeParams("bike"); - config.planCalcScore().addModeParams(bikeScoringParams); + config.scoring().addModeParams(bikeScoringParams); // Set up controller (no specific settings needed for scenario) Controler controller = new Controler(config); diff --git a/contribs/signals/src/main/java/org/matsim/codeexamples/adaptiveSignals/RunAdaptiveSignalsExample.java b/contribs/signals/src/main/java/org/matsim/codeexamples/adaptiveSignals/RunAdaptiveSignalsExample.java index 11fd915ebda..4511e4d41b2 100644 --- a/contribs/signals/src/main/java/org/matsim/codeexamples/adaptiveSignals/RunAdaptiveSignalsExample.java +++ b/contribs/signals/src/main/java/org/matsim/codeexamples/adaptiveSignals/RunAdaptiveSignalsExample.java @@ -23,16 +23,16 @@ * intersection is signalized by traffic-adaptive signals. The logic of the * traffic-adaptive signals is based on the basic version of Stefan Laemmer from * his phd from 2007 and can be found in LaemmerSignalController. - * + * * If you want to use other implementations of traffic-adaptive signals you have * to adjust the identifiers in the signal control file and add a factory class * for your specific implementation to the SignalsModule (see comment below). - * + * * @author tthunig */ public class RunAdaptiveSignalsExample { // do not change name of class; EWGT-paper (ThunigKuehnelNagel2018...) refers to it. theresa, aug'18 - + private static final Logger log = LogManager.getLogger(RunAdaptiveSignalsExample.class); public static void main(String[] args) { @@ -43,27 +43,27 @@ public static void main(String[] args) { } run(configFileName, "output/runAdaptiveSignalsExampleOutput/", true); // The run method is extracted so that a test can operate on it. } - + public static void run(String configFileName, String outputDir, boolean visualize) { - + Config config = ConfigUtils.loadConfig(configFileName) ; - - config.controler().setOutputDirectory(outputDir); - + + config.controller().setOutputDirectory(outputDir); + // adjustments for live visualization OTFVisConfigGroup otfvisConfig = ConfigUtils.addOrGetModule(config, OTFVisConfigGroup.class); otfvisConfig.setDrawTime(true); config.qsim().setSnapshotStyle(QSimConfigGroup.SnapshotStyle.withHoles); Scenario scenario = ScenarioUtils.loadScenario( config ) ; - + SignalSystemsConfigGroup signalsConfigGroup = ConfigUtils.addOrGetModule(config, SignalSystemsConfigGroup.GROUP_NAME, SignalSystemsConfigGroup.class); - + if (signalsConfigGroup.isUseSignalSystems()) { scenario.addScenarioElement(SignalsData.ELEMENT_NAME, new SignalsDataLoader(config).loadSignalsData()); } - + // here are some examples how to change parameters for the laemmer control LaemmerConfigGroup laemmerConfigGroup = ConfigUtils.addOrGetModule(config, LaemmerConfigGroup.GROUP_NAME, LaemmerConfigGroup.class); @@ -71,9 +71,9 @@ public static void run(String configFileName, String outputDir, boolean visualiz laemmerConfigGroup.setDesiredCycleTime(90); laemmerConfigGroup.setMinGreenTime(5); // ... - + Controler controler = new Controler( scenario ); - + // add the signals extension to the simulation if signal systems are enabled in the config if (signalsConfigGroup.isUseSignalSystems()) { Signals.configure( controler ); @@ -87,22 +87,22 @@ public static void run(String configFileName, String outputDir, boolean visualiz * Signals.configure( controler ); */ } - + // add live visualization module - if (visualize) { + if (visualize) { controler.addOverridingModule(new OTFVisWithSignalsLiveModule()); } - - controler.addOverridingModule(new AbstractModule() { + + controler.addOverridingModule(new AbstractModule() { @Override public void install() { // add analysis tools here if you like // ... } }); - + controler.run(); - + } - + } diff --git a/contribs/signals/src/main/java/org/matsim/codeexamples/fixedTimeSignals/RunSignalSystemsExample.java b/contribs/signals/src/main/java/org/matsim/codeexamples/fixedTimeSignals/RunSignalSystemsExample.java index b7a22bfa0d1..71920b51e3e 100644 --- a/contribs/signals/src/main/java/org/matsim/codeexamples/fixedTimeSignals/RunSignalSystemsExample.java +++ b/contribs/signals/src/main/java/org/matsim/codeexamples/fixedTimeSignals/RunSignalSystemsExample.java @@ -35,7 +35,7 @@ /** * Minimal example how to start your matsim run with traffic signals - * + * * @author tthunig */ public class RunSignalSystemsExample { @@ -44,28 +44,28 @@ public class RunSignalSystemsExample { /** * @param args the path to your config file */ - public static void main(String[] args) { + public static void main(String[] args) { Config config; if (args.length==0 || args.length>1) { // --- create a config for the example scenario config = ConfigUtils.loadConfig("./examples/tutorial/example90TrafficLights/useSignalInput/withLanes/config.xml"); - config.controler().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); - config.controler().setLastIteration(0); - config.controler().setOutputDirectory("output/runSignalSystemsExample/"); + config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); + config.controller().setLastIteration(0); + config.controller().setOutputDirectory("output/runSignalSystemsExample/"); } else { // --- create a config from the arguments you provided config = ConfigUtils.loadConfig(args[0]); } - + run(config, true); // The run method is extracted so that a test can operate on it. } - + public static void run(Config config, boolean visualize) { // adjustments for live visualization OTFVisConfigGroup otfvisConfig = ConfigUtils.addOrGetModule(config, OTFVisConfigGroup.class); otfvisConfig.setDrawTime(true); config.qsim().setSnapshotStyle(QSimConfigGroup.SnapshotStyle.withHoles); - + // --- create the scenario Scenario scenario = ScenarioUtils.loadScenario(config); // load the information about signals data (i.e. fill the SignalsData object) and add it to the scenario as scenario element @@ -81,7 +81,7 @@ public static void run(Config config, boolean visualize) { if (visualize) { c.addOverridingModule(new OTFVisWithSignalsLiveModule()); } - + // --- run the simulation c.run(); } diff --git a/contribs/signals/src/main/java/org/matsim/codeexamples/fixedTimeSignals/RunSignalSystemsExampleWithHoles.java b/contribs/signals/src/main/java/org/matsim/codeexamples/fixedTimeSignals/RunSignalSystemsExampleWithHoles.java index 1a07422a619..768283ca922 100644 --- a/contribs/signals/src/main/java/org/matsim/codeexamples/fixedTimeSignals/RunSignalSystemsExampleWithHoles.java +++ b/contribs/signals/src/main/java/org/matsim/codeexamples/fixedTimeSignals/RunSignalSystemsExampleWithHoles.java @@ -40,12 +40,12 @@ /** * Configures and runs MATSim with traffic signals from input files - * and visualizes it with OTFVis. - * + * and visualizes it with OTFVis. + * * @author dgrether, tthunig */ public class RunSignalSystemsExampleWithHoles { - + public static void main(String[] args) { run(true); } @@ -53,24 +53,24 @@ public static void main(String[] args) { static void run(boolean useOTFVis) { // load a config (without signal information) Config config = ConfigUtils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("equil-extended"), "config.xml")); - config.controler().setOverwriteFileSetting( OverwriteFileSetting.deleteDirectoryIfExists); - + config.controller().setOverwriteFileSetting( OverwriteFileSetting.deleteDirectoryIfExists); + // use higher values if you want to iterate - config.controler().setLastIteration(0); - + config.controller().setLastIteration(0); + config.network().setInputFile("network.xml"); config.plans().setInputFile("plans2000.xml.gz"); - + // simulate traffic dynamics with holes (default would be without) config.qsim().setTrafficDynamics(TrafficDynamics.withHoles); config.qsim().setSnapshotStyle(SnapshotStyle.withHoles); config.qsim().setNodeOffset(5.); config.qsim().setUsingFastCapacityUpdate(false); - + // add the signal config group to the config file - SignalSystemsConfigGroup signalConfig = + SignalSystemsConfigGroup signalConfig = ConfigUtils.addOrGetModule(config, SignalSystemsConfigGroup.GROUP_NAME, SignalSystemsConfigGroup.class ) ; - + // the following makes the contrib load the signal input files, but not to do anything with them // (this switch will eventually go away) signalConfig.setUseSignalSystems(true); @@ -79,7 +79,7 @@ static void run(boolean useOTFVis) { signalConfig.setSignalSystemFile("signalSystems_v2.0.xml"); signalConfig.setSignalGroupsFile("signalGroups_v2.0.xml"); signalConfig.setSignalControlFile("signalControl_v2.0.xml"); - + // // here is how to also use intergreen and amber times: // signalConfig.setUseIntergreenTimes(true); // signalConfig.setIntergreenTimesFile(intergreenTimesFile); @@ -87,17 +87,17 @@ static void run(boolean useOTFVis) { // signalConfig.setActionOnIntergreenViolation(SignalSystemsConfigGroup.ActionOnIntergreenViolation.WARN); // signalConfig.setUseAmbertimes(true); // signalConfig.setAmberTimesFile(amberTimesFile); - + // // here is how to switch on link to link travel times if lanes are used: // config.travelTimeCalculator().setCalculateLinkToLinkTravelTimes(true); // config.controler().setLinkToLinkRoutingEnabled(true); - + if (useOTFVis) { // add the OTFVis config group - OTFVisConfigGroup otfvisConfig = + OTFVisConfigGroup otfvisConfig = ConfigUtils.addOrGetModule(config, OTFVisConfigGroup.GROUP_NAME, OTFVisConfigGroup.class); // make links visible beyond screen edge - otfvisConfig.setScaleQuadTreeRect(true); + otfvisConfig.setScaleQuadTreeRect(true); otfvisConfig.setColoringScheme(ColoringScheme.byId); otfvisConfig.setAgentSize(240); } @@ -107,22 +107,22 @@ static void run(boolean useOTFVis) { /* load the information about signals data (i.e. fill the SignalsData object) * and add it to the scenario as scenario element */ scenario.addScenarioElement(SignalsData.ELEMENT_NAME, new SignalsDataLoader(config).loadSignalsData()); - + // --- create the controler Controler c = new Controler( scenario ); /* add the signals module to the simulation - * such that SignalsData is not only contained in the scenario + * such that SignalsData is not only contained in the scenario * but also used in the simulation */ // c.addOverridingModule(new SignalsModule()); Signals.configure( c ); - + /* add the visualization module to the simulation * such that it is used */ if ( useOTFVis ) { c.addOverridingModule( new OTFVisWithSignalsLiveModule() ); } - + // run the simulation c.run(); } diff --git a/contribs/signals/src/main/java/org/matsim/codeexamples/fixedTimeSignals/VisualizeSignalScenario.java b/contribs/signals/src/main/java/org/matsim/codeexamples/fixedTimeSignals/VisualizeSignalScenario.java index 1f3dbcf4129..b80a6106253 100644 --- a/contribs/signals/src/main/java/org/matsim/codeexamples/fixedTimeSignals/VisualizeSignalScenario.java +++ b/contribs/signals/src/main/java/org/matsim/codeexamples/fixedTimeSignals/VisualizeSignalScenario.java @@ -36,24 +36,24 @@ /** * This class contains a simple example how to visualize a simple scenario * with signalized intersections. - * + * * @author dgrether */ -public class VisualizeSignalScenario { +public class VisualizeSignalScenario { private static final String INPUT_DIR = "./examples/tutorial/example90TrafficLights/useSignalInput/woLanes/"; - + public static void run(boolean startOtfvis) throws IOException { // --- load the configuration file Config config = ConfigUtils.loadConfig(INPUT_DIR + "config.xml"); - config.controler().setLastIteration(0); - config.controler().setOverwriteFileSetting(OverwriteFileSetting.overwriteExistingFiles); - + config.controller().setLastIteration(0); + config.controller().setOverwriteFileSetting(OverwriteFileSetting.overwriteExistingFiles); + // --- create the scenario Scenario scenario = ScenarioUtils.loadScenario(config); // load the information about signals data (i.e. fill the SignalsData object) and add it to the scenario as scenario element scenario.addScenarioElement(SignalsData.ELEMENT_NAME, new SignalsDataLoader(config).loadSignalsData()); - + // --- create the controler Controler c = new Controler(scenario); // add the signals module to the simulation such that SignalsData is not only @@ -64,11 +64,11 @@ public static void run(boolean startOtfvis) throws IOException { // add the module that start the otfvis visualization with signals c.addOverridingModule(new OTFVisWithSignalsLiveModule()); } - + // --- run the simulation c.run(); } - + public static void main(String[] args) throws IOException { run(true); } diff --git a/contribs/signals/src/main/java/org/matsim/codeexamples/fixedTimeSignals/VisualizeSignalScenarioWithLanes.java b/contribs/signals/src/main/java/org/matsim/codeexamples/fixedTimeSignals/VisualizeSignalScenarioWithLanes.java index f1c49c85168..0b080a7fa38 100644 --- a/contribs/signals/src/main/java/org/matsim/codeexamples/fixedTimeSignals/VisualizeSignalScenarioWithLanes.java +++ b/contribs/signals/src/main/java/org/matsim/codeexamples/fixedTimeSignals/VisualizeSignalScenarioWithLanes.java @@ -32,7 +32,7 @@ /** * This class contains a simple example how to visualize a scenario with lanes and signalized intersections. - * + * * @author dgrether */ public class VisualizeSignalScenarioWithLanes { @@ -42,9 +42,9 @@ public class VisualizeSignalScenarioWithLanes { public static void run(boolean startOtfvis) { // --- load the configuration file Config config = ConfigUtils.loadConfig(INPUT_DIR + "config.xml"); - config.controler().setLastIteration(0); - config.controler().setOverwriteFileSetting(OverwriteFileSetting.overwriteExistingFiles); - + config.controller().setLastIteration(0); + config.controller().setOverwriteFileSetting(OverwriteFileSetting.overwriteExistingFiles); + // --- create the scenario Scenario scenario = ScenarioUtils.loadScenario(config); // load the information about signals data (i.e. fill the SignalsData object) and add it to the scenario as scenario element diff --git a/contribs/signals/src/main/java/org/matsim/codeexamples/simpleResponsiveSignalEngine/RunSimpleResponsiveSignalExample.java b/contribs/signals/src/main/java/org/matsim/codeexamples/simpleResponsiveSignalEngine/RunSimpleResponsiveSignalExample.java index a0b08f2895d..2e4303d48c1 100644 --- a/contribs/signals/src/main/java/org/matsim/codeexamples/simpleResponsiveSignalEngine/RunSimpleResponsiveSignalExample.java +++ b/contribs/signals/src/main/java/org/matsim/codeexamples/simpleResponsiveSignalEngine/RunSimpleResponsiveSignalExample.java @@ -246,9 +246,9 @@ private static void createSignals(Scenario scenario) { private static Config defineConfig() { Config config = ConfigUtils.createConfig(); - config.controler().setOutputDirectory("output/simpleResponsiveSignalEngineExample/"); + config.controller().setOutputDirectory("output/simpleResponsiveSignalEngineExample/"); - config.controler().setLastIteration(40); + config.controller().setLastIteration(40); config.travelTimeCalculator().setMaxTime(3600 * 5); config.qsim().setStartTime(0); config.qsim().setEndTime(3600 * 5); @@ -259,7 +259,7 @@ private static Config defineConfig() { ActivityParams dummyAct = new ActivityParams("dummy"); dummyAct.setTypicalDuration(12 * 3600); - config.planCalcScore().addActivityParams(dummyAct); + config.scoring().addActivityParams(dummyAct); // { // StrategySettings strat = new StrategySettings(); @@ -279,16 +279,16 @@ private static Config defineConfig() { StrategySettings strat = new StrategySettings(); strat.setStrategyName(DefaultSelector.KeepLastSelected.toString()); strat.setWeight(0.0); - strat.setDisableAfter(config.controler().getLastIteration()); - config.strategy().addStrategySettings(strat); + strat.setDisableAfter(config.controller().getLastIteration()); + config.replanning().addStrategySettings(strat); } - config.controler().setOverwriteFileSetting( OverwriteFileSetting.deleteDirectoryIfExists ) ; - config.controler().setWriteEventsInterval(config.controler().getLastIteration()); - config.controler().setWritePlansInterval(config.controler().getLastIteration()); + config.controller().setOverwriteFileSetting( OverwriteFileSetting.deleteDirectoryIfExists ) ; + config.controller().setWriteEventsInterval(config.controller().getLastIteration()); + config.controller().setWritePlansInterval(config.controller().getLastIteration()); config.vspExperimental().setWritingOutputEvents(true); - config.planCalcScore().setWriteExperiencedPlans(true); - config.controler().setCreateGraphs(true); + config.scoring().setWriteExperiencedPlans(true); + config.controller().setCreateGraphs(true); return config; } diff --git a/contribs/signals/src/main/java/org/matsim/codeexamples/simpleResponsiveSignalEngine/SimpleResponsiveSignal.java b/contribs/signals/src/main/java/org/matsim/codeexamples/simpleResponsiveSignalEngine/SimpleResponsiveSignal.java index 76b19f3d815..935a85ca0f0 100644 --- a/contribs/signals/src/main/java/org/matsim/codeexamples/simpleResponsiveSignalEngine/SimpleResponsiveSignal.java +++ b/contribs/signals/src/main/java/org/matsim/codeexamples/simpleResponsiveSignalEngine/SimpleResponsiveSignal.java @@ -110,7 +110,7 @@ void setFactory(SignalModelFactory factory) { @Override public void notifyAfterMobsim(AfterMobsimEvent event) { // change signal green split every INTERVAL iteration - if (event.getIteration() % INTERVAL == 0 && event.getIteration() != scenario.getConfig().controler().getFirstIteration()){ + if (event.getIteration() % INTERVAL == 0 && event.getIteration() != scenario.getConfig().controller().getFirstIteration()){ computeDelays(event); LOG.info("+++ Iteration " + event.getIteration() + ". Update signal green split..."); updateSignals(); diff --git a/contribs/signals/src/main/java/org/matsim/contrib/signals/analysis/SignalEvents2ViaCSVWriter.java b/contribs/signals/src/main/java/org/matsim/contrib/signals/analysis/SignalEvents2ViaCSVWriter.java index 516c9d1f539..5ea233f38ed 100644 --- a/contribs/signals/src/main/java/org/matsim/contrib/signals/analysis/SignalEvents2ViaCSVWriter.java +++ b/contribs/signals/src/main/java/org/matsim/contrib/signals/analysis/SignalEvents2ViaCSVWriter.java @@ -92,7 +92,7 @@ public void reset(int iteration) { @Override public void notifyIterationStarts(IterationStartsEvent event) { - if (event.getIteration() == scenario.getConfig().controler().getFirstIteration()) { + if (event.getIteration() == scenario.getConfig().controller().getFirstIteration()) { /* * do all the stuff that is needed only once a simulation: - calculating coordinations for the via file - getting the signals data out of the scenario */ @@ -100,9 +100,9 @@ public void notifyIterationStarts(IterationStartsEvent event) { } // write signal events in the same interval als usual matsim events - if (event.isLastIteration() || (scenario.getConfig().controler().getWriteEventsInterval() != 0 && event.getIteration() % scenario.getConfig().controler().getWriteEventsInterval() == 0)) { + if (event.isLastIteration() || (scenario.getConfig().controller().getWriteEventsInterval() != 0 && event.getIteration() % scenario.getConfig().controller().getWriteEventsInterval() == 0)) { writeThisIteration = true; - String signalCSVFilename = scenario.getConfig().controler().getOutputDirectory() + "/ITERS/it." + event.getIteration() + "/signalEvents2Via.csv"; + String signalCSVFilename = scenario.getConfig().controller().getOutputDirectory() + "/ITERS/it." + event.getIteration() + "/signalEvents2Via.csv"; // log.info("Initializing SignalsCSVWriter ..."); signalsCSVWriter = IOUtils.getBufferedWriter(signalCSVFilename); diff --git a/contribs/signals/src/main/java/org/matsim/contrib/signals/builder/SignalsModule.java b/contribs/signals/src/main/java/org/matsim/contrib/signals/builder/SignalsModule.java index e185debcf1a..acbb5cfa31c 100644 --- a/contribs/signals/src/main/java/org/matsim/contrib/signals/builder/SignalsModule.java +++ b/contribs/signals/src/main/java/org/matsim/contrib/signals/builder/SignalsModule.java @@ -52,7 +52,7 @@ * signal controllers, you can add a respective factory by calling the method * addSignalControllerFactory. It is also possible to use different control * schemes in one scenario at different intersections (i.e. signal systems). - * + * * @author tthunig */ class SignalsModule extends AbstractModule { @@ -70,7 +70,7 @@ class SignalsModule extends AbstractModule { signalControllerFactoryClassNames.put(SylviaSignalController.IDENTIFIER, SylviaSignalController.SylviaFactory.class); signalControllerFactoryClassNames.put(LaemmerSignalController.IDENTIFIER, LaemmerSignalController.LaemmerFactory.class); } - + @Override public void install() { @@ -79,7 +79,7 @@ public void install() { // yyyy move to individual config files??? kai, feb'19 this.signalControllerFactoryMultibinder = MapBinder.newMapBinder(binder(), new TypeLiteral() {}, new TypeLiteral() {}); - + if ((boolean) ConfigUtils.addOrGetModule(getConfig(), SignalSystemsConfigGroup.GROUP_NAME, SignalSystemsConfigGroup.class).isUseSignalSystems()) { // bindings for sensor-based signals (also works for fixed-time signals) bind(SignalModelFactory.class).to(SignalModelFactoryImpl.class); @@ -93,7 +93,7 @@ public void install() { * configure()... theresa, aug'18 */ signalControllerFactoryMultibinder.addBinding(identifier).to(signalControllerFactoryClassNames.get(identifier)); } - + // general signal bindings bind(SignalSystemsManager.class).toProvider(FromDataBuilder.class).in(Singleton.class); addMobsimListenerBinding().to(QSimSignalEngine.class); @@ -108,16 +108,16 @@ public void install() { throw new RuntimeException("Fast flow capacity update does not support signals"); } } - if (getConfig().controler().isLinkToLinkRoutingEnabled()){ + if (getConfig().controller().isLinkToLinkRoutingEnabled()){ //use the extended NetworkWithSignalsTurnInfoBuilder (instead of NetworkTurnInfoBuilder) //michalm, jan'17 bind(NetworkTurnInfoBuilderI.class).to(NetworkWithSignalsTurnInfoBuilder.class); } } - + /** * Call this method when you want to add your own SignalController. E.g. via signalsModule.addSignalControllerFactory().to(LaemmerSignalController.LaemmerFactory.class) - * + * * @param signalControllerFactoryClassName */ final void addSignalControllerFactory(String key, Class signalControllerFactoryClassName) { diff --git a/contribs/signals/src/test/java/org/matsim/codeexamples/fixedTimeSignals/RunSignalSystemsExampleTest.java b/contribs/signals/src/test/java/org/matsim/codeexamples/fixedTimeSignals/RunSignalSystemsExampleTest.java index e894ac9deaf..ee8adba17bf 100644 --- a/contribs/signals/src/test/java/org/matsim/codeexamples/fixedTimeSignals/RunSignalSystemsExampleTest.java +++ b/contribs/signals/src/test/java/org/matsim/codeexamples/fixedTimeSignals/RunSignalSystemsExampleTest.java @@ -44,15 +44,15 @@ public final void testExampleWithHoles() { Assert.fail("something went wrong: " + ee.getMessage()) ; } } - + @Test public final void testMinimalExample() { try { Config config = ConfigUtils.loadConfig("./examples/tutorial/example90TrafficLights/useSignalInput/withLanes/config.xml"); - config.controler().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); - config.controler().setLastIteration(0); - config.controler().setOutputDirectory(testUtils.getOutputDirectory()); - + config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); + config.controller().setLastIteration(0); + config.controller().setOutputDirectory(testUtils.getOutputDirectory()); + RunSignalSystemsExample.run(config, false); } catch (Exception ee ) { ee.printStackTrace(); diff --git a/contribs/signals/src/test/java/org/matsim/contrib/signals/builder/Fixture.java b/contribs/signals/src/test/java/org/matsim/contrib/signals/builder/Fixture.java index d0318865a4e..63f18a921a9 100644 --- a/contribs/signals/src/test/java/org/matsim/contrib/signals/builder/Fixture.java +++ b/contribs/signals/src/test/java/org/matsim/contrib/signals/builder/Fixture.java @@ -86,15 +86,15 @@ private Config createConfigOneSignal(Boolean useIntergreens) { e.printStackTrace(); } Config conf = ConfigUtils.createConfig(testUtils.classInputResourcePath()); - conf.controler().setOverwriteFileSetting(OverwriteFileSetting.overwriteExistingFiles); + conf.controller().setOverwriteFileSetting(OverwriteFileSetting.overwriteExistingFiles); ActivityParams params = new ActivityParams("h"); params.setTypicalDuration(24.0 * 3600.0); - conf.planCalcScore().addActivityParams(params); + conf.scoring().addActivityParams(params); StrategySettings settings = new StrategySettings(Id.create("1", StrategySettings.class)); settings.setStrategyName("ChangeExpBeta"); settings.setWeight(1.0); - conf.strategy().addStrategySettings(settings); + conf.replanning().addStrategySettings(settings); conf.network().setInputFile("network.xml.gz"); conf.network().setLaneDefinitionsFile("testLaneDefinitions_v2.0.xml"); conf.plans().setInputFile("plans1Agent.xml"); diff --git a/contribs/signals/src/test/java/org/matsim/contrib/signals/builder/TravelTimeFourWaysTest.java b/contribs/signals/src/test/java/org/matsim/contrib/signals/builder/TravelTimeFourWaysTest.java index 826e90c1f3f..da098163ddb 100644 --- a/contribs/signals/src/test/java/org/matsim/contrib/signals/builder/TravelTimeFourWaysTest.java +++ b/contribs/signals/src/test/java/org/matsim/contrib/signals/builder/TravelTimeFourWaysTest.java @@ -48,16 +48,16 @@ public class TravelTimeFourWaysTest { private static final String EVENTSFILE = "events.xml.gz"; - + @Rule public MatsimTestUtils testUtils = new MatsimTestUtils(); - + @Test public void testTrafficLightIntersection4arms() { Scenario scenario = this.createTestScenario(); scenario.getConfig().plans().setInputFile("plans.xml.gz"); ScenarioUtils.loadScenario(scenario); - + runQSimWithSignals(scenario); } @@ -72,13 +72,13 @@ public void testTrafficLightIntersection4armsWithUTurn() { private Scenario createTestScenario(){ Config conf = ConfigUtils.createConfig(testUtils.classInputResourcePath()); - conf.controler().setOverwriteFileSetting(OverwriteFileSetting.overwriteExistingFiles); - conf.controler().setMobsim("qsim"); + conf.controller().setOverwriteFileSetting(OverwriteFileSetting.overwriteExistingFiles); + conf.controller().setMobsim("qsim"); conf.network().setInputFile("network.xml.gz"); conf.network().setLaneDefinitionsFile("testLaneDefinitions_v2.0.xml"); conf.qsim().setUseLanes(true); conf.qsim().setUsingFastCapacityUpdate(false); - + SignalSystemsConfigGroup signalsConfig = ConfigUtils.addOrGetModule(conf, SignalSystemsConfigGroup.GROUP_NAME, SignalSystemsConfigGroup.class ); signalsConfig.setUseSignalSystems(true); signalsConfig.setSignalSystemFile("testSignalSystems_v2.0.xml"); @@ -86,7 +86,7 @@ private Scenario createTestScenario(){ signalsConfig.setSignalControlFile("testSignalControl_v2.0.xml"); signalsConfig.setUseAmbertimes(true); signalsConfig.setAmberTimesFile("testAmberTimes_v1.0.xml"); - + Scenario scenario = ScenarioUtils.createScenario(conf); scenario.addScenarioElement( SignalsData.ELEMENT_NAME , new SignalsDataLoader(scenario.getConfig()).loadSignalsData()); return scenario; @@ -103,7 +103,7 @@ private void runQSimWithSignals(final Scenario scenario) { // install(new ScenarioByInstanceModule(scenario)); // } // }), new SignalsModule())); - + // EventsManager events = injector.getInstance(EventsManager.class); // events.initProcessing(); @@ -122,10 +122,10 @@ private void runQSimWithSignals(final Scenario scenario) { .addOverridingModule( new SignalsModule() ) .addOverridingQSimModule( new SignalsQSimModule() ) .build( scenario, events ).run(); - + eventsXmlWriter.closeFile(); // Assert.assertEquals("different events files", EventsFileComparator.compareAndReturnInt(this.testUtils.getInputDirectory() + EVENTSFILE, eventsOut), 0); Assert.assertEquals( Result.FILES_ARE_EQUAL, new EventsFileComparator().setIgnoringCoordinates( true ).runComparison( this.testUtils.getInputDirectory() + EVENTSFILE, eventsOut ) ); } - + } diff --git a/contribs/signals/src/test/java/org/matsim/contrib/signals/builder/TravelTimeOneWayTestIT.java b/contribs/signals/src/test/java/org/matsim/contrib/signals/builder/TravelTimeOneWayTestIT.java index 1fbeee55fcf..fde085e7b61 100644 --- a/contribs/signals/src/test/java/org/matsim/contrib/signals/builder/TravelTimeOneWayTestIT.java +++ b/contribs/signals/src/test/java/org/matsim/contrib/signals/builder/TravelTimeOneWayTestIT.java @@ -78,12 +78,12 @@ public void testSignalOutflow_withLanes() { public void testSignalOutflow_woLanes() { runAndTestDifferentGreensplitSignals(this.loadAllGreenScenario(false)); } - + @Test public void testAllGreenSignalVsNoSignal_withLanes() { runAndCompareAllGreenWithNoSignals(this.loadAllGreenScenario(true)); } - + @Test public void testAllGreenSignalVsNoSignal_woLanes() { runAndCompareAllGreenWithNoSignals(this.loadAllGreenScenario(false)); @@ -91,8 +91,8 @@ public void testAllGreenSignalVsNoSignal_woLanes() { private Scenario loadAllGreenScenario(boolean useLanes) { Config conf = ConfigUtils.createConfig(testUtils.classInputResourcePath()); - conf.controler().setOverwriteFileSetting(OverwriteFileSetting.overwriteExistingFiles); - conf.controler().setMobsim("qsim"); + conf.controller().setOverwriteFileSetting(OverwriteFileSetting.overwriteExistingFiles); + conf.controller().setMobsim("qsim"); conf.network().setInputFile("network.xml"); conf.plans().setInputFile("plans.xml.gz"); conf.qsim().setStuckTime(1000); @@ -122,7 +122,7 @@ private static void runAndCompareAllGreenWithNoSignals(final Scenario scenario) StubLinkEnterEventHandler stubLinkEnterEventHandler = new StubLinkEnterEventHandler(); runQsimWithSignals(scenario, stubLinkEnterEventHandler); MeasurementPoint resultsWithSignals = stubLinkEnterEventHandler.beginningOfLink2; - + // without signals EventsManager events = EventsUtils.createEventsManager(); StubLinkEnterEventHandler eventHandler = new StubLinkEnterEventHandler(); @@ -140,7 +140,7 @@ private static void runAndCompareAllGreenWithNoSignals(final Scenario scenario) } else { Assert.fail("seems like no LinkEnterEvent was handled, as this.beginningOfLink2 is not set."); } - + // compare values Assert.assertEquals(5000.0, resultsWithSignals.numberOfVehPassed, MatsimTestUtils.EPSILON); Assert.assertEquals(resultsWithSignals.firstVehPassTime_s, resultsWoSignals.firstVehPassTime_s, MatsimTestUtils.EPSILON); @@ -163,7 +163,7 @@ private static void runAndTestDifferentGreensplitSignals(final Scenario scenario StubLinkEnterEventHandler stubLinkEnterEventHandler = new StubLinkEnterEventHandler(); runQsimWithSignals(scenario, stubLinkEnterEventHandler); - + log.debug("circulationTime: " + circulationTime); log.debug("dropping : " + dropping); @@ -183,7 +183,7 @@ public void install() { install(new ScenarioByInstanceModule(scenario)); } }), new SignalsModule())); - + EventsManager events = injector.getInstance(EventsManager.class); events.initProcessing(); for (EventHandler handler : eventHandlers){ diff --git a/contribs/signals/src/test/java/org/matsim/contrib/signals/controller/fixedTime/DefaultPlanbasedSignalSystemControllerIT.java b/contribs/signals/src/test/java/org/matsim/contrib/signals/controller/fixedTime/DefaultPlanbasedSignalSystemControllerIT.java index b6994271e62..9e5a726548a 100644 --- a/contribs/signals/src/test/java/org/matsim/contrib/signals/controller/fixedTime/DefaultPlanbasedSignalSystemControllerIT.java +++ b/contribs/signals/src/test/java/org/matsim/contrib/signals/controller/fixedTime/DefaultPlanbasedSignalSystemControllerIT.java @@ -718,10 +718,10 @@ private void createSignals() { private Config defineConfig() { Config config = ConfigUtils.createConfig(); - config.controler().setOutputDirectory(testUtils.getOutputDirectory()); + config.controller().setOutputDirectory(testUtils.getOutputDirectory()); // set number of iterations - config.controler().setLastIteration(0); + config.controller().setLastIteration(0); config.qsim().setStartTime(simStart_h*3600); config.qsim().setUsingFastCapacityUpdate(false); @@ -735,26 +735,26 @@ private Config defineConfig() { StrategySettings strat = new StrategySettings(); strat.setStrategyName(DefaultSelector.KeepLastSelected.toString()); strat.setWeight(1); - strat.setDisableAfter(config.controler().getLastIteration()); - config.strategy().addStrategySettings(strat); + strat.setDisableAfter(config.controller().getLastIteration()); + config.replanning().addStrategySettings(strat); } config.qsim().setStuckTime( 3600 ); config.qsim().setRemoveStuckVehicles(false); - config.controler().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); + config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); config.vspExperimental().setWritingOutputEvents(false); - config.planCalcScore().setWriteExperiencedPlans(false); - config.controler().setCreateGraphs(false); - config.controler().setDumpDataAtEnd(false); - config.controler().setWriteEventsInterval(config.controler().getLastIteration()); - config.controler().setWritePlansInterval(config.controler().getLastIteration()); + config.scoring().setWriteExperiencedPlans(false); + config.controller().setCreateGraphs(false); + config.controller().setDumpDataAtEnd(false); + config.controller().setWriteEventsInterval(config.controller().getLastIteration()); + config.controller().setWritePlansInterval(config.controller().getLastIteration()); // define activity types { ActivityParams dummyAct = new ActivityParams("dummy"); dummyAct.setTypicalDuration(12 * 3600); - config.planCalcScore().addActivityParams(dummyAct); + config.scoring().addActivityParams(dummyAct); } return config; } diff --git a/contribs/signals/src/test/java/org/matsim/contrib/signals/controller/laemmerFix/LaemmerIT.java b/contribs/signals/src/test/java/org/matsim/contrib/signals/controller/laemmerFix/LaemmerIT.java index f72b596c231..d5e9aaf88ca 100644 --- a/contribs/signals/src/test/java/org/matsim/contrib/signals/controller/laemmerFix/LaemmerIT.java +++ b/contribs/signals/src/test/java/org/matsim/contrib/signals/controller/laemmerFix/LaemmerIT.java @@ -510,7 +510,7 @@ private class Fixture { // create Config Config config = ConfigUtils.loadConfig("./examples/tutorial/singleCrossingScenario/config.xml"); config.plans().setInputFile(null); - config.controler().setOutputDirectory(testUtils.getOutputDirectory()); + config.controller().setOutputDirectory(testUtils.getOutputDirectory()); LaemmerConfigGroup laemmerConfigGroup = ConfigUtils.addOrGetModule(config, LaemmerConfigGroup.GROUP_NAME, LaemmerConfigGroup.class); @@ -546,12 +546,12 @@ void addLeftTurnTraffic() { } void setLastIteration(int lastIteration) { - scenario.getConfig().controler().setLastIteration(lastIteration); + scenario.getConfig().controller().setLastIteration(lastIteration); // add replanning strategy StrategySettings strat = new StrategySettings(); strat.setStrategyName(DefaultSelector.KeepLastSelected.toString()); strat.setWeight(1.); - scenario.getConfig().strategy().addStrategySettings(strat); + scenario.getConfig().replanning().addStrategySettings(strat); } DelayAnalysisTool run(SignalAnalysisTool signalAnalyzer) { diff --git a/contribs/signals/src/test/java/org/matsim/contrib/signals/controller/sylvia/SylviaIT.java b/contribs/signals/src/test/java/org/matsim/contrib/signals/controller/sylvia/SylviaIT.java index 4d4fca3fff7..3954235366d 100644 --- a/contribs/signals/src/test/java/org/matsim/contrib/signals/controller/sylvia/SylviaIT.java +++ b/contribs/signals/src/test/java/org/matsim/contrib/signals/controller/sylvia/SylviaIT.java @@ -365,10 +365,10 @@ private void createSignals(Scenario scenario, int offset) { private Config defineConfig() { Config config = ConfigUtils.createConfig(); - config.controler().setOutputDirectory(testUtils.getOutputDirectory()); + config.controller().setOutputDirectory(testUtils.getOutputDirectory()); // set number of iterations - config.controler().setLastIteration(0); + config.controller().setLastIteration(0); // able or enable signals and lanes SignalSystemsConfigGroup signalConfigGroup = ConfigUtils.addOrGetModule(config, SignalSystemsConfigGroup.GROUP_NAME, SignalSystemsConfigGroup.class); @@ -389,8 +389,8 @@ private Config defineConfig() { StrategySettings strat = new StrategySettings(); strat.setStrategyName(DefaultSelector.KeepLastSelected.toString()); strat.setWeight(0.9); - strat.setDisableAfter(config.controler().getLastIteration()); - config.strategy().addStrategySettings(strat); + strat.setDisableAfter(config.controller().getLastIteration()); + config.replanning().addStrategySettings(strat); } // choose maximal number of plans per agent. 0 means unlimited @@ -404,20 +404,20 @@ private Config defineConfig() { config.qsim().setUsingFastCapacityUpdate(false); - config.controler().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); + config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); config.vspExperimental().setWritingOutputEvents(false); - config.planCalcScore().setWriteExperiencedPlans(false); - config.controler().setCreateGraphs(false); + config.scoring().setWriteExperiencedPlans(false); + config.controller().setCreateGraphs(false); - config.controler().setWriteEventsInterval(config.controler().getLastIteration()); - config.controler().setWritePlansInterval(config.controler().getLastIteration()); + config.controller().setWriteEventsInterval(config.controller().getLastIteration()); + config.controller().setWritePlansInterval(config.controller().getLastIteration()); // define activity types { ActivityParams dummyAct = new ActivityParams("dummy"); dummyAct.setTypicalDuration(12 * 3600); - config.planCalcScore().addActivityParams(dummyAct); + config.scoring().addActivityParams(dummyAct); } return config; diff --git a/contribs/signals/src/test/java/org/matsim/contrib/signals/data/conflicts/UnprotectedLeftTurnLogicTest.java b/contribs/signals/src/test/java/org/matsim/contrib/signals/data/conflicts/UnprotectedLeftTurnLogicTest.java index 29b171fbdf6..e33fed5dc46 100644 --- a/contribs/signals/src/test/java/org/matsim/contrib/signals/data/conflicts/UnprotectedLeftTurnLogicTest.java +++ b/contribs/signals/src/test/java/org/matsim/contrib/signals/data/conflicts/UnprotectedLeftTurnLogicTest.java @@ -43,14 +43,14 @@ public class UnprotectedLeftTurnLogicTest { @Rule public MatsimTestUtils testUtils = new MatsimTestUtils(); - + @Test public void testSingleIntersectionScenarioWithLeftTurns() { // run scenarios from files AnalyzeSingleIntersectionLeftTurnDelays restrictedLeftTurns = runSimulation(IntersectionLogic.CONFLICTING_DIRECTIONS_AND_TURN_RESTRICTIONS); AnalyzeSingleIntersectionLeftTurnDelays unrestrictedLeftTurns = runSimulation(IntersectionLogic.CONFLICTING_DIRECTIONS_NO_TURN_RESTRICTIONS); AnalyzeSingleIntersectionLeftTurnDelays noLogic = runSimulation(IntersectionLogic.NONE); - + double leftTurnDelayWTurnRestriction = restrictedLeftTurns.getLeftTurnDelay(); double leftTurnDelayWoTurnRestriction = unrestrictedLeftTurns.getLeftTurnDelay(); double leftTurnDelayWithoutLogic = noLogic.getLeftTurnDelay(); @@ -69,30 +69,30 @@ private AnalyzeSingleIntersectionLeftTurnDelays runSimulation(IntersectionLogic SignalSystemsConfigGroup.GROUP_NAME, SignalSystemsConfigGroup.class); signalsConfigGroup.setSignalControlFile("signalControlFixedTime.xml"); signalsConfigGroup.setIntersectionLogic(intersectionLogic); - config.controler().setOutputDirectory(testUtils.getOutputDirectory() + intersectionLogic + "/"); - + config.controller().setOutputDirectory(testUtils.getOutputDirectory() + intersectionLogic + "/"); + Scenario scenario = ScenarioUtils.loadScenario( config ) ; scenario.addScenarioElement(SignalsData.ELEMENT_NAME, new SignalsDataLoader(config).loadSignalsData()); - + Controler controler = new Controler( scenario ); - + // add the signals module // controler.addOverridingModule(new SignalsModule()); Signals.configure(controler); - + // add analysis tools AnalyzeSingleIntersectionLeftTurnDelays handler = new AnalyzeSingleIntersectionLeftTurnDelays(); - controler.addOverridingModule(new AbstractModule() { + controler.addOverridingModule(new AbstractModule() { @Override public void install() { this.addEventHandlerBinding().toInstance(handler); } }); - + // run the simulation controler.run(); - + return handler; } - + } diff --git a/contribs/signals/src/test/java/org/matsim/contrib/signals/integration/SignalSystemsIT.java b/contribs/signals/src/test/java/org/matsim/contrib/signals/integration/SignalSystemsIT.java index e8eabb57027..96b73fa8a3d 100644 --- a/contribs/signals/src/test/java/org/matsim/contrib/signals/integration/SignalSystemsIT.java +++ b/contribs/signals/src/test/java/org/matsim/contrib/signals/integration/SignalSystemsIT.java @@ -45,64 +45,64 @@ * */ public class SignalSystemsIT { - + private final static String CONFIG_FILE_NAME = "signalSystemsIntegrationConfig.xml"; - + @Rule public MatsimTestUtils testUtils = new MatsimTestUtils(); - + @Test public void testSignalSystems() { Config config = testUtils.loadConfig(testUtils.getClassInputDirectory() + CONFIG_FILE_NAME); config.plans().setActivityDurationInterpretation(PlansConfigGroup.ActivityDurationInterpretation.minOfDurationAndEndTime); String controlerOutputDir = testUtils.getOutputDirectory() + "controlerOutput/"; - + config.network().setLaneDefinitionsFile("testLaneDefinitions_v2.0.xml"); - config.controler().setWriteEventsInterval(10); - config.controler().setWritePlansInterval(10); - - config.controler().setOutputDirectory(controlerOutputDir); - config.controler().setCreateGraphs(false); - config.controler().setDumpDataAtEnd(false); - + config.controller().setWriteEventsInterval(10); + config.controller().setWritePlansInterval(10); + + config.controller().setOutputDirectory(controlerOutputDir); + config.controller().setCreateGraphs(false); + config.controller().setDumpDataAtEnd(false); + config.qsim().setStartTime(1.5*3600); config.qsim().setEndTime(5.5*3600); config.qsim().setUsingFastCapacityUpdate(false); - - config.controler().setLastIteration(10); - + + config.controller().setLastIteration(10); + // --- - + Scenario scenario = ScenarioUtils.loadScenario(config) ; scenario.addScenarioElement(SignalsData.ELEMENT_NAME, new SignalsDataLoader(config).loadSignalsData()); - + // --- - + Controler c = new Controler(scenario); Signals.configure(c); - + c.run(); - + String inputDirectory = testUtils.getInputDirectory(); { - //iteration 0 + //iteration 0 String iterationOutput = controlerOutputDir + "ITERS/it.0/"; - + Assert.assertEquals("different events files after iteration 0 ", EventsFileComparator.Result.FILES_ARE_EQUAL, new EventsFileComparator().setIgnoringCoordinates( true ).runComparison( inputDirectory + "0.events.xml.gz", iterationOutput + "0.events.xml.gz") ); - + Scenario expectedPopulation = ScenarioUtils.createScenario(c.getConfig()); new MatsimNetworkReader(expectedPopulation.getNetwork()).parse(c.getConfig().network().getInputFileURL(c.getConfig().getContext())); new PopulationReader(expectedPopulation).readFile(inputDirectory + "0.plans.xml.gz"); - + Scenario actualPopulation = ScenarioUtils.createScenario(c.getConfig()); new PopulationReader(actualPopulation).readFile(iterationOutput + "0.plans.xml.gz"); - + boolean works = PopulationUtils.equalPopulation(expectedPopulation.getPopulation(), actualPopulation.getPopulation()); - + if (!works){ new org.matsim.api.core.v01.population.PopulationWriter(expectedPopulation.getPopulation()).write(testUtils.getOutputDirectory()+"/expected_plans_it0.xml.gz"); new org.matsim.api.core.v01.population.PopulationWriter(actualPopulation.getPopulation()).write(testUtils.getOutputDirectory()+"/actual_plans_it0.xml.gz"); @@ -110,9 +110,9 @@ public void testSignalSystems() { Assert.assertTrue("different population files after iteration 0 ", works); } { - //iteration 10 + //iteration 10 String iterationOutput = controlerOutputDir + "ITERS/it.10/"; - + Assert.assertEquals("different event files after iteration 10", EventsFileComparator.Result.FILES_ARE_EQUAL, new EventsFileComparator().setIgnoringCoordinates( true ).runComparison( inputDirectory + "10.events.xml.gz", iterationOutput + "10.events.xml.gz" ) @@ -121,12 +121,12 @@ public void testSignalSystems() { Scenario expectedPopulation = ScenarioUtils.createScenario(c.getConfig()); new MatsimNetworkReader(expectedPopulation.getNetwork()).parse(c.getConfig().network().getInputFileURL(c.getConfig().getContext())); new PopulationReader(expectedPopulation).readFile(inputDirectory + "10.plans.xml.gz"); - + Scenario actualPopulation = ScenarioUtils.createScenario(c.getConfig()); new PopulationReader(actualPopulation).readFile(iterationOutput + "10.plans.xml.gz"); - + boolean works = PopulationUtils.equalPopulation(expectedPopulation.getPopulation(), actualPopulation.getPopulation()); - + if (!works){ new org.matsim.api.core.v01.population.PopulationWriter(expectedPopulation.getPopulation()).write(testUtils.getOutputDirectory()+"/expected_plans_it10.xml.gz"); new org.matsim.api.core.v01.population.PopulationWriter(actualPopulation.getPopulation()).write(testUtils.getOutputDirectory()+"/actual_plans_it10.xml.gz"); @@ -144,58 +144,58 @@ public void testSignalSystems() { Assert.assertTrue(file.exists()); file = new File(writer.getIntergreenTimesOutputFilename()); Assert.assertTrue(file.exists()); - + } - + @Test - public void testSignalSystemsWTryEndTimeThenDuration() { + public void testSignalSystemsWTryEndTimeThenDuration() { Config config = testUtils.loadConfig(testUtils.getClassInputDirectory() + CONFIG_FILE_NAME); // tryEndTimeThenDuration currently is the default config.plans().setActivityDurationInterpretation(PlansConfigGroup.ActivityDurationInterpretation.tryEndTimeThenDuration); String controlerOutputDir = testUtils.getOutputDirectory() + "controlerOutput/"; - + config.network().setLaneDefinitionsFile("testLaneDefinitions_v2.0.xml"); - config.controler().setWriteEventsInterval(10); - config.controler().setWritePlansInterval(10); - - config.controler().setOutputDirectory(controlerOutputDir); - config.controler().setCreateGraphs(false); - config.controler().setDumpDataAtEnd(false); - + config.controller().setWriteEventsInterval(10); + config.controller().setWritePlansInterval(10); + + config.controller().setOutputDirectory(controlerOutputDir); + config.controller().setCreateGraphs(false); + config.controller().setDumpDataAtEnd(false); + config.qsim().setStartTime(1.5*3600); config.qsim().setEndTime(5*3600); config.qsim().setUsingFastCapacityUpdate(false); - - config.controler().setLastIteration(10); - + + config.controller().setLastIteration(10); + Scenario scenario = ScenarioUtils.loadScenario(config); scenario.addScenarioElement(SignalsData.ELEMENT_NAME, new SignalsDataLoader(config).loadSignalsData()); - + Controler c = new Controler(scenario); Signals.configure( c ); c.run(); - - + + String inputDirectory = testUtils.getInputDirectory(); { - //iteration 0 + //iteration 0 String iterationOutput = controlerOutputDir + "ITERS/it.0/"; - + Assert.assertEquals("different events files after iteration 0 ", EventsFileComparator.Result.FILES_ARE_EQUAL, new EventsFileComparator().setIgnoringCoordinates( true ).runComparison( inputDirectory + "0.events.xml.gz", iterationOutput + "0.events.xml.gz") ); - + Scenario expectedPopulation = ScenarioUtils.createScenario(c.getConfig()); new MatsimNetworkReader(expectedPopulation.getNetwork()).parse(c.getConfig().network().getInputFileURL(c.getConfig().getContext())); new PopulationReader(expectedPopulation).readFile(testUtils.getInputDirectory() + "0.plans.xml.gz"); - + Scenario actualPopulation = ScenarioUtils.createScenario(c.getConfig()); new PopulationReader(actualPopulation).readFile(iterationOutput + "0.plans.xml.gz"); - + boolean works = PopulationUtils.equalPopulation(expectedPopulation.getPopulation(), actualPopulation.getPopulation()); - + if (!works){ new org.matsim.api.core.v01.population.PopulationWriter(expectedPopulation.getPopulation()).write(testUtils.getOutputDirectory()+"/expected_plans_it0.xml.gz"); new org.matsim.api.core.v01.population.PopulationWriter(actualPopulation.getPopulation()).write(testUtils.getOutputDirectory()+"/actual_plans_it0.xml.gz"); @@ -203,24 +203,24 @@ public void testSignalSystemsWTryEndTimeThenDuration() { Assert.assertTrue("different population files after iteration 0 ", works); } { - //iteration 10 + //iteration 10 String iterationOutput = controlerOutputDir + "ITERS/it.10/"; - + Assert.assertEquals("different event files after iteration 10", EventsFileComparator.Result.FILES_ARE_EQUAL, new EventsFileComparator().setIgnoringCoordinates( true ).runComparison( inputDirectory + "10.events.xml.gz", iterationOutput + "10.events.xml.gz") ); - - + + Scenario expectedPopulation = ScenarioUtils.createScenario(c.getConfig()); new MatsimNetworkReader(expectedPopulation.getNetwork()).parse(c.getConfig().network().getInputFileURL(c.getConfig().getContext())); new PopulationReader(expectedPopulation).readFile(inputDirectory + "10.plans.xml.gz"); - + Scenario actualPopulation = ScenarioUtils.createScenario(c.getConfig()); new PopulationReader(actualPopulation).readFile(iterationOutput + "10.plans.xml.gz"); - + boolean works = PopulationUtils.equalPopulation(expectedPopulation.getPopulation(), actualPopulation.getPopulation()); - + if (!works){ new org.matsim.api.core.v01.population.PopulationWriter(expectedPopulation.getPopulation()).write(testUtils.getOutputDirectory()+"/expected_plans_it10.xml.gz"); new org.matsim.api.core.v01.population.PopulationWriter(actualPopulation.getPopulation()).write(testUtils.getOutputDirectory()+"/actual_plans_it10.xml.gz"); @@ -238,8 +238,8 @@ public void testSignalSystemsWTryEndTimeThenDuration() { Assert.assertTrue(file.exists()); file = new File(writer.getIntergreenTimesOutputFilename()); Assert.assertTrue(file.exists()); - + } - - + + } diff --git a/contribs/signals/src/test/java/org/matsim/contrib/signals/integration/invertednetworks/InvertedNetworksSignalsIT.java b/contribs/signals/src/test/java/org/matsim/contrib/signals/integration/invertednetworks/InvertedNetworksSignalsIT.java index 1f2806e32fe..3515b7fba6e 100644 --- a/contribs/signals/src/test/java/org/matsim/contrib/signals/integration/invertednetworks/InvertedNetworksSignalsIT.java +++ b/contribs/signals/src/test/java/org/matsim/contrib/signals/integration/invertednetworks/InvertedNetworksSignalsIT.java @@ -45,16 +45,16 @@ public class InvertedNetworksSignalsIT { @Rule public MatsimTestUtils testUtils = new MatsimTestUtils(); - + @Test public final void testSignalsInvertedNetworkRouting() { InvertedNetworkRoutingSignalsFixture f = new InvertedNetworkRoutingSignalsFixture(false, false, true); - f.scenario.getConfig().controler().setOutputDirectory(testUtils.getOutputDirectory()); + f.scenario.getConfig().controller().setOutputDirectory(testUtils.getOutputDirectory()); Controler c = new Controler(f.scenario); // c.addOverridingModule(new SignalsModule()); Signals.configure(c); - c.getConfig().controler().setDumpDataAtEnd(false); - c.getConfig().controler().setCreateGraphs(false); + c.getConfig().controller().setDumpDataAtEnd(false); + c.getConfig().controller().setCreateGraphs(false); final InvertedNetworkRoutingTestEventHandler testHandler = new InvertedNetworkRoutingTestEventHandler(); c.addControlerListener(new StartupListener(){ @Override @@ -65,12 +65,12 @@ public void notifyStartup(StartupEvent event) { c.run(); Assert.assertTrue("No traffic on link", testHandler.hadTrafficOnLink25); } - + @Test public final void testSignalsInvertedNetworkRoutingIterations() { InvertedNetworkRoutingSignalsFixture f = new InvertedNetworkRoutingSignalsFixture(false, false, true); - f.scenario.getConfig().controler().setOutputDirectory(testUtils.getOutputDirectory()); - f.scenario.getConfig().controler().setLastIteration(1); + f.scenario.getConfig().controller().setOutputDirectory(testUtils.getOutputDirectory()); + f.scenario.getConfig().controller().setLastIteration(1); SignalsData signalsData = (SignalsData) f.scenario.getScenarioElement(SignalsData.ELEMENT_NAME); SignalPlanData signalPlan = signalsData.getSignalControlData().getSignalSystemControllerDataBySystemId().get(Id.create(2, SignalSystem.class)).getSignalPlanData().get(Id.create(1, SignalPlan.class)); signalPlan.setCycleTime(500); @@ -81,8 +81,8 @@ public final void testSignalsInvertedNetworkRoutingIterations() { Controler c = new Controler(f.scenario); // c.addOverridingModule(new SignalsModule()); Signals.configure( c ); - c.getConfig().controler().setDumpDataAtEnd(false); - c.getConfig().controler().setCreateGraphs(false); + c.getConfig().controller().setDumpDataAtEnd(false); + c.getConfig().controller().setCreateGraphs(false); final InvertedNetworkRoutingTestEventHandler testHandler = new InvertedNetworkRoutingTestEventHandler(); c.addControlerListener(new StartupListener(){ @Override @@ -93,7 +93,7 @@ public void notifyStartup(StartupEvent event) { c.run(); Assert.assertTrue("No traffic on link", testHandler.hadTrafficOnLink25); } - + diff --git a/contribs/signals/src/test/java/org/matsim/contrib/signals/network/SignalsAndLanesOsmNetworkReaderTest.java b/contribs/signals/src/test/java/org/matsim/contrib/signals/network/SignalsAndLanesOsmNetworkReaderTest.java index be54f468859..7a8db642e1c 100644 --- a/contribs/signals/src/test/java/org/matsim/contrib/signals/network/SignalsAndLanesOsmNetworkReaderTest.java +++ b/contribs/signals/src/test/java/org/matsim/contrib/signals/network/SignalsAndLanesOsmNetworkReaderTest.java @@ -426,8 +426,8 @@ public void berlinSnippet(){ //Try-Mini Example to ensure basic usability scenario.getConfig().plans().setInputFile(inputfile+"plans_berlinSnippet.xml"); Controler controler = new Controler( scenario ); - config.controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists); - config.controler().setLastIteration(1); + config.controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists); + config.controller().setLastIteration(1); controler.run(); int noSignalGroups = 0; diff --git a/contribs/signals/src/test/java/org/matsim/contrib/signals/oneagent/ControlerTest.java b/contribs/signals/src/test/java/org/matsim/contrib/signals/oneagent/ControlerTest.java index 65aaff468ce..6b981e6ba59 100644 --- a/contribs/signals/src/test/java/org/matsim/contrib/signals/oneagent/ControlerTest.java +++ b/contribs/signals/src/test/java/org/matsim/contrib/signals/oneagent/ControlerTest.java @@ -32,7 +32,6 @@ import org.matsim.contrib.signals.events.SignalGroupStateChangedEventHandler; import org.matsim.core.controler.Controler; import org.matsim.core.controler.events.AfterMobsimEvent; -import org.matsim.core.controler.events.IterationStartsEvent; import org.matsim.core.controler.listener.AfterMobsimListener; import org.matsim.core.controler.listener.IterationStartsListener; import org.matsim.core.mobsim.qsim.interfaces.SignalGroupState; @@ -50,10 +49,10 @@ * */ public class ControlerTest { - + @Rule public MatsimTestUtils testUtils = new MatsimTestUtils(); - + /** * Tests the setup with a traffic light that shows all the time green in the 0th iteration. * After the mobsim is run the signal settings are changed thus in the 1st iteration @@ -64,13 +63,13 @@ public void testModifySignalControlDataOnsetOffset() { //configure and load standard scenario Fixture fixture = new Fixture(); Scenario scenario = fixture.createAndLoadTestScenarioOneSignal(false); - scenario.getConfig().controler().setFirstIteration(0); - scenario.getConfig().controler().setLastIteration(1); - scenario.getConfig().controler().setOutputDirectory(testUtils.getOutputDirectory()); - scenario.getConfig().controler().setWriteEventsInterval(1); - + scenario.getConfig().controller().setFirstIteration(0); + scenario.getConfig().controller().setLastIteration(1); + scenario.getConfig().controller().setOutputDirectory(testUtils.getOutputDirectory()); + scenario.getConfig().controller().setWriteEventsInterval(1); + Controler controler = new Controler(scenario); - controler.getConfig().controler().setCreateGraphs(false); + controler.getConfig().controller().setCreateGraphs(false); controler.addControlerListener(new AfterMobsimListener() { @Override @@ -82,7 +81,7 @@ public void notifyAfterMobsim(AfterMobsimEvent event) { ((SignalsData) scenario .getScenarioElement(SignalsData.ELEMENT_NAME)).getSignalControlData() .getSignalSystemControllerDataBySystemId().values()) { - + for (SignalPlanData plan : intersectionSignal.getSignalPlanData().values()) { plan.setCycleTime(2000); for (SignalGroupSettingsData data : plan.getSignalGroupSettingsDataByGroupId().values()) { @@ -93,7 +92,7 @@ public void notifyAfterMobsim(AfterMobsimEvent event) { } } }); - + controler.addControlerListener((IterationStartsListener)event -> { event.getServices().getEvents().addHandler(new EventsLogger()); @@ -108,11 +107,11 @@ public void notifyAfterMobsim(AfterMobsimEvent event) { event.getServices().getEvents().addHandler(signalsHandler0); } }); - + controler.run(); } - - + + private static final class TestSignalGroupStateChangedHandler implements SignalGroupStateChangedEventHandler { @@ -143,5 +142,5 @@ public void handleEvent(LinkEnterEvent e){ } } } - + } diff --git a/contribs/signals/src/test/java/org/matsim/contrib/signals/oneagent/Fixture.java b/contribs/signals/src/test/java/org/matsim/contrib/signals/oneagent/Fixture.java index 3021d072edd..2aeba8355a5 100644 --- a/contribs/signals/src/test/java/org/matsim/contrib/signals/oneagent/Fixture.java +++ b/contribs/signals/src/test/java/org/matsim/contrib/signals/oneagent/Fixture.java @@ -89,15 +89,15 @@ private Config createConfigOneSignal(Boolean useIntergreens) { e.printStackTrace(); } Config conf = ConfigUtils.createConfig(testUtils.classInputResourcePath()); - conf.controler().setOverwriteFileSetting(OverwriteFileSetting.overwriteExistingFiles); + conf.controller().setOverwriteFileSetting(OverwriteFileSetting.overwriteExistingFiles); ActivityParams params = new ActivityParams("h"); params.setTypicalDuration(24.0 * 3600.0); - conf.planCalcScore().addActivityParams(params); + conf.scoring().addActivityParams(params); StrategySettings settings = new StrategySettings(Id.create("1", StrategySettings.class)); settings.setStrategyName("ChangeExpBeta"); settings.setWeight(1.0); - conf.strategy().addStrategySettings(settings); + conf.replanning().addStrategySettings(settings); conf.network().setInputFile("network.xml.gz"); conf.network().setLaneDefinitionsFile("testLaneDefinitions_v2.0.xml"); conf.plans().setInputFile("plans1Agent.xml"); diff --git a/contribs/simulatedannealing/src/main/java/org/matsim/contrib/simulatedannealing/SimulatedAnnealingAnalysis.java b/contribs/simulatedannealing/src/main/java/org/matsim/contrib/simulatedannealing/SimulatedAnnealingAnalysis.java index 519351d1390..c6e2c23ea99 100644 --- a/contribs/simulatedannealing/src/main/java/org/matsim/contrib/simulatedannealing/SimulatedAnnealingAnalysis.java +++ b/contribs/simulatedannealing/src/main/java/org/matsim/contrib/simulatedannealing/SimulatedAnnealingAnalysis.java @@ -39,7 +39,7 @@ public final class SimulatedAnnealingAnalysis implements IterationStartsListe public SimulatedAnnealingAnalysis(Config config, MatsimServices matsimServices, SimulatedAnnealing simulatedAnnealing) { this.matsimServices = matsimServices; - this.runId = Optional.ofNullable(config.controler().getRunId()).orElse(notAvailableString); + this.runId = Optional.ofNullable(config.controller().getRunId()).orElse(notAvailableString); this.simulatedAnnealing = simulatedAnnealing; this.delimiter = config.global().getDefaultDelimiter(); diff --git a/contribs/simulatedannealing/src/test/java/org/matsim/contrib/simulatedannealing/SimulatedAnnealingIT.java b/contribs/simulatedannealing/src/test/java/org/matsim/contrib/simulatedannealing/SimulatedAnnealingIT.java index 361e99b08cc..a8622e6ba36 100644 --- a/contribs/simulatedannealing/src/test/java/org/matsim/contrib/simulatedannealing/SimulatedAnnealingIT.java +++ b/contribs/simulatedannealing/src/test/java/org/matsim/contrib/simulatedannealing/SimulatedAnnealingIT.java @@ -41,12 +41,12 @@ public void testIntegratedAnnealingInQSim() { final Controler controler = new Controler(config); - controler.getConfig().controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles); - controler.getConfig().controler().setCreateGraphs(false); - controler.getConfig().controler().setWriteEventsInterval(0); + controler.getConfig().controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles); + controler.getConfig().controller().setCreateGraphs(false); + controler.getConfig().controller().setWriteEventsInterval(0); SimulatedAnnealingConfigGroup simAnCfg = new SimulatedAnnealingConfigGroup(); - config.controler().setLastIteration(10); + config.controller().setLastIteration(10); controler.addOverridingModule(new AbstractModule() { @Override diff --git a/contribs/simwrapper/src/test/java/org/matsim/simwrapper/SimWrapperModuleTest.java b/contribs/simwrapper/src/test/java/org/matsim/simwrapper/SimWrapperModuleTest.java index ec6e7ca7075..0e781bb830d 100644 --- a/contribs/simwrapper/src/test/java/org/matsim/simwrapper/SimWrapperModuleTest.java +++ b/contribs/simwrapper/src/test/java/org/matsim/simwrapper/SimWrapperModuleTest.java @@ -2,14 +2,11 @@ import org.junit.Rule; import org.junit.Test; -import org.matsim.application.analysis.traffic.LinkStats; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; import org.matsim.core.controler.Controler; import org.matsim.core.utils.io.IOUtils; import org.matsim.examples.ExamplesUtils; -import org.matsim.simwrapper.viz.PieChart; -import org.matsim.simwrapper.viz.TextBlock; import org.matsim.testcases.MatsimTestUtils; import java.net.URL; @@ -26,8 +23,8 @@ public void runScenario() { Config config = ConfigUtils.loadConfig(equil); - config.controler().setLastIteration(5); - config.controler().setOutputDirectory(utils.getOutputDirectory()); + config.controller().setLastIteration(5); + config.controller().setOutputDirectory(utils.getOutputDirectory()); Controler controler = new Controler(config); controler.addOverridingModule(new SimWrapperModule()); diff --git a/contribs/simwrapper/src/test/java/org/matsim/simwrapper/TestScenario.java b/contribs/simwrapper/src/test/java/org/matsim/simwrapper/TestScenario.java index 039e7acad58..a58095cc3e1 100644 --- a/contribs/simwrapper/src/test/java/org/matsim/simwrapper/TestScenario.java +++ b/contribs/simwrapper/src/test/java/org/matsim/simwrapper/TestScenario.java @@ -4,7 +4,6 @@ import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.network.Link; import org.matsim.application.MATSimApplication; -import org.matsim.contrib.emissions.HbefaVehicleCategory; import org.matsim.contrib.vsp.scenario.SnzActivities; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; @@ -13,9 +12,6 @@ import org.matsim.core.utils.io.IOUtils; import org.matsim.examples.ExamplesUtils; import org.matsim.testcases.MatsimTestUtils; -import org.matsim.vehicles.EngineInformation; -import org.matsim.vehicles.VehicleType; -import org.matsim.vehicles.VehicleUtils; import java.net.URL; import java.util.HashSet; @@ -36,10 +32,10 @@ public static Config loadConfig(MatsimTestUtils utils) { URL context = ExamplesUtils.getTestScenarioURL("kelheim"); Config config = ConfigUtils.loadConfig(IOUtils.extendUrl(context, "config.xml")); - config.controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists); - config.controler().setOutputDirectory(utils.getOutputDirectory()); - config.controler().setLastIteration(0); - config.controler().setWriteEventsInterval(1); + config.controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists); + config.controller().setOutputDirectory(utils.getOutputDirectory()); + config.controller().setLastIteration(0); + config.controller().setWriteEventsInterval(1); return config; } diff --git a/contribs/simwrapper/src/test/java/org/matsim/simwrapper/dashboard/DashboardTests.java b/contribs/simwrapper/src/test/java/org/matsim/simwrapper/dashboard/DashboardTests.java index d3bd0e20124..394797cdea9 100644 --- a/contribs/simwrapper/src/test/java/org/matsim/simwrapper/dashboard/DashboardTests.java +++ b/contribs/simwrapper/src/test/java/org/matsim/simwrapper/dashboard/DashboardTests.java @@ -4,7 +4,6 @@ import org.junit.Rule; import org.junit.Test; import org.matsim.application.MATSimApplication; -import org.matsim.contrib.emissions.utils.EmissionsConfigGroup; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; import org.matsim.core.controler.Controler; @@ -23,7 +22,7 @@ public class DashboardTests { private void run(Dashboard... dashboards) { Config config = TestScenario.loadConfig(utils); - config.controler().setLastIteration(2); + config.controller().setLastIteration(2); SimWrapperConfigGroup group = ConfigUtils.addOrGetModule(config, SimWrapperConfigGroup.class); group.defaultParams().sampleSize = 0.001; diff --git a/contribs/socnetsim/src/main/java/org/matsim/contrib/socnetsim/framework/controller/listeners/JointPlansDumping.java b/contribs/socnetsim/src/main/java/org/matsim/contrib/socnetsim/framework/controller/listeners/JointPlansDumping.java index d0268d9daad..1f624bbc98d 100644 --- a/contribs/socnetsim/src/main/java/org/matsim/contrib/socnetsim/framework/controller/listeners/JointPlansDumping.java +++ b/contribs/socnetsim/src/main/java/org/matsim/contrib/socnetsim/framework/controller/listeners/JointPlansDumping.java @@ -52,8 +52,8 @@ public JointPlansDumping( final OutputDirectoryHierarchy controlerIO ) { this.sc = sc ; this.jointPlans = (JointPlans) sc.getScenarioElement( JointPlans.ELEMENT_NAME ); - this.firstIteration = sc.getConfig().controler().getFirstIteration(); - this.writePlansInterval = sc.getConfig().controler().getWritePlansInterval() ; + this.firstIteration = sc.getConfig().controller().getFirstIteration(); + this.writePlansInterval = sc.getConfig().controller().getWritePlansInterval() ; this.controlerIO = controlerIO ; } diff --git a/contribs/socnetsim/src/main/java/org/matsim/contrib/socnetsim/framework/replanning/strategies/CoalitionExpBetaFactory.java b/contribs/socnetsim/src/main/java/org/matsim/contrib/socnetsim/framework/replanning/strategies/CoalitionExpBetaFactory.java index 3d4d089511e..174687017ea 100644 --- a/contribs/socnetsim/src/main/java/org/matsim/contrib/socnetsim/framework/replanning/strategies/CoalitionExpBetaFactory.java +++ b/contribs/socnetsim/src/main/java/org/matsim/contrib/socnetsim/framework/replanning/strategies/CoalitionExpBetaFactory.java @@ -49,7 +49,7 @@ public GroupLevelPlanSelector createSelector() { return new CoalitionSelector( new LogitWeight( MatsimRandom.getLocalInstance(), - sc.getConfig().planCalcScore().getBrainExpBeta()), + sc.getConfig().scoring().getBrainExpBeta()), conflictSolver); } } diff --git a/contribs/socnetsim/src/main/java/org/matsim/contrib/socnetsim/framework/replanning/strategies/GroupSelectExpBetaFactory.java b/contribs/socnetsim/src/main/java/org/matsim/contrib/socnetsim/framework/replanning/strategies/GroupSelectExpBetaFactory.java index 96a9ef30475..047404f6e16 100644 --- a/contribs/socnetsim/src/main/java/org/matsim/contrib/socnetsim/framework/replanning/strategies/GroupSelectExpBetaFactory.java +++ b/contribs/socnetsim/src/main/java/org/matsim/contrib/socnetsim/framework/replanning/strategies/GroupSelectExpBetaFactory.java @@ -48,7 +48,7 @@ public GroupLevelPlanSelector createSelector() { return new LogitSumSelector( MatsimRandom.getLocalInstance(), incompatiblePlansIdentifierFactory, - sc.getConfig().planCalcScore().getBrainExpBeta()); + sc.getConfig().scoring().getBrainExpBeta()); } } diff --git a/contribs/socnetsim/src/main/java/org/matsim/contrib/socnetsim/framework/replanning/strategies/GroupWhoIsTheBossSelectExpBetaFactory.java b/contribs/socnetsim/src/main/java/org/matsim/contrib/socnetsim/framework/replanning/strategies/GroupWhoIsTheBossSelectExpBetaFactory.java index 91648c35c9f..120cd6e7658 100644 --- a/contribs/socnetsim/src/main/java/org/matsim/contrib/socnetsim/framework/replanning/strategies/GroupWhoIsTheBossSelectExpBetaFactory.java +++ b/contribs/socnetsim/src/main/java/org/matsim/contrib/socnetsim/framework/replanning/strategies/GroupWhoIsTheBossSelectExpBetaFactory.java @@ -53,7 +53,7 @@ public GroupLevelPlanSelector createSelector() { incompatiblePlansIdentifierFactory , new LogitWeight( MatsimRandom.getLocalInstance(), - sc.getConfig().planCalcScore().getBrainExpBeta()) ); + sc.getConfig().scoring().getBrainExpBeta()) ); } } diff --git a/contribs/socnetsim/src/main/java/org/matsim/contrib/socnetsim/jointactivities/scoring/FireMoneyEventsForUtilityOfBeingTogether.java b/contribs/socnetsim/src/main/java/org/matsim/contrib/socnetsim/jointactivities/scoring/FireMoneyEventsForUtilityOfBeingTogether.java index 1df9b8341df..019ca148c9b 100644 --- a/contribs/socnetsim/src/main/java/org/matsim/contrib/socnetsim/jointactivities/scoring/FireMoneyEventsForUtilityOfBeingTogether.java +++ b/contribs/socnetsim/src/main/java/org/matsim/contrib/socnetsim/jointactivities/scoring/FireMoneyEventsForUtilityOfBeingTogether.java @@ -94,7 +94,7 @@ public FireMoneyEventsForUtilityOfBeingTogether( module.getActTypeFilterForJointScoring(), module.getModeFilterForJointScoring(), getPersonOverlapScorerFactory( sc ), - sc.getConfig().planCalcScore().getMarginalUtilityOfMoney(), + sc.getConfig().scoring().getMarginalUtilityOfMoney(), sc.getActivityFacilities(), (SocialNetwork) sc.getScenarioElement( SocialNetwork.ELEMENT_NAME ) ); @@ -151,7 +151,7 @@ public static double getTypicalDuration( if ( typicalDuration != null ) return typicalDuration; - final ActivityParams params = scenario.getConfig().planCalcScore().getActivityParams( type ); + final ActivityParams params = scenario.getConfig().scoring().getActivityParams( type ); if ( params == null ) { //throw new RuntimeException( "could not find typical duration for Person "+person.getId()+" for type "+type ); diff --git a/contribs/socnetsim/src/main/java/org/matsim/contrib/socnetsim/jointtrips/scoring/CharyparNagelWithJointModesScoringFunctionFactory.java b/contribs/socnetsim/src/main/java/org/matsim/contrib/socnetsim/jointtrips/scoring/CharyparNagelWithJointModesScoringFunctionFactory.java index 4fe7423b7f3..2f436e9d857 100644 --- a/contribs/socnetsim/src/main/java/org/matsim/contrib/socnetsim/jointtrips/scoring/CharyparNagelWithJointModesScoringFunctionFactory.java +++ b/contribs/socnetsim/src/main/java/org/matsim/contrib/socnetsim/jointtrips/scoring/CharyparNagelWithJointModesScoringFunctionFactory.java @@ -66,7 +66,7 @@ public CharyparNagelWithJointModesScoringFunctionFactory( final Set typesNotToScore, final Scenario scenario) { log.warn( "initializing the \"CharyparNagel\" scoring function: this has no special parameters for joint modes!" ); - this.params = new ScoringParameters.Builder(scenario.getConfig().planCalcScore(), scenario.getConfig().planCalcScore().getScoringParameters(null), scenario.getConfig().scenario()).build(); + this.params = new ScoringParameters.Builder(scenario.getConfig().scoring(), scenario.getConfig().scoring().getScoringParameters(null), scenario.getConfig().scenario()).build(); this.scenario = scenario; this.blackList = typesNotToScore; diff --git a/contribs/socnetsim/src/main/java/org/matsim/contrib/socnetsim/usage/analysis/CourtesyHistogramListener.java b/contribs/socnetsim/src/main/java/org/matsim/contrib/socnetsim/usage/analysis/CourtesyHistogramListener.java index 02c1f50e5e9..824a87c16b4 100644 --- a/contribs/socnetsim/src/main/java/org/matsim/contrib/socnetsim/usage/analysis/CourtesyHistogramListener.java +++ b/contribs/socnetsim/src/main/java/org/matsim/contrib/socnetsim/usage/analysis/CourtesyHistogramListener.java @@ -59,7 +59,7 @@ public class CourtesyHistogramListener implements IterationEndsListener, Iterat CourtesyHistogramListener(Config config, CourtesyHistogram histogram, OutputDirectoryHierarchy controlerIO) { this.controlerIO = controlerIO; this.histogram = histogram; - this.outputGraph = config.controler().isCreateGraphs(); + this.outputGraph = config.controller().isCreateGraphs(); } @Override diff --git a/contribs/socnetsim/src/main/java/org/matsim/contrib/socnetsim/usage/replanning/strategies/GroupMinLossSelectExpBetaFactory.java b/contribs/socnetsim/src/main/java/org/matsim/contrib/socnetsim/usage/replanning/strategies/GroupMinLossSelectExpBetaFactory.java index 9f211616cdc..b6f397ca44a 100644 --- a/contribs/socnetsim/src/main/java/org/matsim/contrib/socnetsim/usage/replanning/strategies/GroupMinLossSelectExpBetaFactory.java +++ b/contribs/socnetsim/src/main/java/org/matsim/contrib/socnetsim/usage/replanning/strategies/GroupMinLossSelectExpBetaFactory.java @@ -40,7 +40,7 @@ public class GroupMinLossSelectExpBetaFactory extends NonInnovativeStrategyFacto private final Scenario sc; private final IncompatiblePlansIdentifierFactory incompatiblePlans; - + @Inject public GroupMinLossSelectExpBetaFactory( Scenario sc , IncompatiblePlansIdentifierFactory incompatiblePlans ) { this.sc = sc; @@ -57,7 +57,7 @@ public GroupLevelPlanSelector createSelector() { new LossWeight(), (JointPlans) sc.getScenarioElement( JointPlans.ELEMENT_NAME ) ), MatsimRandom.getLocalInstance(), - sc.getConfig().planCalcScore().getBrainExpBeta()) ); + sc.getConfig().scoring().getBrainExpBeta()) ); } } diff --git a/contribs/socnetsim/src/main/java/org/matsim/contrib/socnetsim/usage/replanning/strategies/GroupMinSelectExpBetaFactory.java b/contribs/socnetsim/src/main/java/org/matsim/contrib/socnetsim/usage/replanning/strategies/GroupMinSelectExpBetaFactory.java index 9399f0d65c2..60c42842220 100644 --- a/contribs/socnetsim/src/main/java/org/matsim/contrib/socnetsim/usage/replanning/strategies/GroupMinSelectExpBetaFactory.java +++ b/contribs/socnetsim/src/main/java/org/matsim/contrib/socnetsim/usage/replanning/strategies/GroupMinSelectExpBetaFactory.java @@ -54,7 +54,7 @@ public GroupLevelPlanSelector createSelector() { new LowestScoreOfJointPlanWeight( ((JointPlans) sc.getScenarioElement( JointPlans.ELEMENT_NAME )) ), MatsimRandom.getLocalInstance(), - sc.getConfig().planCalcScore().getBrainExpBeta()) ); + sc.getConfig().scoring().getBrainExpBeta()) ); } } diff --git a/contribs/socnetsim/src/main/java/org/matsim/contrib/socnetsim/usage/replanning/strategies/GroupTimeAllocationMutatorFactory.java b/contribs/socnetsim/src/main/java/org/matsim/contrib/socnetsim/usage/replanning/strategies/GroupTimeAllocationMutatorFactory.java index 032b81787ca..9c27ebe7b89 100644 --- a/contribs/socnetsim/src/main/java/org/matsim/contrib/socnetsim/usage/replanning/strategies/GroupTimeAllocationMutatorFactory.java +++ b/contribs/socnetsim/src/main/java/org/matsim/contrib/socnetsim/usage/replanning/strategies/GroupTimeAllocationMutatorFactory.java @@ -79,8 +79,8 @@ public GroupPlanStrategy get() { public PlanAlgorithm getPlanAlgoInstance() { final int iteration = getReplanningContext().getIteration(); - final int firstIteration = config.controler().getFirstIteration(); - final double nIters = config.controler().getLastIteration() - firstIteration; + final int firstIteration = config.controller().getFirstIteration(); + final double nIters = config.controller().getLastIteration() - firstIteration; final double minTemp = 1; final double startMin = (2 / 3.) * nIters; final double progress = (iteration - firstIteration) / startMin; diff --git a/contribs/socnetsim/src/main/java/org/matsim/contrib/socnetsim/usage/replanning/strategies/GroupWeightedSelectExpBetaFactory.java b/contribs/socnetsim/src/main/java/org/matsim/contrib/socnetsim/usage/replanning/strategies/GroupWeightedSelectExpBetaFactory.java index 5c3a04b5d64..b3b683627e5 100644 --- a/contribs/socnetsim/src/main/java/org/matsim/contrib/socnetsim/usage/replanning/strategies/GroupWeightedSelectExpBetaFactory.java +++ b/contribs/socnetsim/src/main/java/org/matsim/contrib/socnetsim/usage/replanning/strategies/GroupWeightedSelectExpBetaFactory.java @@ -54,13 +54,13 @@ public GroupLevelPlanSelector createSelector() { sc.getConfig().getModule( GroupReplanningConfigGroup.GROUP_NAME ); - return + return new HighestWeightSelector( incompatiblePlansIdentifierFactory , new WeightedWeight( new LogitWeight( MatsimRandom.getLocalInstance(), - sc.getConfig().planCalcScore().getBrainExpBeta()), + sc.getConfig().scoring().getBrainExpBeta()), configGroup.getWeightAttributeName(), sc.getPopulation() ) ); diff --git a/contribs/socnetsim/src/main/java/org/matsim/contrib/socnetsim/usage/replanning/strategies/ParetoExpBetaFactory.java b/contribs/socnetsim/src/main/java/org/matsim/contrib/socnetsim/usage/replanning/strategies/ParetoExpBetaFactory.java index e42ae240f1f..e616e55e645 100644 --- a/contribs/socnetsim/src/main/java/org/matsim/contrib/socnetsim/usage/replanning/strategies/ParetoExpBetaFactory.java +++ b/contribs/socnetsim/src/main/java/org/matsim/contrib/socnetsim/usage/replanning/strategies/ParetoExpBetaFactory.java @@ -48,13 +48,13 @@ public ParetoExpBetaFactory( IncompatiblePlansIdentifierFactory incompatiblePlan @Override public GroupLevelPlanSelector createSelector() { - return + return new HighestWeightSelector( incompatiblePlansIdentifierFactory, new ParetoWeight( new LogitWeight( MatsimRandom.getLocalInstance(), - sc.getConfig().planCalcScore().getBrainExpBeta())) ); + sc.getConfig().scoring().getBrainExpBeta())) ); } } diff --git a/contribs/taxi/src/main/java/org/matsim/contrib/etaxi/run/RunETaxiBenchmark.java b/contribs/taxi/src/main/java/org/matsim/contrib/etaxi/run/RunETaxiBenchmark.java index 0236fe6a5ee..5e67a5e2105 100644 --- a/contribs/taxi/src/main/java/org/matsim/contrib/etaxi/run/RunETaxiBenchmark.java +++ b/contribs/taxi/src/main/java/org/matsim/contrib/etaxi/run/RunETaxiBenchmark.java @@ -72,16 +72,16 @@ public static void run(String [] configUrl, int nIterations) { Config config = ConfigUtils.loadConfig(configUrl, new MultiModeTaxiConfigGroup(ETaxiConfigGroups::createWithCustomETaxiOptimizerParams), new DvrpConfigGroup(), new EvConfigGroup()); - config.controler().setOverwriteFileSetting(OverwriteFileSetting.overwriteExistingFiles); + config.controller().setOverwriteFileSetting(OverwriteFileSetting.overwriteExistingFiles); createControler(config, nIterations).run(); } public static Controler createControler(Config config, int runs) { - config.controler().setLastIteration(runs - 1); - config.controler().setDumpDataAtEnd(false); - config.controler().setWriteEventsInterval(0); - config.controler().setWritePlansInterval(0); - config.controler().setCreateGraphs(false); + config.controller().setLastIteration(runs - 1); + config.controller().setDumpDataAtEnd(false); + config.controller().setWriteEventsInterval(0); + config.controller().setWritePlansInterval(0); + config.controller().setCreateGraphs(false); DvrpBenchmarks.adjustConfig(config); Scenario scenario = createScenarioWithDrtRouteFactory(config); diff --git a/contribs/taxi/src/main/java/org/matsim/contrib/etaxi/run/RunETaxiScenario.java b/contribs/taxi/src/main/java/org/matsim/contrib/etaxi/run/RunETaxiScenario.java index 1d67f8be01e..f5598174103 100644 --- a/contribs/taxi/src/main/java/org/matsim/contrib/etaxi/run/RunETaxiScenario.java +++ b/contribs/taxi/src/main/java/org/matsim/contrib/etaxi/run/RunETaxiScenario.java @@ -58,7 +58,7 @@ public static void run(String [] args, boolean otfvis) { new MultiModeTaxiConfigGroup(ETaxiConfigGroups::createWithCustomETaxiOptimizerParams), new DvrpConfigGroup(), new OTFVisConfigGroup(), new EvConfigGroup()); - config.controler().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); + config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); createControler(config, otfvis).run(); } diff --git a/contribs/taxi/src/main/java/org/matsim/contrib/taxi/benchmark/RunTaxiBenchmark.java b/contribs/taxi/src/main/java/org/matsim/contrib/taxi/benchmark/RunTaxiBenchmark.java index 989ea7e4062..b87e10a3413 100644 --- a/contribs/taxi/src/main/java/org/matsim/contrib/taxi/benchmark/RunTaxiBenchmark.java +++ b/contribs/taxi/src/main/java/org/matsim/contrib/taxi/benchmark/RunTaxiBenchmark.java @@ -56,11 +56,11 @@ public static void run(URL configUrl, int runs) { } public static Controler createControler(Config config, int runs) { - config.controler().setLastIteration(runs - 1); - config.controler().setDumpDataAtEnd(false); - config.controler().setWriteEventsInterval(0); - config.controler().setWritePlansInterval(0); - config.controler().setCreateGraphs(false); + config.controller().setLastIteration(runs - 1); + config.controller().setDumpDataAtEnd(false); + config.controller().setWriteEventsInterval(0); + config.controller().setWritePlansInterval(0); + config.controller().setCreateGraphs(false); DvrpBenchmarks.adjustConfig(config); Scenario scenario = createScenarioWithDrtRouteFactory(config); diff --git a/contribs/taxi/src/main/java/org/matsim/contrib/taxi/run/examples/RunMultiModeTaxiExample.java b/contribs/taxi/src/main/java/org/matsim/contrib/taxi/run/examples/RunMultiModeTaxiExample.java index 2fd5bc00fdd..81d05a94c33 100644 --- a/contribs/taxi/src/main/java/org/matsim/contrib/taxi/run/examples/RunMultiModeTaxiExample.java +++ b/contribs/taxi/src/main/java/org/matsim/contrib/taxi/run/examples/RunMultiModeTaxiExample.java @@ -34,7 +34,7 @@ public static void run(URL configUrl, boolean otfvis, int lastIteration) { // load config Config config = ConfigUtils.loadConfig(configUrl, new MultiModeTaxiConfigGroup(), new DvrpConfigGroup(), new OTFVisConfigGroup()); - config.controler().setLastIteration(lastIteration); + config.controller().setLastIteration(lastIteration); TaxiControlerCreator.createControler(config, otfvis).run(); } diff --git a/contribs/taxi/src/main/java/org/matsim/contrib/taxi/run/examples/RunTaxiExample.java b/contribs/taxi/src/main/java/org/matsim/contrib/taxi/run/examples/RunTaxiExample.java index 7b4a44842c3..e3bc4048497 100644 --- a/contribs/taxi/src/main/java/org/matsim/contrib/taxi/run/examples/RunTaxiExample.java +++ b/contribs/taxi/src/main/java/org/matsim/contrib/taxi/run/examples/RunTaxiExample.java @@ -33,7 +33,7 @@ public static void run(URL configUrl, boolean otfvis, int lastIteration) { // load config Config config = ConfigUtils.loadConfig(configUrl, new MultiModeTaxiConfigGroup(), new DvrpConfigGroup(), new OTFVisConfigGroup()); - config.controler().setLastIteration(lastIteration); + config.controller().setLastIteration(lastIteration); TaxiControlerCreator.createControler(config, otfvis).run(); } } diff --git a/contribs/taxi/src/test/java/org/matsim/contrib/taxi/optimizer/TaxiOptimizerTests.java b/contribs/taxi/src/test/java/org/matsim/contrib/taxi/optimizer/TaxiOptimizerTests.java index 57b3ac811ca..f92b30ee28a 100644 --- a/contribs/taxi/src/test/java/org/matsim/contrib/taxi/optimizer/TaxiOptimizerTests.java +++ b/contribs/taxi/src/test/java/org/matsim/contrib/taxi/optimizer/TaxiOptimizerTests.java @@ -43,7 +43,7 @@ public static void runBenchmark(boolean vehicleDiversion, AbstractTaxiOptimizerP // mielec taxi mini benchmark contains only the morning peak (6:00 - 12:00) that is shifted by -6 hours (i.e. 0:00 - 6:00). URL configUrl = IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("mielec"), "mielec_taxi_mini_benchmark_config.xml"); var config = ConfigUtils.loadConfig(configUrl, new MultiModeTaxiConfigGroup(), new DvrpConfigGroup()); - config.controler().setOutputDirectory(utils.getOutputDirectory()); + config.controller().setOutputDirectory(utils.getOutputDirectory()); TaxiConfigGroup taxiCfg = TaxiConfigGroup.getSingleModeTaxiConfig(config); Optional.ofNullable(taxiCfg.getTaxiOptimizerParams()).ifPresent(taxiCfg::removeParameterSet); @@ -52,8 +52,8 @@ public static void runBenchmark(boolean vehicleDiversion, AbstractTaxiOptimizerP var controler = RunTaxiBenchmark.createControler(config, 1); // RunTaxiBenchmark.createControler() overrides some config params, this is a moment to adjust them - config.controler().setWriteEventsInterval(1); - config.controler().setDumpDataAtEnd(true); + config.controller().setWriteEventsInterval(1); + config.controller().setDumpDataAtEnd(true); controler.run(); diff --git a/contribs/taxi/src/test/java/org/matsim/contrib/taxi/run/RunTaxiScenarioTestIT.java b/contribs/taxi/src/test/java/org/matsim/contrib/taxi/run/RunTaxiScenarioTestIT.java index ee1f6728ea3..7e991fdfebe 100644 --- a/contribs/taxi/src/test/java/org/matsim/contrib/taxi/run/RunTaxiScenarioTestIT.java +++ b/contribs/taxi/src/test/java/org/matsim/contrib/taxi/run/RunTaxiScenarioTestIT.java @@ -51,8 +51,8 @@ private void runMielec(String plansFile, String taxisFile) { new OTFVisConfigGroup()); config.plans().setInputFile(plansFile); TaxiConfigGroup.getSingleModeTaxiConfig(config).taxisFile = taxisFile; - config.controler().setOutputDirectory(utils.getOutputDirectory()); - config.controler().setDumpDataAtEnd(false); + config.controller().setOutputDirectory(utils.getOutputDirectory()); + config.controller().setDumpDataAtEnd(false); TaxiControlerCreator.createControler(config, false).run(); } } diff --git a/contribs/vsp/src/main/java/org/matsim/contrib/freight/analysis/RunFreightAnalysisEventBased.java b/contribs/vsp/src/main/java/org/matsim/contrib/freight/analysis/RunFreightAnalysisEventBased.java index 3f5792e8ace..f63240e6e7d 100644 --- a/contribs/vsp/src/main/java/org/matsim/contrib/freight/analysis/RunFreightAnalysisEventBased.java +++ b/contribs/vsp/src/main/java/org/matsim/contrib/freight/analysis/RunFreightAnalysisEventBased.java @@ -75,8 +75,8 @@ public void runAnalysis() throws IOException { config.network().setInputFile(SIM_OUTPUT_PATH + "output_network.xml.gz"); config.global().setCoordinateSystem(GLOBAL_CRS); config.plans().setInputFile(null); - config.parallelEventHandling().setNumberOfThreads(null); - config.parallelEventHandling().setEstimatedNumberOfEvents(null); + config.eventsManager().setNumberOfThreads(null); + config.eventsManager().setEstimatedNumberOfEvents(null); config.global().setNumberOfThreads(1); //freight settings FreightConfigGroup freightConfigGroup = ConfigUtils.addOrGetModule( config, FreightConfigGroup.class ) ; diff --git a/contribs/vsp/src/main/java/org/matsim/contrib/vsp/scenario/SnzActivities.java b/contribs/vsp/src/main/java/org/matsim/contrib/vsp/scenario/SnzActivities.java index cbb8c519805..5687f8b2116 100644 --- a/contribs/vsp/src/main/java/org/matsim/contrib/vsp/scenario/SnzActivities.java +++ b/contribs/vsp/src/main/java/org/matsim/contrib/vsp/scenario/SnzActivities.java @@ -70,18 +70,18 @@ public static void addScoringParams(Config config) { for (SnzActivities value : SnzActivities.values()) { for (long ii = 600; ii <= 97200; ii += 600) { - config.planCalcScore().addActivityParams(value.apply(new ScoringConfigGroup.ActivityParams(value.name() + "_" + ii).setTypicalDuration(ii))); + config.scoring().addActivityParams(value.apply(new ScoringConfigGroup.ActivityParams(value.name() + "_" + ii).setTypicalDuration(ii))); } } - config.planCalcScore().addActivityParams(new ScoringConfigGroup.ActivityParams("car interaction").setTypicalDuration(60)); - config.planCalcScore().addActivityParams(new ScoringConfigGroup.ActivityParams("ride interaction").setTypicalDuration(60)); - config.planCalcScore().addActivityParams(new ScoringConfigGroup.ActivityParams("bike interaction").setTypicalDuration(60)); + config.scoring().addActivityParams(new ScoringConfigGroup.ActivityParams("car interaction").setTypicalDuration(60)); + config.scoring().addActivityParams(new ScoringConfigGroup.ActivityParams("ride interaction").setTypicalDuration(60)); + config.scoring().addActivityParams(new ScoringConfigGroup.ActivityParams("bike interaction").setTypicalDuration(60)); - config.planCalcScore().addActivityParams(new ScoringConfigGroup.ActivityParams("other").setTypicalDuration(600 * 3)); + config.scoring().addActivityParams(new ScoringConfigGroup.ActivityParams("other").setTypicalDuration(600 * 3)); - config.planCalcScore().addActivityParams(new ScoringConfigGroup.ActivityParams("freight_start").setTypicalDuration(60 * 15)); - config.planCalcScore().addActivityParams(new ScoringConfigGroup.ActivityParams("freight_end").setTypicalDuration(60 * 15)); + config.scoring().addActivityParams(new ScoringConfigGroup.ActivityParams("freight_start").setTypicalDuration(60 * 15)); + config.scoring().addActivityParams(new ScoringConfigGroup.ActivityParams("freight_end").setTypicalDuration(60 * 15)); } } diff --git a/contribs/vsp/src/main/java/playground/vsp/analysis/modules/modalAnalyses/modalShare/ModalShareControlerListener.java b/contribs/vsp/src/main/java/playground/vsp/analysis/modules/modalAnalyses/modalShare/ModalShareControlerListener.java index 758bd5814d0..829f58ac57f 100644 --- a/contribs/vsp/src/main/java/playground/vsp/analysis/modules/modalAnalyses/modalShare/ModalShareControlerListener.java +++ b/contribs/vsp/src/main/java/playground/vsp/analysis/modules/modalAnalyses/modalShare/ModalShareControlerListener.java @@ -51,13 +51,13 @@ public class ModalShareControlerListener implements StartupListener, IterationEn @Override public void notifyStartup(StartupEvent event) { - this.firstIteration = event.getServices().getConfig().controler().getFirstIteration(); + this.firstIteration = event.getServices().getConfig().controller().getFirstIteration(); this.events.addHandler(this.modalShareHandler); } @Override public void notifyIterationEnds(IterationEndsEvent event) { - String outputDir = event.getServices().getConfig().controler().getOutputDirectory(); + String outputDir = event.getServices().getConfig().controller().getOutputDirectory(); SortedMap mode2legs = this.modalShareHandler.getMode2numberOflegs(); modeHistory.addAll(mode2legs.keySet()); diff --git a/contribs/vsp/src/main/java/playground/vsp/analysis/modules/modalAnalyses/modalTripTime/ModalTravelTimeControlerListener.java b/contribs/vsp/src/main/java/playground/vsp/analysis/modules/modalAnalyses/modalTripTime/ModalTravelTimeControlerListener.java index e8bae833ad3..604fa8a1f0f 100644 --- a/contribs/vsp/src/main/java/playground/vsp/analysis/modules/modalAnalyses/modalTripTime/ModalTravelTimeControlerListener.java +++ b/contribs/vsp/src/main/java/playground/vsp/analysis/modules/modalAnalyses/modalTripTime/ModalTravelTimeControlerListener.java @@ -55,14 +55,14 @@ public class ModalTravelTimeControlerListener implements StartupListener, Iterat @Override public void notifyStartup(StartupEvent event) { - this.firstIteration = event.getServices().getConfig().controler().getFirstIteration(); + this.firstIteration = event.getServices().getConfig().controller().getFirstIteration(); this.events.addHandler(this.travelTimeHandler); } @Override public void notifyIterationEnds(IterationEndsEvent event) { - String outputDir = event.getServices().getConfig().controler().getOutputDirectory(); + String outputDir = event.getServices().getConfig().controller().getOutputDirectory(); SortedMap mode2AvgTripTime = modalAvgTime(); modeHistory.addAll(mode2AvgTripTime.keySet()); diff --git a/contribs/vsp/src/main/java/playground/vsp/analysis/modules/simpleTripAnalyzer/SimpleTripAnalyzer.java b/contribs/vsp/src/main/java/playground/vsp/analysis/modules/simpleTripAnalyzer/SimpleTripAnalyzer.java index 01555386963..877f39c9eab 100644 --- a/contribs/vsp/src/main/java/playground/vsp/analysis/modules/simpleTripAnalyzer/SimpleTripAnalyzer.java +++ b/contribs/vsp/src/main/java/playground/vsp/analysis/modules/simpleTripAnalyzer/SimpleTripAnalyzer.java @@ -55,17 +55,17 @@ import org.matsim.core.utils.io.IOUtils; /** - * A simple analysis-class for a very basic MATSim-Scenario, i.e it should be used + * A simple analysis-class for a very basic MATSim-Scenario, i.e it should be used * with physical simulation of car-trips only. All other modes must be teleported. Thus, - * this class will throw a runtime-exception when {@link ScenarioConfigGroup#isUseTransit()} is true. - * + * this class will throw a runtime-exception when {@link ScenarioConfigGroup#isUseTransit()} is true. + * * @author droeder * */ -public final class SimpleTripAnalyzer extends AbstractPersonAlgorithm +public final class SimpleTripAnalyzer extends AbstractPersonAlgorithm implements LinkLeaveEventHandler, PersonArrivalEventHandler, - PersonDepartureEventHandler, + PersonDepartureEventHandler, PersonStuckEventHandler, VehicleEntersTrafficEventHandler, VehicleLeavesTrafficEventHandler { @SuppressWarnings("unused") @@ -74,15 +74,15 @@ public final class SimpleTripAnalyzer extends AbstractPersonAlgorithm private Network net; private Set> pIds; private Map distFactors; - + private Vehicle2DriverEventHandler delegate = new Vehicle2DriverEventHandler(); - + public SimpleTripAnalyzer(Config c, Network net, Set> pIds) throws RuntimeException{ if(c.transit().isUseTransit() ){ throw new RuntimeException("This analysis is structured very simple. " + "Thus, it does not allow physically simulated transit!"); } - this.distFactors = c.plansCalcRoute().getBeelineDistanceFactors() ; + this.distFactors = c.routing().getBeelineDistanceFactors() ; this.net = net; this.pIds = pIds; } @@ -106,9 +106,9 @@ public void handleEvent(PersonDepartureEvent event) { mode = (mode == TransportMode.transit_walk) ? TransportMode.walk : mode; // cars start at the end of a link, thus we subtract the link-length for car-trips. //the distance for other modes is Double.NaN as they are teleported. - t.startTrip(event.getTime(), mode, + t.startTrip(event.getTime(), mode, (mode == TransportMode.car) ? (-calcLinkDistance(event.getLinkId())) : Double.NaN); - + } @Override @@ -120,7 +120,7 @@ public void handleEvent(LinkLeaveEvent event) { t.passLink(calcLinkDistance(event.getLinkId())); } - + @Override public void handleEvent(PersonArrivalEvent event) { Traveller t = this.traveller.get(event.getPersonId()); @@ -129,7 +129,7 @@ public void handleEvent(PersonArrivalEvent event) { } t.endTrip(event.getTime(), calcLinkDistance(event.getLinkId())); } - + @Override public void handleEvent(PersonStuckEvent event) { Traveller t = this.traveller.get(event.getPersonId()); @@ -138,7 +138,7 @@ public void handleEvent(PersonStuckEvent event) { } t.setStuck(); } - + @Override public void handleEvent(VehicleEntersTrafficEvent event) { delegate.handleEvent(event); @@ -169,7 +169,7 @@ public void run(Person person) { trip.beeline = calcBeelineDistance(trip.from, trip.to); // dist for non-car-modes is calculated with a factor if(!trip.mode.equals(TransportMode.car)){ - trip.dist = this.distFactors.get( trip.mode ) * trip.beeline; + trip.dist = this.distFactors.get( trip.mode ) * trip.beeline; } // there will be no more trips if(trip.stuck) return; @@ -177,7 +177,7 @@ public void run(Person person) { } // ##################helper methods ####################### - + /** * @param linkId * @return @@ -200,7 +200,7 @@ private Double calcBeelineDistance(Coord from, Coord to) { * @param outputPath */ public void dumpData(String outputPath, String fileprefix) { - BufferedWriter w = IOUtils.getBufferedWriter(outputPath + System.getProperty("file.separator") + + BufferedWriter w = IOUtils.getBufferedWriter(outputPath + System.getProperty("file.separator") + ((fileprefix == null) ? "" : (fileprefix.endsWith(".") ? fileprefix : (fileprefix + "."))) + "trips.csv.gz"); try { w.write(Traveller.HEADER + "\n"); @@ -216,10 +216,10 @@ public void dumpData(String outputPath, String fileprefix) { } //##################getter/setter############################### - + public final Map, Traveller> getTraveller(){ return traveller; } - + } diff --git a/contribs/vsp/src/main/java/playground/vsp/analysis/modules/userBenefits/UserBenefitsCalculator.java b/contribs/vsp/src/main/java/playground/vsp/analysis/modules/userBenefits/UserBenefitsCalculator.java index 622939f0685..f67b7f0fc98 100644 --- a/contribs/vsp/src/main/java/playground/vsp/analysis/modules/userBenefits/UserBenefitsCalculator.java +++ b/contribs/vsp/src/main/java/playground/vsp/analysis/modules/userBenefits/UserBenefitsCalculator.java @@ -54,7 +54,7 @@ public class UserBenefitsCalculator { private final Set> stuckingAgents; public UserBenefitsCalculator(Config config, WelfareMeasure wm, boolean considerAllPlans) { - ScoringConfigGroup pcs = config.planCalcScore(); + ScoringConfigGroup pcs = config.scoring(); this.betaLogit = pcs.getBrainExpBeta(); this.marginalUtlOfMoney = pcs.getMarginalUtilityOfMoney(); this.welfareMeasure = wm; @@ -73,7 +73,7 @@ public UserBenefitsCalculator(Config config, WelfareMeasure wm, boolean consider public UserBenefitsCalculator(Config config, Set> stuckingAgents) { logger.info("Providing the IDs of agents that are stucking in the final iteration (selected plans)."); - ScoringConfigGroup pcs = config.planCalcScore(); + ScoringConfigGroup pcs = config.scoring(); this.betaLogit = pcs.getBrainExpBeta(); this.marginalUtlOfMoney = pcs.getMarginalUtilityOfMoney(); this.stuckingAgents = stuckingAgents; diff --git a/contribs/vsp/src/main/java/playground/vsp/andreas/mzilske/bvg09/DataPrepare.java b/contribs/vsp/src/main/java/playground/vsp/andreas/mzilske/bvg09/DataPrepare.java index d380efe7262..af460a53229 100644 --- a/contribs/vsp/src/main/java/playground/vsp/andreas/mzilske/bvg09/DataPrepare.java +++ b/contribs/vsp/src/main/java/playground/vsp/andreas/mzilske/bvg09/DataPrepare.java @@ -156,11 +156,11 @@ protected void routePopulation() { new PopulationReader(this.scenario).readFile(InInputPlansFileWithXY2Links); DijkstraFactory dijkstraFactory = new DijkstraFactory(); - FreespeedTravelTimeAndDisutility timeCostCalculator = new FreespeedTravelTimeAndDisutility(this.scenario.getConfig().planCalcScore()); + FreespeedTravelTimeAndDisutility timeCostCalculator = new FreespeedTravelTimeAndDisutility(this.scenario.getConfig().scoring()); TransitConfigGroup transitConfig = new TransitConfigGroup(); - TransitRouterConfig transitRouterConfig = new TransitRouterConfig(this.scenario.getConfig().planCalcScore() - , this.scenario.getConfig().plansCalcRoute(), this.scenario.getConfig().transitRouter(), + TransitRouterConfig transitRouterConfig = new TransitRouterConfig(this.scenario.getConfig().scoring() + , this.scenario.getConfig().routing(), this.scenario.getConfig().transitRouter(), this.scenario.getConfig().vspExperimental()); log.warn( "please chack that this still does what you want. td, oct 2013"); @@ -185,8 +185,8 @@ protected void routePopulation() { protected void visualizeRouterNetwork() { - TransitRouterConfig transitRouterConfig = new TransitRouterConfig(this.scenario.getConfig().planCalcScore() - , this.scenario.getConfig().plansCalcRoute(), this.scenario.getConfig().transitRouter(), + TransitRouterConfig transitRouterConfig = new TransitRouterConfig(this.scenario.getConfig().scoring() + , this.scenario.getConfig().routing(), this.scenario.getConfig().transitRouter(), this.scenario.getConfig().vspExperimental()); TransitRouterImpl router = new TransitRouterImpl(transitRouterConfig, this.scenario.getTransitSchedule() ); @@ -221,7 +221,7 @@ protected void visualizeRouterNetwork() { private void buildUmlaeufe() { Collection transitLines = this.scenario.getTransitSchedule().getTransitLines().values(); - GreedyUmlaufBuilderImpl greedyUmlaufBuilder = new GreedyUmlaufBuilderImpl(new UmlaufInterpolator(this.scenario.getNetwork(), this.scenario.getConfig().planCalcScore()), transitLines); + GreedyUmlaufBuilderImpl greedyUmlaufBuilder = new GreedyUmlaufBuilderImpl(new UmlaufInterpolator(this.scenario.getNetwork(), this.scenario.getConfig().scoring()), transitLines); Collection umlaeufe = greedyUmlaufBuilder.build(); VehiclesFactory vb = this.scenario.getTransitVehicles().getFactory(); diff --git a/contribs/vsp/src/main/java/playground/vsp/andreas/mzilske/pt/queuesim/GreedyUmlaufBuilderImpl.java b/contribs/vsp/src/main/java/playground/vsp/andreas/mzilske/pt/queuesim/GreedyUmlaufBuilderImpl.java index ed41e96f525..8302957adf5 100644 --- a/contribs/vsp/src/main/java/playground/vsp/andreas/mzilske/pt/queuesim/GreedyUmlaufBuilderImpl.java +++ b/contribs/vsp/src/main/java/playground/vsp/andreas/mzilske/pt/queuesim/GreedyUmlaufBuilderImpl.java @@ -30,12 +30,12 @@ public final class GreedyUmlaufBuilderImpl implements UmlaufBuilder { private static final Logger log = LogManager.getLogger( GreedyUmlaufBuilderImpl.class ); public class UmlaufKey { - + private final Id lineId; private final Id stopFacilityId; private final double lastArrivalTime; private final Id umlaufId; - + Id getUmlaufId() { return umlaufId; @@ -52,7 +52,7 @@ Id getUmlaufId() { public Id getLineId() { return lineId; } - + public Id getStopFacility() { return stopFacilityId; } @@ -60,12 +60,12 @@ public Id getStopFacility() { double getLastArrivalTime() { return lastArrivalTime; } - + @Override public String toString() { return stopFacilityId + " at " + lastArrivalTime + "(" + getLineId() + ")"; } - + } @@ -75,7 +75,7 @@ public String toString() { public int compare(UmlaufStueck o1, UmlaufStueck o2) { return Double.compare(o1.getDeparture().getDepartureTime(), o2.getDeparture().getDepartureTime()); } - + }; private static final Comparator umlaufKeyComparator = new Comparator() { @@ -86,7 +86,7 @@ public int compare(UmlaufKey o1, UmlaufKey o2) { if (c != 0) { return c; } else { - int cc = o1.getLineId().compareTo(o2.getLineId()); + int cc = o1.getLineId().compareTo(o2.getLineId()); if (cc != 0) { return cc; } else { @@ -99,9 +99,9 @@ public int compare(UmlaufKey o1, UmlaufKey o2) { } } } - + }; - + private final Collection transitLines; private final SortedMap umlaeufe = new TreeMap(umlaufKeyComparator); private ArrayList umlaufStuecke; @@ -115,14 +115,14 @@ public GreedyUmlaufBuilderImpl(UmlaufInterpolator interpolator, Collection build() { if (!canBuild()) { @@ -142,12 +142,12 @@ public Collection build() { } return umlaeufe.values(); } - + private static double getLastArrivalTime( Umlauf umlauf ) { TransitRouteStop previousStop = getLastStop(umlauf); double previousDepartureTime = getLastDeparture(umlauf).getDepartureTime(); double arrivalOffset = previousStop.getArrivalOffset().seconds(); - double previousArrivalTime = previousDepartureTime + arrivalOffset; + double previousArrivalTime = previousDepartureTime + arrivalOffset; return previousArrivalTime; } @@ -210,7 +210,7 @@ private void createUmlaufStuecke() { Collections.sort(this.umlaufStuecke, departureTimeComparator); } - - + + } diff --git a/contribs/vsp/src/main/java/playground/vsp/buildingEnergy/BuildingEnergyRunnerMain.java b/contribs/vsp/src/main/java/playground/vsp/buildingEnergy/BuildingEnergyRunnerMain.java index 28d2b93ecd0..982a441a790 100644 --- a/contribs/vsp/src/main/java/playground/vsp/buildingEnergy/BuildingEnergyRunnerMain.java +++ b/contribs/vsp/src/main/java/playground/vsp/buildingEnergy/BuildingEnergyRunnerMain.java @@ -57,7 +57,7 @@ public abstract class BuildingEnergyRunnerMain { private static final int LENGTH = 2; /** - * + * * @param args {configfile agents2exclude.csv} */ public static void main(String[] args) { @@ -72,7 +72,7 @@ public static void main(String[] args) { System.exit(-1); } OutputDirectoryLogging.catchLogEntries(); - + log.info("running " + BuildingEnergyRunnerMain.class.getName() ); String configFilename = args[0]; String agents2exclude = args[1]; @@ -84,14 +84,14 @@ public static void main(String[] args) { Scenario sc = loadScenario(c, agents2exclude); // run Controler controler = new Controler(sc); - controler.getConfig().controler().setOverwriteFileSetting( + controler.getConfig().controller().setOverwriteFileSetting( overwrite ? OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles : OutputDirectoryHierarchy.OverwriteFileSetting.failIfDirectoryExists ); controler.addControlerListener(new MyControlerListener(c, sc.getNetwork())); controler.run(); } - + /** * @param configFilename * @param agents2exclude @@ -139,33 +139,33 @@ private static Set> getAgents2Exclude(String agents2exclude) { // static class which plug the analysis to the services and generates some more output (distance- & tt-shares) private static class MyControlerListener implements IterationStartsListener, IterationEndsListener{ - + private SimpleTripAnalyzer analyzer; - + MyControlerListener(Config c, Network net){ analyzer = new SimpleTripAnalyzer(c, net, null); } - + @Override public void notifyIterationStarts(IterationStartsEvent event) { - if(event.getIteration() == event.getServices().getConfig().controler().getLastIteration()){ + if(event.getIteration() == event.getServices().getConfig().controller().getLastIteration()){ analyzer.reset(event.getIteration()); event.getServices().getEvents().addHandler(analyzer); } } - + @Override public void notifyIterationEnds(IterationEndsEvent event) { - if(event.getIteration() == event.getServices().getConfig().controler().getLastIteration()){ + if(event.getIteration() == event.getServices().getConfig().controller().getLastIteration()){ analyzer.run(event.getServices().getScenario().getPopulation()); String path = event.getServices().getControlerIO().getOutputPath() + System.getProperty("file.separator"); - String prefix = event.getServices().getConfig().controler().getRunId() + "."; + String prefix = event.getServices().getConfig().controller().getRunId() + "."; analyzer.dumpData(path, prefix); calcWriteDistanceDistribution(analyzer.getTraveller(), path + prefix + "distanceShare.csv.gz"); calcAndWriteTTDistribution(analyzer.getTraveller(), path + prefix + "ttShare.csv.gz"); } } - + /** * @param traveller */ @@ -194,7 +194,7 @@ private void calcAndWriteTTDistribution(Map, Traveller> traveller, St } dumpData(map, file); } - + /** * @param traveller */ @@ -223,7 +223,7 @@ private void calcWriteDistanceDistribution(Map, Traveller> traveller, } dumpData(map, file); } - + /** * @param map * @param file @@ -249,7 +249,7 @@ private void dumpData(Map> map, String file) { e.printStackTrace(); } } - + /** * @param temp * @param dist @@ -262,9 +262,9 @@ private void increase(Map temp, Double value) { } } } - - - + + + private Map getColumn(Map> map, List distribution, String mode){ if(map.containsKey(mode)) return map.get(mode); Map temp = new LinkedHashMap(); @@ -274,9 +274,9 @@ private Map getColumn(Map> map, L map.put(mode, temp); return temp; } - + } - + } diff --git a/contribs/vsp/src/main/java/playground/vsp/buildingEnergy/linkOccupancy/RunEquil.java b/contribs/vsp/src/main/java/playground/vsp/buildingEnergy/linkOccupancy/RunEquil.java index 18a2268e3d1..965ae44b56b 100644 --- a/contribs/vsp/src/main/java/playground/vsp/buildingEnergy/linkOccupancy/RunEquil.java +++ b/contribs/vsp/src/main/java/playground/vsp/buildingEnergy/linkOccupancy/RunEquil.java @@ -14,7 +14,7 @@ public class RunEquil { public static void main(String[] args) { String configFile = "examples/equil/config.xml"; Config config = ConfigUtils.loadConfig(configFile); - config.controler().setLastIteration(0); + config.controller().setLastIteration(0); Scenario scenario = ScenarioUtils.loadScenario(config); Controler controler = new Controler(scenario); @@ -31,7 +31,7 @@ public static void main(String[] args) { // People work only 30 minutes in Equil, so the interval for work-time is 6:01 to 6:30 final LinkActivityOccupancyCounter atWork = new LinkActivityOccupancyCounter(scenario.getPopulation(), 6*60*60 + 1, 6*60*60 + 30 * 60); controler.getEvents().addHandler(atWork); - + // This one briefly listens in when everyone is already at home again final LinkActivityOccupancyCounter nextNight = new LinkActivityOccupancyCounter(scenario.getPopulation(), 13*60*60 + 45 * 60, 13*60*60 + 47 * 60); controler.getEvents().addHandler(nextNight); @@ -39,7 +39,7 @@ public static void main(String[] args) { // During this window, most people are already home, a few are still working, and one person is actually seen both at work and at home. final LinkActivityOccupancyCounter middle = new LinkActivityOccupancyCounter(scenario.getPopulation(), 27810, 31440); controler.getEvents().addHandler(middle); - + // This one listens all day final LinkActivityOccupancyCounter allDay = new LinkActivityOccupancyCounter(scenario.getPopulation()); controler.getEvents().addHandler(allDay); @@ -69,7 +69,7 @@ public void notifyIterationEnds(IterationEndsEvent event) { System.out.println("---"); } }); - controler.getConfig().controler().setOverwriteFileSetting( + controler.getConfig().controller().setOverwriteFileSetting( true ? OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles : OutputDirectoryHierarchy.OverwriteFileSetting.failIfDirectoryExists ); diff --git a/contribs/vsp/src/main/java/playground/vsp/cadyts/marginals/ModalDistanceCadytsBuilder.java b/contribs/vsp/src/main/java/playground/vsp/cadyts/marginals/ModalDistanceCadytsBuilder.java index 8ddbcd6641d..513423ed0c6 100644 --- a/contribs/vsp/src/main/java/playground/vsp/cadyts/marginals/ModalDistanceCadytsBuilder.java +++ b/contribs/vsp/src/main/java/playground/vsp/cadyts/marginals/ModalDistanceCadytsBuilder.java @@ -40,7 +40,7 @@ AnalyticalCalibrator> build() { validateTimeBinSize(cadytsConfig.getTimeBinSize()); AnalyticalCalibrator> calibrator = new AnalyticalCalibrator<>( - config.controler().getOutputDirectory() + "/cadyts" + MARGINALS + ".log", + config.controller().getOutputDirectory() + "/cadyts" + MARGINALS + ".log", MatsimRandom.getLocalInstance().nextLong(), cadytsConfig.getTimeBinSize() ); @@ -51,7 +51,7 @@ AnalyticalCalibrator> build() { calibrator.setFreezeIteration(cadytsConfig.getFreezeIteration()); calibrator.setPreparatoryIterations(cadytsConfig.getPreparatoryIterations()); calibrator.setVarianceScale(cadytsConfig.getVarianceScale()); - calibrator.setStatisticsFile(config.controler().getOutputDirectory() + "/calibration-stats"+MARGINALS+".txt"); + calibrator.setStatisticsFile(config.controller().getOutputDirectory() + "/calibration-stats"+MARGINALS+".txt"); calibrator.setBruteForce(cadytsConfig.useBruteForce()); // I don't think this has an influence on any of the variants we are using. (Has an influence only when plan choice is left diff --git a/contribs/vsp/src/main/java/playground/vsp/congestion/RunSimpleExample.java b/contribs/vsp/src/main/java/playground/vsp/congestion/RunSimpleExample.java index e8a973e1c77..20eab2ed05b 100644 --- a/contribs/vsp/src/main/java/playground/vsp/congestion/RunSimpleExample.java +++ b/contribs/vsp/src/main/java/playground/vsp/congestion/RunSimpleExample.java @@ -19,7 +19,7 @@ * *********************************************************************** */ /** - * + * */ package playground.vsp.congestion; @@ -54,7 +54,7 @@ public static void main(String[] args) throws IOException { if (args.length > 0) { - configFile = args[0]; + configFile = args[0]; log.info("first argument (config file): "+ configFile); } else { @@ -70,10 +70,10 @@ private void run() { Controler controler = new Controler(configFile); TollHandler tollHandler = new TollHandler(controler.getScenario()); - + final CongestionTollTimeDistanceTravelDisutilityFactory tollDisutilityCalculatorFactory = new CongestionTollTimeDistanceTravelDisutilityFactory( new RandomizingTimeDistanceTravelDisutilityFactory(TransportMode.car, controler.getConfig()), - tollHandler, controler.getConfig().planCalcScore()); + tollHandler, controler.getConfig().scoring()); controler.addOverridingModule(new AbstractModule() { @Override public void install() { @@ -86,7 +86,7 @@ public void install() { controler.addControlerListener(new MarginalCongestionPricingContolerListener(controler.getScenario(), tollHandler, new CongestionHandlerImplV3(controler.getEvents(), controler.getScenario()))); controler.addOverridingModule(new OTFVisFileWriterModule()); - controler.getConfig().controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles); + controler.getConfig().controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles); controler.run(); } diff --git a/contribs/vsp/src/main/java/playground/vsp/congestion/analysis/CongestionAnalysisEventHandler.java b/contribs/vsp/src/main/java/playground/vsp/congestion/analysis/CongestionAnalysisEventHandler.java index f5eba3c57a6..0bd39d2ca33 100644 --- a/contribs/vsp/src/main/java/playground/vsp/congestion/analysis/CongestionAnalysisEventHandler.java +++ b/contribs/vsp/src/main/java/playground/vsp/congestion/analysis/CongestionAnalysisEventHandler.java @@ -19,7 +19,7 @@ * *********************************************************************** */ /** - * + * */ package playground.vsp.congestion.analysis; @@ -55,39 +55,39 @@ import playground.vsp.congestion.handlers.CongestionEventHandler; /** - * + * * @author ikaddoura , lkroeger * */ public class CongestionAnalysisEventHandler implements PersonMoneyEventHandler, TransitDriverStartsEventHandler , ActivityEndEventHandler , PersonDepartureEventHandler , LinkEnterEventHandler, PersonEntersVehicleEventHandler , PersonLeavesVehicleEventHandler , CongestionEventHandler { private final static Logger log = LogManager.getLogger(CongestionAnalysisEventHandler.class); private final double vtts_car; - + // This analysis uses either money events or congestion events. private final boolean useMoneyEvents; - + private Map,Integer> personId2actualTripNumber = new HashMap, Integer>(); private Map,Map> personId2tripNumber2legMode = new HashMap,Map>(); - + private Map,Map> personId2tripNumber2departureTime = new HashMap, Map>(); private Map,Map> personId2tripNumber2tripDistance = new HashMap, Map>(); private Map,Map> personId2tripNumber2amount = new HashMap, Map>(); private Map,Double> driverId2totalDistance = new HashMap,Double>(); - + private Map, Double> causingAgentId2amountSum = new HashMap , Double>(); private Map, Double> affectedAgentId2amountSum = new HashMap , Double>(); private Set> persons = new HashSet>(); - + // for pt-distance calculation private Map,Double> personId2distanceEnterValue = new HashMap,Double>(); - + private List> ptDrivers = new ArrayList>(); private Scenario scenario; - + private double distance = 500.; // TODO: set dynamically! private double maxDistance = 40 * distance; // TODO: set dynamically! private double timeBinSize = 900.0; // TODO: set dynamically! - + public CongestionAnalysisEventHandler(Scenario scenario, boolean useMoneyEvents) { this.scenario = scenario; this.useMoneyEvents = useMoneyEvents; @@ -95,7 +95,7 @@ public CongestionAnalysisEventHandler(Scenario scenario, boolean useMoneyEvents) if (useMoneyEvents) { log.warn("Money events may be thrown later than the congestion events... May result in a wrong interpretation of the results. Better use directly the congestion events for analysis."); } - this.vtts_car = (this.scenario.getConfig().planCalcScore().getModes().get(TransportMode.car).getMarginalUtilityOfTraveling() - this.scenario.getConfig().planCalcScore().getPerforming_utils_hr()) / this.scenario.getConfig().planCalcScore().getMarginalUtilityOfMoney(); + this.vtts_car = (this.scenario.getConfig().scoring().getModes().get(TransportMode.car).getMarginalUtilityOfTraveling() - this.scenario.getConfig().scoring().getPerforming_utils_hr()) / this.scenario.getConfig().scoring().getMarginalUtilityOfMoney(); log.info("Anlayzing the congestion events during the simulation. Assuming the following VTTS (equal for all agents): " + vtts_car); } @@ -116,16 +116,16 @@ public void reset(int iteration) { @Override public void handleEvent(CongestionEvent event) { - + if (useMoneyEvents == false){ - + // trip-based analysis double amount = event.getDelay() / 3600 * this.vtts_car; double emergenceTime = event.getEmergenceTime(); int tripNumber = 0; double maxDepTime = 0.; Map tripNumber2departureTime = personId2tripNumber2departureTime.get(event.getCausingAgentId()); - + for(int tripNr : tripNumber2departureTime.keySet()) { if(emergenceTime >= tripNumber2departureTime.get(tripNr)) { if (tripNumber2departureTime.get(tripNr) >= maxDepTime) { @@ -133,13 +133,13 @@ public void handleEvent(CongestionEvent event) { } } } - + double amountBefore = personId2tripNumber2amount.get(event.getCausingAgentId()).get(tripNumber); double updatedAmount = amountBefore + amount; Map tripNumber2amount = personId2tripNumber2amount.get(event.getCausingAgentId()); tripNumber2amount.put(tripNumber, updatedAmount); personId2tripNumber2amount.put(event.getCausingAgentId(), tripNumber2amount); - + // person-based analysis - causing agent if (this.causingAgentId2amountSum.get(event.getCausingAgentId()) == null) { this.causingAgentId2amountSum.put(event.getCausingAgentId(), amount); @@ -148,7 +148,7 @@ public void handleEvent(CongestionEvent event) { double amountNew = amountSoFar + amount; this.causingAgentId2amountSum.put(event.getCausingAgentId(), amountNew); } - + // person-based analysis - affected agent if (this.affectedAgentId2amountSum.get(event.getAffectedAgentId()) == null) { this.affectedAgentId2amountSum.put(event.getAffectedAgentId(), amount); @@ -159,19 +159,19 @@ public void handleEvent(CongestionEvent event) { } } } - + @Override public void handleEvent(PersonMoneyEvent event) { - + if (useMoneyEvents == true) { - + // trip-based analysis double amount = event.getAmount(); double eventTime = event.getTime(); int tripNumber = 0; double maxDepTime = 0.; Map tripNumber2departureTime = personId2tripNumber2departureTime.get(event.getPersonId()); - + for(int tripNr : tripNumber2departureTime.keySet()) { if(eventTime >= tripNumber2departureTime.get(tripNr)) { if (tripNumber2departureTime.get(tripNr) >= maxDepTime) { @@ -179,13 +179,13 @@ public void handleEvent(PersonMoneyEvent event) { } } } - + double amountBefore = personId2tripNumber2amount.get(event.getPersonId()).get(tripNumber); double updatedAmount = amountBefore + amount; Map tripNumber2amount = personId2tripNumber2amount.get(event.getPersonId()); tripNumber2amount.put(tripNumber, updatedAmount); personId2tripNumber2amount.put(event.getPersonId(), tripNumber2amount); - + // person-based analysis - causing agent if (this.causingAgentId2amountSum.get(event.getPersonId()) == null) { this.causingAgentId2amountSum.put(event.getPersonId(), amount); @@ -194,10 +194,10 @@ public void handleEvent(PersonMoneyEvent event) { double amountNew = amountSoFar + amount; this.causingAgentId2amountSum.put(event.getPersonId(), amountNew); } - + } } - + @Override public void handleEvent(LinkEnterEvent event) { double linkLength = this.scenario.getNetwork().getLinks().get(event.getLinkId()).getLength(); @@ -217,9 +217,9 @@ public void handleEvent(LinkEnterEvent event) { personId2tripNumber2tripDistance.put(Id.createPersonId(event.getVehicleId()), tripNumber2tripDistance); } } - + // // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - + public Map,List> getPersonId2listOfDepartureTimes(String mode) { Map,List> personId2listOfDepartureTimes = new HashMap, List>(); for(Id personId: personId2tripNumber2departureTime.keySet()){ @@ -235,7 +235,7 @@ public Map,List> getPersonId2listOfDepartureTimes(String mode } return personId2listOfDepartureTimes; } - + public Map,List> getPersonId2listOfDistances(String mode) { Map,List> personId2listOfDistances = new HashMap, List>(); for(Id personId: personId2tripNumber2tripDistance.keySet()){ @@ -251,7 +251,7 @@ public Map,List> getPersonId2listOfDistances(String mode) { } return personId2listOfDistances; } - + public Map,List> getPersonId2listOfAmounts(String mode) { Map,List> personId2listOfAmounts = new HashMap, List>(); for(Id personId: personId2tripNumber2amount.keySet()){ @@ -267,7 +267,7 @@ public Map,List> getPersonId2listOfAmounts(String mode) { } return personId2listOfAmounts; } - + public Map getAvgAmountPerTripDepartureTime(String mode) { Map tripDepTime2avgFare = new HashMap(); @@ -275,15 +275,15 @@ public Map getAvgAmountPerTripDepartureTime(String mode) { double startTime = this.timeBinSize; double periodLength = this.timeBinSize; double endTime = 30. * 3600; - + for (double time = startTime; time <= endTime; time = time + periodLength){ List fares = new ArrayList(); tripDepTime2fares.put(time, fares); } - + Map counter2allDepartureTimesAndAmounts = new HashMap(); int i = 0; - + for(Id personId : personId2tripNumber2departureTime.keySet()){ for(int tripNumber : personId2tripNumber2departureTime.get(personId).keySet()){ if(personId2tripNumber2legMode.get(personId).get(tripNumber).toString().equals(mode)){ @@ -291,14 +291,14 @@ public Map getAvgAmountPerTripDepartureTime(String mode) { double belongingAmount = personId2tripNumber2amount.get(personId).get(tripNumber); double[] departureTimeAndAmount = new double[2]; departureTimeAndAmount[0] = departureTime; - departureTimeAndAmount[1] = belongingAmount; + departureTimeAndAmount[1] = belongingAmount; counter2allDepartureTimesAndAmounts.put(i, departureTimeAndAmount); i++; }else{ } } } - + for (Double time : tripDepTime2fares.keySet()){ for (int counter : counter2allDepartureTimesAndAmounts.keySet()){ if (counter2allDepartureTimesAndAmounts.get(counter)[0] < time && counter2allDepartureTimesAndAmounts.get(counter)[0] >= (time - periodLength)) { @@ -308,19 +308,19 @@ public Map getAvgAmountPerTripDepartureTime(String mode) { } } } - + for (Double time : tripDepTime2fares.keySet()){ double amountSum = 0.; double counter = 0.; for (Double amount : tripDepTime2fares.get(time)){ if (amount == null){ - + } else { amountSum = amountSum + amount; counter++; } } - + double avgFare = 0.; if (counter!=0.){ avgFare = (-1) * amountSum / counter; @@ -329,7 +329,7 @@ public Map getAvgAmountPerTripDepartureTime(String mode) { } return tripDepTime2avgFare; } - + public Map getAvgAmountPerTripDistance(String mode) { Map tripDistance2avgAmount = new HashMap(); @@ -337,15 +337,15 @@ public Map getAvgAmountPerTripDistance(String mode) { double startDistance = this.distance; double groupsize = this.distance; double endDistance = this.maxDistance; - + for (double distance = startDistance; distance <= endDistance; distance = distance + groupsize){ List amounts = new ArrayList(); tripDistance2amount.put(distance, amounts); } - + Map counter2allDistancesAndAmounts = new HashMap(); int i = 0; - + for(Id personId : personId2tripNumber2tripDistance.keySet()){ for(int tripNumber : personId2tripNumber2tripDistance.get(personId).keySet()){ if(personId2tripNumber2legMode.get(personId).get(tripNumber).toString().equals(mode)){ @@ -353,13 +353,13 @@ public Map getAvgAmountPerTripDistance(String mode) { double belongingAmount = personId2tripNumber2amount.get(personId).get(tripNumber); double[] tripDistanceAndAmount = new double[2]; tripDistanceAndAmount[0] = tripDistance; - tripDistanceAndAmount[1] = belongingAmount; + tripDistanceAndAmount[1] = belongingAmount; counter2allDistancesAndAmounts.put(i, tripDistanceAndAmount); i++; } } } - + for (Double dist : tripDistance2amount.keySet()){ for (int counter : counter2allDistancesAndAmounts.keySet()){ if (counter2allDistancesAndAmounts.get(counter)[0] < dist && counter2allDistancesAndAmounts.get(counter)[0] >= (dist - groupsize)) { @@ -369,19 +369,19 @@ public Map getAvgAmountPerTripDistance(String mode) { } } } - + for (Double dist : tripDistance2amount.keySet()){ double amountSum = 0.; double counter = 0.; for (Double amount : tripDistance2amount.get(dist)){ if (amount == null){ - + } else { amountSum = amountSum + amount; counter++; } } - + double avgAmount = 0.; if (counter!=0.){ avgAmount = (-1) * amountSum / counter; @@ -393,13 +393,13 @@ public Map getAvgAmountPerTripDistance(String mode) { @Override public void handleEvent(ActivityEndEvent event) { - + if (this.persons.contains(event.getPersonId())){ // do nothing } else { this.persons.add(event.getPersonId()); } - + // A transit driver should not practice any activity, // otherwise the code has to be adapted here. if(ptDrivers.contains(event.getPersonId())){ @@ -417,11 +417,11 @@ public void handleEvent(ActivityEndEvent event) { Map tripNumber2tripDistance = personId2tripNumber2tripDistance.get(event.getPersonId()); tripNumber2tripDistance.put(personId2actualTripNumber.get(event.getPersonId()), 0.0); personId2tripNumber2tripDistance.put(event.getPersonId(), tripNumber2tripDistance); - + Map tripNumber2amount = personId2tripNumber2amount.get(event.getPersonId()); tripNumber2amount.put(personId2actualTripNumber.get(event.getPersonId()), 0.0); personId2tripNumber2amount.put(event.getPersonId(), tripNumber2amount); - + } else { // The trip which starts immediately is the first trip of the person personId2actualTripNumber.put(event.getPersonId(), 1); @@ -431,14 +431,14 @@ public void handleEvent(ActivityEndEvent event) { Map tripNumber2tripDistance = new HashMap(); tripNumber2tripDistance.put(1, 0.0); personId2tripNumber2tripDistance.put(event.getPersonId(), tripNumber2tripDistance); - + Map tripNumber2amount = new HashMap(); tripNumber2amount.put(1, 0.0); personId2tripNumber2amount.put(event.getPersonId(), tripNumber2amount); } - } + } } - + @Override public void handleEvent(PersonDepartureEvent event) { if(ptDrivers.contains(event.getPersonId())){ @@ -452,7 +452,7 @@ public void handleEvent(PersonDepartureEvent event) { Map tripNumber2legMode = personId2tripNumber2legMode.get(event.getPersonId()); if(tripNumber2legMode.containsKey(tripNumber)){ // legMode already listed, possible for pt trips - if(tripNumber2legMode.get(tripNumber).toString().equals("pt")){ + if(tripNumber2legMode.get(tripNumber).toString().equals("pt")){ } else{ throw new RuntimeException("A leg mode has already been listed."); } @@ -479,7 +479,7 @@ public void handleEvent(PersonDepartureEvent event) { } } } - + @Override public void handleEvent(TransitDriverStartsEvent event) { if (ptDrivers.contains(event.getDriverId())) { @@ -489,7 +489,7 @@ public void handleEvent(TransitDriverStartsEvent event) { driverId2totalDistance.put(Id.createPersonId(event.getVehicleId()),0.0); } } - + @Override public void handleEvent(PersonLeavesVehicleEvent event) { if(ptDrivers.contains(event.getPersonId())){ @@ -500,11 +500,11 @@ public void handleEvent(PersonLeavesVehicleEvent event) { if((tripNumber2legMode.get(tripNumber)).equals(TransportMode.car)){ // car drivers not considered here } else { - double distanceTravelled = (driverId2totalDistance.get(event.getVehicleId()) - personId2distanceEnterValue.get(event.getPersonId())); - + double distanceTravelled = (driverId2totalDistance.get(event.getVehicleId()) - personId2distanceEnterValue.get(event.getPersonId())); + Map tripNumber2distance = personId2tripNumber2tripDistance.get(event.getPersonId()); tripNumber2distance.put(tripNumber, tripNumber2distance.get(tripNumber) + distanceTravelled); - + personId2distanceEnterValue.remove(event.getPersonId()); } } @@ -528,14 +528,14 @@ public void handleEvent(PersonEntersVehicleEvent event) { public Map, Double> getCausingAgentId2amountSum() { return causingAgentId2amountSum; } - + public Map, Double> getAffectedAgentId2amountSum() { return affectedAgentId2amountSum; } public Map, Double> getCausingAgentId2amountSumAllAgents() { Map, Double> personId2amountSumAllAgents = new HashMap, Double>(); - + List> personIds = new ArrayList>(); if (this.scenario.getPopulation().getPersons().isEmpty()) { log.warn("Scenario does not contain a Population. Using the person IDs from the events file for the person-based analysis (total: " + personIds.size() +")."); @@ -544,7 +544,7 @@ public Map, Double> getCausingAgentId2amountSumAllAgents() { log.info("Scenario contains a Population. Using the person IDs from the population for the person-based analysis."); personIds.addAll(this.scenario.getPopulation().getPersons().keySet()); } - + for (Id id : personIds) { double amountSum = 0.; if (this.causingAgentId2amountSum.get(id) == null) { @@ -556,13 +556,13 @@ public Map, Double> getCausingAgentId2amountSumAllAgents() { } return personId2amountSumAllAgents; } - + public Map, Double> getAffectedAgentId2amountSumAllAgents() { Map, Double> personId2amountSumAllAgents = new HashMap, Double>(); - + if (this.affectedAgentId2amountSum.isEmpty()) { - log.warn("There is no info re the affected agents. This info is only avalable when analyzing congestion events and not the money events."); - + log.warn("There is no info re the affected agents. This info is only avalable when analyzing congestion events and not the money events."); + } else { List> personIds = new ArrayList>(); if (this.scenario.getPopulation().getPersons().isEmpty()) { @@ -572,7 +572,7 @@ public Map, Double> getAffectedAgentId2amountSumAllAgents() { log.info("Scenario contains a Population. Using the person IDs from the population for the person-based analysis."); personIds.addAll(this.scenario.getPopulation().getPersons().keySet()); } - + for (Id id : personIds) { double amountSum = 0.; if (this.affectedAgentId2amountSum.get(id) == null) { diff --git a/contribs/vsp/src/main/java/playground/vsp/congestion/analysis/CongestionEventsWriter.java b/contribs/vsp/src/main/java/playground/vsp/congestion/analysis/CongestionEventsWriter.java index 993816f4cea..8c2d421ab91 100644 --- a/contribs/vsp/src/main/java/playground/vsp/congestion/analysis/CongestionEventsWriter.java +++ b/contribs/vsp/src/main/java/playground/vsp/congestion/analysis/CongestionEventsWriter.java @@ -38,63 +38,63 @@ /** * (1) Computes marginal congestion events based on a standard events file. * (2) Computes agent money events based on these marginal congestion events. - * + * * @author ikaddoura * */ public class CongestionEventsWriter { private static final Logger log = LogManager.getLogger(CongestionEventsWriter.class); - + static String runDirectory; - + public static void main(String[] args) { - + if (args.length > 0) { - - runDirectory = args[0]; + + runDirectory = args[0]; log.info("runDirectory: " + runDirectory); - + } else { runDirectory = "../../runs-svn/berlin_internalizationCar2/output/baseCase_2/"; } - + CongestionEventsWriter congestionEventsWriter = new CongestionEventsWriter(); congestionEventsWriter.run(); } private void run() { - + log.info("Loading scenario..."); Config config = ConfigUtils.loadConfig(runDirectory + "output_config.xml.gz"); config.network().setInputFile(runDirectory + "output_network.xml.gz"); config.plans().setInputFile(runDirectory + "output_plans.xml.gz"); MutableScenario scenario = (MutableScenario) ScenarioUtils.loadScenario(config); log.info("Loading scenario... Done."); - - String outputDirectory = runDirectory + "analysis_it." + config.controler().getLastIteration() + "/"; + + String outputDirectory = runDirectory + "analysis_it." + config.controller().getLastIteration() + "/"; File file = new File(outputDirectory); file.mkdirs(); - + EventsManager events = EventsUtils.createEventsManager(); - - EventWriterXML eventWriter = new EventWriterXML(outputDirectory + config.controler().getLastIteration() + ".events_ExternalCongestionCost_Offline.xml.gz"); + + EventWriterXML eventWriter = new EventWriterXML(outputDirectory + config.controller().getLastIteration() + ".events_ExternalCongestionCost_Offline.xml.gz"); CongestionHandlerImplV3 congestionHandler = new CongestionHandlerImplV3(events, scenario); MarginalCongestionPricingHandler marginalCostTollHandler = new MarginalCongestionPricingHandler(events, scenario); - + events.addHandler(eventWriter); events.addHandler(congestionHandler); events.addHandler(marginalCostTollHandler); - + log.info("Reading events file..."); MatsimEventsReader reader = new MatsimEventsReader(events); - reader.readFile(runDirectory + "ITERS/it." + config.controler().getLastIteration() + "/" + config.controler().getLastIteration() + ".events.xml.gz"); + reader.readFile(runDirectory + "ITERS/it." + config.controller().getLastIteration() + "/" + config.controller().getLastIteration() + ".events.xml.gz"); log.info("Reading events file... Done."); eventWriter.closeFile(); - - congestionHandler.writeCongestionStats(outputDirectory + config.controler().getLastIteration() + ".congestionStats_Offline.csv"); + + congestionHandler.writeCongestionStats(outputDirectory + config.controller().getLastIteration() + ".congestionStats_Offline.csv"); } - + } - + diff --git a/contribs/vsp/src/main/java/playground/vsp/congestion/controler/AdvancedMarginalCongestionPricingContolerListener.java b/contribs/vsp/src/main/java/playground/vsp/congestion/controler/AdvancedMarginalCongestionPricingContolerListener.java index 2641fd649e1..d940473e97b 100644 --- a/contribs/vsp/src/main/java/playground/vsp/congestion/controler/AdvancedMarginalCongestionPricingContolerListener.java +++ b/contribs/vsp/src/main/java/playground/vsp/congestion/controler/AdvancedMarginalCongestionPricingContolerListener.java @@ -19,7 +19,7 @@ * *********************************************************************** */ /** - * + * */ package playground.vsp.congestion.controler; @@ -50,60 +50,60 @@ public class AdvancedMarginalCongestionPricingContolerListener implements Startu private final Scenario scenario; private TollHandler tollHandler; private EventHandler congestionHandler; - + private double factor = 1.0; private AdvancedMarginalCongestionPricingHandler pricingHandler; - + /** * @param scenario * @param tollHandler - * @param handler must be one of the implementation for congestion pricing + * @param handler must be one of the implementation for congestion pricing */ public AdvancedMarginalCongestionPricingContolerListener(Scenario scenario, TollHandler tollHandler, EventHandler congestionHandler){ this(scenario, tollHandler, congestionHandler, 1.0); } - + public AdvancedMarginalCongestionPricingContolerListener(Scenario scenario, TollHandler tollHandler, EventHandler congestionHandler, double factor){ this.scenario = scenario; this.tollHandler = tollHandler; this.congestionHandler = congestionHandler; this.factor = factor; } - + @Override public void notifyStartup(StartupEvent event) { - + EventsManager eventsManager = event.getServices().getEvents(); - + this.pricingHandler = new AdvancedMarginalCongestionPricingHandler(eventsManager, this.scenario, this.factor); - + eventsManager.addHandler(this.congestionHandler); eventsManager.addHandler(this.pricingHandler); eventsManager.addHandler(this.tollHandler); } - + @Override public void notifyAfterMobsim(AfterMobsimEvent event) { log.info("Monetize final congestion events..."); this.pricingHandler.processFinalCongestionEvents(); log.info("Total monetized amount: " + this.pricingHandler.getAmountSum()); log.info("Monetize final congestion events... Done."); - + log.info("Writing out VTTS statistics..."); - this.pricingHandler.printVTTS(this.scenario.getConfig().controler().getOutputDirectory() + "/ITERS/it." + event.getIteration() + "/VTTS_forAllDelayedTrips.csv"); - this.pricingHandler.printAvgVTTSperPerson(this.scenario.getConfig().controler().getOutputDirectory() + "/ITERS/it." + event.getIteration() + "/VTTS_AvgPerPerson_forAllDelayedTrips.csv"); + this.pricingHandler.printVTTS(this.scenario.getConfig().controller().getOutputDirectory() + "/ITERS/it." + event.getIteration() + "/VTTS_forAllDelayedTrips.csv"); + this.pricingHandler.printAvgVTTSperPerson(this.scenario.getConfig().controller().getOutputDirectory() + "/ITERS/it." + event.getIteration() + "/VTTS_AvgPerPerson_forAllDelayedTrips.csv"); log.info("Writing out VTTS statistics... Done."); } @Override public void notifyIterationEnds(IterationEndsEvent event) { - + log.info("Set average tolls for each link Id and time bin..."); this.tollHandler.setLinkId2timeBin2avgToll(); log.info("Set average tolls for each link Id and time bin... Done."); - + // write out analysis every iteration - this.tollHandler.writeTollStats(this.scenario.getConfig().controler().getOutputDirectory() + "/ITERS/it." + event.getIteration() + "/tollStats.csv"); + this.tollHandler.writeTollStats(this.scenario.getConfig().controller().getOutputDirectory() + "/ITERS/it." + event.getIteration() + "/tollStats.csv"); } } diff --git a/contribs/vsp/src/main/java/playground/vsp/congestion/controler/AverageCongestionPricingControlerListener.java b/contribs/vsp/src/main/java/playground/vsp/congestion/controler/AverageCongestionPricingControlerListener.java index 3a0be7bf7f6..6b62c0bdd73 100644 --- a/contribs/vsp/src/main/java/playground/vsp/congestion/controler/AverageCongestionPricingControlerListener.java +++ b/contribs/vsp/src/main/java/playground/vsp/congestion/controler/AverageCongestionPricingControlerListener.java @@ -19,7 +19,7 @@ * *********************************************************************** */ /** - * + * */ package playground.vsp.congestion.controler; @@ -50,18 +50,18 @@ public class AverageCongestionPricingControlerListener implements StartupListene private final MutableScenario scenario; private TollHandler tollHandler; private CongestionHandlerImplV3 congestionHandler; - + public AverageCongestionPricingControlerListener(MutableScenario scenario, TollHandler tollHandler){ this.scenario = scenario; this.tollHandler = tollHandler; } - + @Override public void notifyStartup(StartupEvent event) { - + EventsManager eventsManager = event.getServices().getEvents(); congestionHandler = new CongestionHandlerImplV3(eventsManager, scenario); - + event.getServices().getEvents().addHandler(congestionHandler); event.getServices().getEvents().addHandler(tollHandler); @@ -69,19 +69,19 @@ public void notifyStartup(StartupEvent event) { @Override public void notifyAfterMobsim(AfterMobsimEvent event) { - + log.info("Set average tolls for each link Id and time bin."); tollHandler.setLinkId2timeBin2avgToll(); - + // write out toll statistics every iteration - tollHandler.writeTollStats(this.scenario.getConfig().controler().getOutputDirectory() + "/ITERS/it." + event.getIteration() + "/tollStats.csv"); - + tollHandler.writeTollStats(this.scenario.getConfig().controller().getOutputDirectory() + "/ITERS/it." + event.getIteration() + "/tollStats.csv"); + // write out congestion statistics every iteration - congestionHandler.writeCongestionStats(this.scenario.getConfig().controler().getOutputDirectory() + "/ITERS/it." + event.getIteration() + "/congestionStats.csv"); - + congestionHandler.writeCongestionStats(this.scenario.getConfig().controller().getOutputDirectory() + "/ITERS/it." + event.getIteration() + "/congestionStats.csv"); + log.info("Throwing agent money events based on calculated average marginal cost for each link and time bin."); EventsManager events = event.getServices().getEvents(); - + for (LinkEnterEvent enterEvent : this.tollHandler.getLinkEnterEvents()) { double amount = tollHandler.getAvgToll(enterEvent.getLinkId(), enterEvent.getTime()); PersonMoneyEvent moneyEvent = new PersonMoneyEvent(enterEvent.getTime(), Id.createPersonId(enterEvent.getVehicleId()), amount, "congestionPricing", null); diff --git a/contribs/vsp/src/main/java/playground/vsp/congestion/controler/MarginalCongestionPricingContolerListener.java b/contribs/vsp/src/main/java/playground/vsp/congestion/controler/MarginalCongestionPricingContolerListener.java index d43dfcf26ec..7926459c53f 100644 --- a/contribs/vsp/src/main/java/playground/vsp/congestion/controler/MarginalCongestionPricingContolerListener.java +++ b/contribs/vsp/src/main/java/playground/vsp/congestion/controler/MarginalCongestionPricingContolerListener.java @@ -19,7 +19,7 @@ * *********************************************************************** */ /** - * + * */ package playground.vsp.congestion.controler; @@ -51,30 +51,30 @@ public class MarginalCongestionPricingContolerListener implements StartupListene private double factor = 1.0; private MarginalCongestionPricingHandler pricingHandler; - + /** * @param scenario * @param tollHandler - * @param handler must be one of the implementation for congestion pricing + * @param handler must be one of the implementation for congestion pricing */ public MarginalCongestionPricingContolerListener(Scenario scenario, TollHandler tollHandler, EventHandler congestionHandler){ this (scenario, tollHandler, congestionHandler, 1.0); } - + public MarginalCongestionPricingContolerListener(Scenario scenario, TollHandler tollHandler, EventHandler congestionHandler, double factor){ this.scenario = scenario; this.tollHandler = tollHandler; this.congestionHandler = congestionHandler; this.factor = factor; } - + @Override public void notifyStartup(StartupEvent event) { - + EventsManager eventsManager = event.getServices().getEvents(); - + this.pricingHandler = new MarginalCongestionPricingHandler(eventsManager, this.scenario, this.factor); - + eventsManager.addHandler(this.congestionHandler); eventsManager.addHandler(this.pricingHandler); eventsManager.addHandler(this.tollHandler); @@ -82,13 +82,13 @@ public void notifyStartup(StartupEvent event) { @Override public void notifyIterationEnds(IterationEndsEvent event) { - + this.log.info("Set average tolls for each link Id and time bin..."); this.tollHandler.setLinkId2timeBin2avgToll(); this.log.info("Set average tolls for each link Id and time bin... Done."); - + // write out analysis every iteration - this.tollHandler.writeTollStats(this.scenario.getConfig().controler().getOutputDirectory() + "/ITERS/it." + event.getIteration() + "/tollStats.csv"); + this.tollHandler.writeTollStats(this.scenario.getConfig().controller().getOutputDirectory() + "/ITERS/it." + event.getIteration() + "/tollStats.csv"); } } diff --git a/contribs/vsp/src/main/java/playground/vsp/congestion/handlers/AdvancedMarginalCongestionPricingHandler.java b/contribs/vsp/src/main/java/playground/vsp/congestion/handlers/AdvancedMarginalCongestionPricingHandler.java index 639cba9d587..e5a56c9ddfc 100644 --- a/contribs/vsp/src/main/java/playground/vsp/congestion/handlers/AdvancedMarginalCongestionPricingHandler.java +++ b/contribs/vsp/src/main/java/playground/vsp/congestion/handlers/AdvancedMarginalCongestionPricingHandler.java @@ -18,7 +18,7 @@ * *********************************************************************** */ /** - * + * */ package playground.vsp.congestion.handlers; @@ -56,7 +56,7 @@ * This handler calculates agent money events based on marginal congestion events. * The causing agent has to pay a toll depending on the number of affected agents and the external delay in sec. * The delay is monetized using the behavioral parameters from the scenario and taking into account the agent-specific Value of Travel Time Savings (VTTS) - * + * * @author ikaddoura * */ @@ -65,47 +65,47 @@ public class AdvancedMarginalCongestionPricingHandler implements CongestionEvent private final static Logger log = LogManager.getLogger(AdvancedMarginalCongestionPricingHandler.class); private static int incompletedPlanWarning = 0; - + private final Scenario scenario; private final EventsManager events; - + private double factor = 1.0; - + private double amountSum = 0.; - + private Map, Double> affectedPersonId2delayToProcess = new HashMap, Double>(); private Map, List> affectedPersonId2congestionEventsToProcess = new HashMap<>(); private Map, Double> personId2currentActivityStartTime = new HashMap, Double>(); private Map, Double> personId2firstActivityEndTime = new HashMap, Double>(); private Map, String> personId2currentActivityType = new HashMap, String>(); private Map, String> personId2firstActivityType = new HashMap, String>(); - + private Map, List> personId2VTTSh = new HashMap<>(); private MarginalSumScoringFunction marginaSumScoringFunction; - + public AdvancedMarginalCongestionPricingHandler(EventsManager eventsManager, Scenario scenario) { this(eventsManager, scenario, 1.0); } - + public AdvancedMarginalCongestionPricingHandler(EventsManager eventsManager, Scenario scenario, double factor) { log.info("Using the toll factor " + factor); log.info("Using different VTTS to translate delays into monetary units. Computing the actual activity delay costs for each agent."); - + this.events = eventsManager; this.scenario = scenario; this.factor = factor; - + this.marginaSumScoringFunction = new MarginalSumScoringFunction( - new ScoringParameters.Builder(scenario.getConfig().planCalcScore(), scenario.getConfig().planCalcScore().getScoringParameters(null), scenario.getConfig().scenario()).build()); + new ScoringParameters.Builder(scenario.getConfig().scoring(), scenario.getConfig().scoring().getScoringParameters(null), scenario.getConfig().scenario()).build()); } @Override public void reset(int iteration) { - + incompletedPlanWarning = 0; - + this.amountSum = 0.; this.personId2currentActivityStartTime.clear(); this.affectedPersonId2congestionEventsToProcess.clear(); @@ -113,13 +113,13 @@ public void reset(int iteration) { this.personId2currentActivityType.clear(); this.personId2firstActivityType.clear(); this.affectedPersonId2delayToProcess.clear(); - + this.personId2VTTSh.clear(); } @Override public void handleEvent(CongestionEvent event) { - + // store the congestion event if (affectedPersonId2congestionEventsToProcess.containsKey(event.getAffectedAgentId())) { affectedPersonId2congestionEventsToProcess.get(event.getAffectedAgentId()).add(event); @@ -127,8 +127,8 @@ public void handleEvent(CongestionEvent event) { List congestionEventsToProcess = new ArrayList<>(); congestionEventsToProcess.add(event); affectedPersonId2congestionEventsToProcess.put(event.getAffectedAgentId(), congestionEventsToProcess); - } - + } + // compute the total trip delay if (this.affectedPersonId2delayToProcess.containsKey(event.getAffectedAgentId())) { double delayUpdated = affectedPersonId2delayToProcess.get(event.getAffectedAgentId()) + event.getDelay(); @@ -136,12 +136,12 @@ public void handleEvent(CongestionEvent event) { } else { affectedPersonId2delayToProcess.put(event.getAffectedAgentId(), event.getDelay()); } - + } - + @Override public void handleEvent(ActivityStartEvent event) { - + if (event.getActType().contains("interaction")) { // skip } else { @@ -152,24 +152,24 @@ public void handleEvent(ActivityStartEvent event) { @Override public void handleEvent(ActivityEndEvent event) { - + if (event.getActType().contains("interaction")) { // skip } else { if (this.personId2currentActivityStartTime.containsKey(event.getPersonId())) { // This is not the first activity... - + // ... now process all congestion events thrown during the trip to the activity which has just ended, ... processCongestionEventsForAffectedPerson(event.getPersonId(), event.getTime(), event.getLinkId()); - + // ... update the status of the 'current' activity... this.personId2currentActivityType.remove(event.getPersonId()); this.personId2currentActivityStartTime.remove(event.getPersonId()); - - // ... and remove all processed congestion events. + + // ... and remove all processed congestion events. this.affectedPersonId2congestionEventsToProcess.remove(event.getPersonId()); this.affectedPersonId2delayToProcess.remove(event.getPersonId()); - + } else { // This is the first activity. The first and last / overnight activity are / is considered in a final step. // Therefore, the relevant information has to be stored. @@ -189,69 +189,69 @@ public void processFinalCongestionEvents() { processCongestionEventsForAffectedPerson(affectedPersonId, FINAL_CONGESTION_EVENT_TIME, null);// } } - + private void processCongestionEventsForAffectedPerson(Id personId, double activityEndTime, Id linkId) { - + // First, compute the agent's total (affected) delay from the previous trip. double totalDelayThisPerson = 0.0; if (this.affectedPersonId2delayToProcess.containsKey(personId)) { totalDelayThisPerson = this.affectedPersonId2delayToProcess.get(personId); } - + if (totalDelayThisPerson > 0.) { // The agent was delayed on the previous trip... - // ... now calculate the agent's disutility from being late at the current activity: score(arrivalTime_ohneDelay) - score(arrivalTime_withDelay) + // ... now calculate the agent's disutility from being late at the current activity: score(arrivalTime_ohneDelay) - score(arrivalTime_withDelay) double activityDelayDisutility = 0.; - + // First, check if the plan completed is completed, i.e. if the agent has arrived at an activity (after being delayed) if (this.personId2currentActivityType.containsKey(personId) && this.personId2currentActivityStartTime.containsKey(personId)) { // Yes, the plan seems to be completed. - + if (activityEndTime == FINAL_CONGESTION_EVENT_TIME) { // The end time is undefined... - + // ... now handle the first and last OR overnight activity. This is figured out by the scoring function itself (depending on the activity types). - + Activity activityMorning = PopulationUtils.createActivityFromLinkId(this.personId2firstActivityType.get(personId), linkId); activityMorning.setEndTime(this.personId2firstActivityEndTime.get(personId)); - + Activity activityEvening = PopulationUtils.createActivityFromLinkId(this.personId2currentActivityType.get(personId), linkId); activityEvening.setStartTime(this.personId2currentActivityStartTime.get(personId)); - + activityDelayDisutility = marginaSumScoringFunction.getOvernightActivityDelayDisutility(activityMorning, activityEvening, totalDelayThisPerson); - + } else { // The activity has an end time indicating a 'normal' activity. - + Activity activity = PopulationUtils.createActivityFromLinkId(this.personId2currentActivityType.get(personId), linkId); activity.setStartTime(this.personId2currentActivityStartTime.get(personId)); - activity.setEndTime(activityEndTime); + activity.setEndTime(activityEndTime); activityDelayDisutility = marginaSumScoringFunction.getNormalActivityDelayDisutility(activity, totalDelayThisPerson); } - + } else { // No, there is no information about the current activity which indicates that the trip (with the delay) was not completed. - + if (incompletedPlanWarning <= 10) { log.warn("Agent " + personId + " has not yet completed the plan/trip (the agent is probably stucking). Cannot compute the disutility of being late at this activity. " + "Something like the disutility of not arriving at the activity is required. Try to avoid this by setting a smaller stuck time period."); - log.warn("Setting the disutilty of being delayed on the previous trip using the config parameters; assuming the marginal disutility of being delayed at the (hypothetical) activity to be equal to beta_performing: " + this.scenario.getConfig().planCalcScore().getPerforming_utils_hr()); - + log.warn("Setting the disutilty of being delayed on the previous trip using the config parameters; assuming the marginal disutility of being delayed at the (hypothetical) activity to be equal to beta_performing: " + this.scenario.getConfig().scoring().getPerforming_utils_hr()); + if (incompletedPlanWarning == 10) { log.warn("Additional warnings of this type are suppressed."); } incompletedPlanWarning++; } - activityDelayDisutility = (totalDelayThisPerson / 3600.) * this.scenario.getConfig().planCalcScore().getPerforming_utils_hr(); + activityDelayDisutility = (totalDelayThisPerson / 3600.) * this.scenario.getConfig().scoring().getPerforming_utils_hr(); } - + // Calculate the agent's trip delay disutility (could be done similar to the activity delay disutility). - double tripDelayDisutility = (totalDelayThisPerson / 3600.) * this.scenario.getConfig().planCalcScore().getModes().get(TransportMode.car).getMarginalUtilityOfTraveling() * (-1); - + double tripDelayDisutility = (totalDelayThisPerson / 3600.) * this.scenario.getConfig().scoring().getModes().get(TransportMode.car).getMarginalUtilityOfTraveling() * (-1); + // Translate the disutility into monetary units. - double totalDelayCost = (activityDelayDisutility + tripDelayDisutility) / this.scenario.getConfig().planCalcScore().getMarginalUtilityOfMoney(); + double totalDelayCost = (activityDelayDisutility + tripDelayDisutility) / this.scenario.getConfig().scoring().getMarginalUtilityOfMoney(); double delayCostPerSecond = totalDelayCost / totalDelayThisPerson; - + // store the VTTS for analysis purposes if (this.personId2VTTSh.containsKey(personId)) { this.personId2VTTSh.get(personId).add(delayCostPerSecond * 3600); @@ -261,34 +261,34 @@ private void processCongestionEventsForAffectedPerson(Id personId, doubl this.personId2VTTSh.put(personId, vTTSh); } // Go through the congestion events and charge each causing agent his/her contribution to the delay cost: caused delay * activity delay cost per second + caused delay * trip delay cost per second - + for (CongestionEvent congestionEvent : this.affectedPersonId2congestionEventsToProcess.get(personId)) { - + double amount = this.factor * congestionEvent.getDelay() * delayCostPerSecond * (-1); this.amountSum = this.amountSum + amount; - + if (activityEndTime == FINAL_CONGESTION_EVENT_TIME) { activityEndTime = this.scenario.getConfig().qsim().getEndTime().seconds(); } - - PersonMoneyEvent moneyEvent = new PersonMoneyEvent(activityEndTime, congestionEvent.getCausingAgentId(), amount, "congestionPricing", null); + + PersonMoneyEvent moneyEvent = new PersonMoneyEvent(activityEndTime, congestionEvent.getCausingAgentId(), amount, "congestionPricing", null); this.events.processEvent(moneyEvent); - + PersonLinkMoneyEvent linkMoneyEvent = new PersonLinkMoneyEvent(activityEndTime, congestionEvent.getCausingAgentId(), congestionEvent.getLinkId(), amount, congestionEvent.getEmergenceTime(), "congestion"); this.events.processEvent(linkMoneyEvent); } } } - + public void printAvgVTTSperPerson(String fileName) { - + File file = new File(fileName); - + try { BufferedWriter bw = new BufferedWriter(new FileWriter(file)); bw.write("person Id;VTTS (money/hour)"); bw.newLine(); - + for (Id personId : this.personId2VTTSh.keySet()){ double vttsSum = 0.; double counter = 0; @@ -297,36 +297,36 @@ public void printAvgVTTSperPerson(String fileName) { counter++; } bw.write(personId + ";" + (vttsSum / counter) ); - bw.newLine(); + bw.newLine(); } - + bw.close(); log.info("Output written to " + fileName); - + } catch (IOException e) { e.printStackTrace(); } } - + public void printVTTS(String fileName) { - + File file = new File(fileName); - + try { BufferedWriter bw = new BufferedWriter(new FileWriter(file)); bw.write("person Id;VTTS (money/hour)"); bw.newLine(); - + for (Id personId : this.personId2VTTSh.keySet()){ for (Double vTTS : this.personId2VTTSh.get(personId)){ bw.write(personId + ";" + vTTS); - bw.newLine(); + bw.newLine(); } } - + bw.close(); log.info("Output written to " + fileName); - + } catch (IOException e) { e.printStackTrace(); } @@ -335,5 +335,5 @@ public void printVTTS(String fileName) { public double getAmountSum() { return amountSum; } - -} \ No newline at end of file + +} diff --git a/contribs/vsp/src/main/java/playground/vsp/congestion/handlers/CongestionHandlerBaseImpl.java b/contribs/vsp/src/main/java/playground/vsp/congestion/handlers/CongestionHandlerBaseImpl.java index dcd89958b88..fa9f4242055 100644 --- a/contribs/vsp/src/main/java/playground/vsp/congestion/handlers/CongestionHandlerBaseImpl.java +++ b/contribs/vsp/src/main/java/playground/vsp/congestion/handlers/CongestionHandlerBaseImpl.java @@ -18,7 +18,7 @@ * *********************************************************************** */ /** - * + * */ package playground.vsp.congestion.handlers; @@ -54,7 +54,7 @@ /** * This class provides the basic functionality to calculate congestion effects which may be used for internalization. * One of the main tasks is to keep track of the queues on each link. - * + * * @author ikaddoura * */ @@ -84,7 +84,7 @@ class CongestionHandlerBaseImpl implements CongestionHandler { log.warn("Capacity period is other than 3600."); } - if ( this.scenario.getConfig().parallelEventHandling().getNumberOfThreads()!= null) { + if ( this.scenario.getConfig().eventsManager().getNumberOfThreads()!= null) { log.warn("Parallel event handling is not tested. It should not work properly."); } @@ -103,7 +103,7 @@ public final void reset(int iteration) { this.totalDelay = 0.; this.delayNotInternalized_roundingErrors = 0.; this.totalInternalizedDelay = 0.; - + veh2DriverDelegate.reset(iteration); } @@ -127,9 +127,9 @@ public final void handleEvent( VehicleEntersTrafficEvent event ) { @Override public final void handleEvent(PersonDepartureEvent event) { if (event.getLegMode().toString().equals(TransportMode.car.toString())){ // car! - + this.carPersonIDs.add(event.getPersonId()); - + LinkCongestionInfo linkInfo = CongestionUtils.getOrCreateLinkInfo( event.getLinkId(), linkId2congestionInfo, scenario ) ; AgentOnLinkInfo agentInfo = new AgentOnLinkInfo.Builder().setAgentId( event.getPersonId() ) @@ -144,11 +144,11 @@ public final void handleEvent(PersonDepartureEvent event) { public final void handleEvent(LinkEnterEvent event) { if (this.ptVehicleIDs.contains(event.getVehicleId())) { // skip pt vehicles - } else { // car! + } else { // car! LinkCongestionInfo linkInfo = CongestionUtils.getOrCreateLinkInfo( event.getLinkId(), linkId2congestionInfo, scenario ) ; Id driverId = veh2DriverDelegate.getDriverOfVehicle(event.getVehicleId()); - + if (this.carPersonIDs.contains(driverId)) { // the driver is a car user AgentOnLinkInfo agentInfo = new AgentOnLinkInfo.Builder().setAgentId( driverId ).setLinkId( event.getLinkId() ) @@ -161,8 +161,8 @@ public final void handleEvent(LinkEnterEvent event) { @Override public final void handleEvent(LinkLeaveEvent event) { // yy My preference would be if we found a solution where the basic bookkeeping (e.g. update flow and - // delay queues) is done here. However, delegation does not allow to have custom code in between - // standard code (as was the case before with calculateCongestion). We need to consider if it is possible to + // delay queues) is done here. However, delegation does not allow to have custom code in between + // standard code (as was the case before with calculateCongestion). We need to consider if it is possible to // rather have the standard code in one go and embed it in the delegated class. In the sense of // class MyCongestionHandlerImpl { // ... handleEvent( LinkLeaveEvent event ) { @@ -170,15 +170,15 @@ public final void handleEvent(LinkLeaveEvent event) { // delegate.handleEvent( event ) ; // ... // more custom code // ... - + // coming here ... - + if (this.ptVehicleIDs.contains(event.getVehicleId())) { // skip pt vehicles - } else { // car! - + } else { // car! + Id personId = veh2DriverDelegate.getDriverOfVehicle( event.getVehicleId() ) ; - + if (this.carPersonIDs.contains(personId)) { // this person is a car user LinkCongestionInfo linkInfo = CongestionUtils.getOrCreateLinkInfo(event.getLinkId(), this.getLinkId2congestionInfo(), scenario); @@ -198,44 +198,44 @@ public final void handleEvent(LinkLeaveEvent event) { // global book-keeping: this.totalDelay += ( event.getTime() - delayInfo.freeSpeedLeaveTime ); } - } + } } @Override public final void handleEvent( PersonArrivalEvent event ) { - + if (event.getLegMode().equals(TransportMode.car)) { LinkCongestionInfo linkInfo = CongestionUtils.getOrCreateLinkInfo( event.getLinkId(), linkId2congestionInfo, scenario) ; linkInfo.getAgentsOnLink().remove( event.getPersonId() ) ; - + this.carPersonIDs.remove(event.getPersonId()); } } public final static void updateFlowAndDelayQueues(double time, DelayInfo delayInfo, LinkCongestionInfo linkInfo) { - + double delay = time - delayInfo.freeSpeedLeaveTime; - if ( delay < 1.0 ) { - linkInfo.getFlowQueue().clear(); + if ( delay < 1.0 ) { + linkInfo.getFlowQueue().clear(); return ; // should be ok but not tested (*) - } - + } + if (linkInfo.getFlowQueue().isEmpty() ) { // queue is already empty; nothing to do - + // seems like this should never be called when (*) is used, but in practice it happens, i.e. tests fail when the above if condition // is commented out. maybe initialization? kai, apr'16 } else { double earliestLeaveTimeAfterVehicleAhead = linkInfo.getLastLeaveEvent().getTime() + linkInfo.getMarginalDelayPerLeavingVehicle_sec(); if ( time > earliestLeaveTimeAfterVehicleAhead + 1.) { // Vehicle is delayed by more than 1/cap. That is, we must be spill-back delayed. - - double freeSpeedLeaveTimeGap = delayInfo.freeSpeedLeaveTime - linkInfo.getFlowQueue().getLast().freeSpeedLeaveTime ; + + double freeSpeedLeaveTimeGap = delayInfo.freeSpeedLeaveTime - linkInfo.getFlowQueue().getLast().freeSpeedLeaveTime ; if(freeSpeedLeaveTimeGap < linkInfo.getMarginalDelayPerLeavingVehicle_sec()){ // we are ALSO flow delayed. Therefore, we consider the bottleneck still active - + } else { // we are NOT also flow delayed. The bottleneck is now inactive: linkInfo.getFlowQueue().clear(); @@ -259,7 +259,7 @@ public final static void updateFlowAndDelayQueues(double time, DelayInfo delayIn *

      * Charging the agents that are in the flow queue. */ - final double computeFlowCongestionAndReturnStorageDelay(double now, Id linkId, DelayInfo affectedAgentDelayInfo, double remainingDelay) { + final double computeFlowCongestionAndReturnStorageDelay(double now, Id linkId, DelayInfo affectedAgentDelayInfo, double remainingDelay) { LinkCongestionInfo linkInfo = this.linkId2congestionInfo.get( linkId ); @@ -273,9 +273,9 @@ final double computeFlowCongestionAndReturnStorageDelay(double now, Id lin double allocatedDelay = Math.min(linkInfo.getMarginalDelayPerLeavingVehicle_sec(), remainingDelay); - CongestionEvent congestionEvent = new CongestionEvent(now, "flowAndStorageCapacity", causingAgentDelayInfo.personId, + CongestionEvent congestionEvent = new CongestionEvent(now, "flowAndStorageCapacity", causingAgentDelayInfo.personId, affectedAgentDelayInfo.personId, allocatedDelay, linkId, causingAgentDelayInfo.linkEnterTime ); - this.events.processEvent(congestionEvent); + this.events.processEvent(congestionEvent); this.totalInternalizedDelay += allocatedDelay ; @@ -292,7 +292,7 @@ final double computeFlowCongestionAndReturnStorageDelay(double now, Id lin return remainingDelay; } - + @Override public double getTotalDelay() { return this.totalDelay ; diff --git a/contribs/vsp/src/main/java/playground/vsp/congestion/handlers/MarginalCongestionPricingHandler.java b/contribs/vsp/src/main/java/playground/vsp/congestion/handlers/MarginalCongestionPricingHandler.java index 6bea372918a..56a521e5f9b 100644 --- a/contribs/vsp/src/main/java/playground/vsp/congestion/handlers/MarginalCongestionPricingHandler.java +++ b/contribs/vsp/src/main/java/playground/vsp/congestion/handlers/MarginalCongestionPricingHandler.java @@ -18,7 +18,7 @@ * *********************************************************************** */ /** - * + * */ package playground.vsp.congestion.handlers; @@ -37,7 +37,7 @@ * This handler calculates agent money events based on marginal congestion events. * The causing agent has to pay a toll depending on the number of affected agents and the external delay in sec. * The delay is monetized using the behavioral parameters from the scenario. - * + * * @author ikaddoura * */ @@ -49,19 +49,19 @@ public class MarginalCongestionPricingHandler implements CongestionEventHandler private final Scenario scenario; private final double vtts_car; private final double factor; - + private double amountSum = 0.; public MarginalCongestionPricingHandler(EventsManager eventsManager, Scenario scenario) { this(eventsManager, scenario, 1.0); } - + public MarginalCongestionPricingHandler(EventsManager eventsManager, Scenario scenario, double factor) { this.events = eventsManager; this.scenario = scenario; - this.vtts_car = (this.scenario.getConfig().planCalcScore().getModes().get(TransportMode.car).getMarginalUtilityOfTraveling() - this.scenario.getConfig().planCalcScore().getPerforming_utils_hr()) / this.scenario.getConfig().planCalcScore().getMarginalUtilityOfMoney(); + this.vtts_car = (this.scenario.getConfig().scoring().getModes().get(TransportMode.car).getMarginalUtilityOfTraveling() - this.scenario.getConfig().scoring().getPerforming_utils_hr()) / this.scenario.getConfig().scoring().getMarginalUtilityOfMoney(); this.factor = factor; - + log.info("Using the toll factor " + factor); log.info("Using the same VTTS for each agent to translate delays into monetary units."); log.info("VTTS_car: " + vtts_car); @@ -74,13 +74,13 @@ public void reset(int iteration) { @Override public void handleEvent(CongestionEvent event) { - + double amount = this.factor * event.getDelay() / 3600 * this.vtts_car; this.amountSum = this.amountSum + amount; - + PersonMoneyEvent moneyEvent = new PersonMoneyEvent(event.getTime(), event.getCausingAgentId(), amount, "congestionPricing", null); this.events.processEvent(moneyEvent); - + PersonLinkMoneyEvent linkMoneyEvent = new PersonLinkMoneyEvent(event.getTime(), event.getCausingAgentId(), event.getLinkId(), amount, event.getEmergenceTime(), "congestion"); this.events.processEvent(linkMoneyEvent); } @@ -88,5 +88,5 @@ public void handleEvent(CongestionEvent event) { public double getAmountSum() { return amountSum; } - -} \ No newline at end of file + +} diff --git a/contribs/vsp/src/main/java/playground/vsp/congestion/handlers/TollHandler.java b/contribs/vsp/src/main/java/playground/vsp/congestion/handlers/TollHandler.java index 3dc92c4caef..7fc6ae63a67 100644 --- a/contribs/vsp/src/main/java/playground/vsp/congestion/handlers/TollHandler.java +++ b/contribs/vsp/src/main/java/playground/vsp/congestion/handlers/TollHandler.java @@ -18,7 +18,7 @@ * *********************************************************************** */ /** - * + * */ package playground.vsp.congestion.handlers; @@ -51,29 +51,29 @@ public class TollHandler implements CongestionEventHandler, LinkEnterEventHandler, PersonDepartureEventHandler { private static final Logger log = LogManager.getLogger(TollHandler.class); private double timeBinSize = 900.; - + private Map, Map> linkId2timeBin2tollSum = new HashMap, Map>(); private Map, Map> linkId2timeBin2enteringAndDepartingAgents = new HashMap, Map>(); - + private List congestionEvents = new ArrayList(); private List linkEnterEvents = new ArrayList(); private List personDepartureEvents = new ArrayList(); private Map, Map> linkId2timeBin2avgToll = new HashMap, Map>(); private Map, Map> linkId2timeBin2avgTollOldValue = new HashMap, Map>(); - + private boolean setMethodsExecuted = false; - + private double vtts_car; private double congestionTollFactor; - + public TollHandler(Scenario scenario, double congestionTollFactor) { - this.vtts_car = (scenario.getConfig().planCalcScore().getModes().get(TransportMode.car).getMarginalUtilityOfTraveling() - scenario.getConfig().planCalcScore().getPerforming_utils_hr()) / scenario.getConfig().planCalcScore().getMarginalUtilityOfMoney(); + this.vtts_car = (scenario.getConfig().scoring().getModes().get(TransportMode.car).getMarginalUtilityOfTraveling() - scenario.getConfig().scoring().getPerforming_utils_hr()) / scenario.getConfig().scoring().getMarginalUtilityOfMoney(); this.congestionTollFactor = congestionTollFactor; log.info("VTTS_car: " + vtts_car); log.info("Congestion toll factor: " + congestionTollFactor); } - + public TollHandler(Scenario scenario) { this(scenario, 1.0); } @@ -89,20 +89,20 @@ public void reset(int iteration) { this.linkId2timeBin2avgTollOldValue.clear(); this.linkId2timeBin2avgTollOldValue.putAll(linkId2timeBin2avgToll); this.linkId2timeBin2avgToll.clear(); - - this.setMethodsExecuted = false; + + this.setMethodsExecuted = false; } @Override public void handleEvent(CongestionEvent event) { this.congestionEvents.add(event); } - + @Override public void handleEvent(LinkEnterEvent event) { - this.linkEnterEvents.add(event); + this.linkEnterEvents.add(event); } - + @Override public void handleEvent(PersonDepartureEvent event) { if (event.getLegMode().equals(TransportMode.car.toString())) { @@ -113,30 +113,30 @@ public void handleEvent(PersonDepartureEvent event) { } public void setLinkId2timeBin2avgToll() { - + log.info("Total number of congestion events: " + this.congestionEvents.size()); - + if (!this.linkId2timeBin2tollSum.isEmpty()) { throw new RuntimeException("Map linkId2timeBin2tollSum should be empty!"); } else { // calculate toll sum for each link and time bin setlinkId2timeBin2tollSum(); } - + if (!this.linkId2timeBin2enteringAndDepartingAgents.isEmpty()) { throw new RuntimeException("Map linkId2timeBin2enteringAndDepartingAgents should be empty!"); } else { // calculate leaving agents for each link and time bin setlinkId2timeBin2enteringAndDepartingAgents(); } - + this.setMethodsExecuted = true; - + if (!this.linkId2timeBin2avgToll.isEmpty()) { throw new RuntimeException("Map linkId2timeBin2avgToll should be empty!"); } else { // calculate average toll for each link and time bin - + for (Id linkId : this.linkId2timeBin2tollSum.keySet()) { // log.info("Calculating average toll for link " + linkId); Map timeBin2tollSum = this.linkId2timeBin2tollSum.get(linkId); @@ -164,19 +164,19 @@ public void setLinkId2timeBin2avgToll() { } private void setlinkId2timeBin2enteringAndDepartingAgents() { - + // first go through all link enter events for (LinkEnterEvent event : this.linkEnterEvents){ - + // if (this.linkId2timeBin2tollSum.containsKey(event.getLinkId())){ // // Tolls paid on this link. - + Map timeBin2enteringAgents = new HashMap(); if (this.linkId2timeBin2enteringAndDepartingAgents.containsKey(event.getLinkId())) { // link already in map timeBin2enteringAgents = this.linkId2timeBin2enteringAndDepartingAgents.get(event.getLinkId()); - + // for this link: search for the right time bin for (double time = 0; time < (30 * 3600);) { time = time + this.timeBinSize; @@ -184,7 +184,7 @@ private void setlinkId2timeBin2enteringAndDepartingAgents() { if (event.getTime() < time && event.getTime() >= (time - this.timeBinSize)) { // event in time bin // update entering agents on this link and in this time bin - + if (timeBin2enteringAgents.get(time) != null) { // not the first agent entering this link in this time bin int enteringAgentsSoFar = timeBin2enteringAgents.get(time); @@ -210,16 +210,16 @@ private void setlinkId2timeBin2enteringAndDepartingAgents() { } } } - - this.linkId2timeBin2enteringAndDepartingAgents.put(event.getLinkId(), timeBin2enteringAgents); - + + this.linkId2timeBin2enteringAndDepartingAgents.put(event.getLinkId(), timeBin2enteringAgents); + // } else { // // No tolls paid on that link. Skip that link. -// +// // } } - - + + // then go through all person departure events // a person departure event means an agent also 'enters' the link for (PersonDepartureEvent event : this.personDepartureEvents) { @@ -289,11 +289,11 @@ private void setlinkId2timeBin2tollSum() { // for this link: search for the right time bin for (double time = 0; time < (30 * 3600);) { time = time + this.timeBinSize; - + if (event.getEmergenceTime() < time && event.getEmergenceTime() >= (time - this.timeBinSize)) { // congestion event in time bin // update toll sum of this link and time bin - + if (timeBin2tollSum.get(time) != null) { // toll sum was calculated before for this time bin double sum = timeBin2tollSum.get(time); @@ -304,13 +304,13 @@ private void setlinkId2timeBin2tollSum() { // toll sum was not calculated before for this time bin double amount = this.congestionTollFactor * (event.getDelay() / 3600.0 * this.vtts_car); timeBin2tollSum.put(time, amount); - } + } } } } else { // link not yet in map - + // for this link: search for the right time bin for (double time = 0; time < (30 * 3600);) { time = time + this.timeBinSize; @@ -322,7 +322,7 @@ private void setlinkId2timeBin2tollSum() { } } } - + this.linkId2timeBin2tollSum.put(event.getLinkId(), timeBin2tollSum); } } @@ -332,7 +332,7 @@ private void setlinkId2timeBin2tollSum() { */ public double getAvgToll(Id linkId, double time) { double avgToll = 0.; - + if (this.linkId2timeBin2avgToll.containsKey(linkId)){ Map timeBin2avgToll = this.linkId2timeBin2avgToll.get(linkId); for (Double timeBin : timeBin2avgToll.keySet()) { @@ -341,16 +341,16 @@ public double getAvgToll(Id linkId, double time) { } } } - + return avgToll; } - + /** * Returns the avg toll (old value) (negative monetary amount) paid on that link during that time bin. */ public double getAvgTollOldValue(Id linkId, double time) { double avgTollOldValue = 0.; - + if (this.linkId2timeBin2avgTollOldValue.containsKey(linkId)){ Map timeBin2avgTollOldValue = this.linkId2timeBin2avgTollOldValue.get(linkId); for (Double timeBin : timeBin2avgTollOldValue.keySet()) { @@ -359,52 +359,52 @@ public double getAvgTollOldValue(Id linkId, double time) { } } } - + return avgTollOldValue; } public void writeTollStats(String fileName) { - + if (this.setMethodsExecuted == false) { log.info("Average tolls per link Id and time bin have to be set. Running required method..."); this.setLinkId2timeBin2avgToll(); } - + File file = new File(fileName); - + try { BufferedWriter bw = new BufferedWriter(new FileWriter(file)); bw.write("link;total toll (per day);entering (and departing) agents (per day)"); bw.newLine(); - + for (Id linkId : this.linkId2timeBin2enteringAndDepartingAgents.keySet()){ double totalToll = 0.; int enteringAgents = 0; - + if (this.linkId2timeBin2tollSum.get(linkId) == null) { // There is no toll payment in any time bin. - + } else { for (Double tollSum_timeBin : this.linkId2timeBin2tollSum.get(linkId).values()){ totalToll = totalToll + tollSum_timeBin; } } - + for (Integer enteringDepartingAgents_timeBin : this.linkId2timeBin2enteringAndDepartingAgents.get(linkId).values()){ enteringAgents = enteringAgents + enteringDepartingAgents_timeBin; } - + bw.write(linkId + ";" + totalToll + ";" + enteringAgents); bw.newLine(); } - + bw.close(); log.info("Output written to " + fileName); - + } catch (IOException e) { e.printStackTrace(); } - + } public List getLinkEnterEvents() { diff --git a/contribs/vsp/src/main/java/playground/vsp/demandde/commuterDemandCottbus/CommuterDemandWriter.java b/contribs/vsp/src/main/java/playground/vsp/demandde/commuterDemandCottbus/CommuterDemandWriter.java index 0a3c94df2f4..10f4c106725 100644 --- a/contribs/vsp/src/main/java/playground/vsp/demandde/commuterDemandCottbus/CommuterDemandWriter.java +++ b/contribs/vsp/src/main/java/playground/vsp/demandde/commuterDemandCottbus/CommuterDemandWriter.java @@ -59,7 +59,7 @@ /** * @author jbischoff * @author dgrether - * + * */ public class CommuterDemandWriter { @@ -122,8 +122,8 @@ public void computeDemand(Scenario scenario) { private void generatePopulation(Scenario scenario) { final FreespeedTravelTimeAndDisutility timeCostCalc = new FreespeedTravelTimeAndDisutility(scenario.getConfig() - .planCalcScore()); - PlanAlgorithm router = + .scoring()); + PlanAlgorithm router = new PlanRouter( new TripRouterFactoryBuilderWithDefaults().build( scenario ).get( diff --git a/contribs/vsp/src/main/java/playground/vsp/ev/RunUrbanEVExample.java b/contribs/vsp/src/main/java/playground/vsp/ev/RunUrbanEVExample.java index 06f63685f7e..e5b374733f6 100644 --- a/contribs/vsp/src/main/java/playground/vsp/ev/RunUrbanEVExample.java +++ b/contribs/vsp/src/main/java/playground/vsp/ev/RunUrbanEVExample.java @@ -108,12 +108,12 @@ private static Config prepareConfig( String[] args ){ urbanEVConfig.setCriticalSOC(0.4); //TODO actually, should also work with all AccessEgressTypes but we have to check (write JUnit test) - config.plansCalcRoute().setAccessEgressType(RoutingConfigGroup.AccessEgressType.none ); + config.routing().setAccessEgressType(RoutingConfigGroup.AccessEgressType.none ); //register charging interaction activities for car - config.planCalcScore().addActivityParams( + config.scoring().addActivityParams( new ActivityParams(TransportMode.car + UrbanEVModule.PLUGOUT_INTERACTION).setScoringThisActivityAtAll(false ) ); - config.planCalcScore().addActivityParams( + config.scoring().addActivityParams( new ActivityParams( TransportMode.car + UrbanEVModule.PLUGIN_INTERACTION).setScoringThisActivityAtAll( false ) ); return config; } diff --git a/contribs/vsp/src/main/java/playground/vsp/ev/UrbanEVTripsPlanner.java b/contribs/vsp/src/main/java/playground/vsp/ev/UrbanEVTripsPlanner.java index 1091c7de552..0449190e8f6 100644 --- a/contribs/vsp/src/main/java/playground/vsp/ev/UrbanEVTripsPlanner.java +++ b/contribs/vsp/src/main/java/playground/vsp/ev/UrbanEVTripsPlanner.java @@ -196,7 +196,7 @@ private void processPlans(Map>> selectedEVPlans) { Plan modifiablePlan = WithinDayAgentUtils.getModifiablePlan(mobsimagent); TripRouter tripRouter = tripRouterProvider.get(); Set modesWithVehicles = new HashSet<>(scenario.getConfig().qsim().getMainModes()); - modesWithVehicles.addAll(scenario.getConfig().plansCalcRoute().getNetworkModes()); + modesWithVehicles.addAll(scenario.getConfig().routing().getNetworkModes()); for (Id ev : selectedEVPlans.get(plan)) { //only replan cnt times per vehicle and person. otherwise, there might be a leg which is just too long and we end up in an infinity loop... @@ -350,7 +350,7 @@ private Leg getCriticalOrLastEvLeg(Plan modifiablePlan, ElectricVehicle pseudoVe Double chargingBegin = null; Set modesWithVehicles = new HashSet<>(scenario.getConfig().qsim().getMainModes()); - modesWithVehicles.addAll(scenario.getConfig().plansCalcRoute().getNetworkModes()); + modesWithVehicles.addAll(scenario.getConfig().routing().getNetworkModes()); Leg lastLegWithVehicle = null; @@ -451,7 +451,7 @@ private boolean replanPrecedentAndCurrentEVLegs(MobsimAgent mobsimagent, Plan mo Activity plugoutTripDestination = findRealOrChargingActAfter(mobsimagent, modifiablePlan.getPlanElements().indexOf(plugoutLeg)); { //some consistency checks.. //TODO consider to put in a JUnit test.. - int offset = config.plansCalcRoute().getAccessEgressType().equals(RoutingConfigGroup.AccessEgressType.none) ? 1 : 3; + int offset = config.routing().getAccessEgressType().equals(RoutingConfigGroup.AccessEgressType.none) ? 1 : 3; Preconditions.checkNotNull(pluginTripOrigin, "pluginTripOrigin is null. should never happen.."); Preconditions.checkState(!pluginTripOrigin.equals(actWhileCharging), diff --git a/contribs/vsp/src/main/java/playground/vsp/openberlinscenario/planmodification/SplitActivityTypesBasedOnDuration.java b/contribs/vsp/src/main/java/playground/vsp/openberlinscenario/planmodification/SplitActivityTypesBasedOnDuration.java index af7be05fd6a..045304706fe 100644 --- a/contribs/vsp/src/main/java/playground/vsp/openberlinscenario/planmodification/SplitActivityTypesBasedOnDuration.java +++ b/contribs/vsp/src/main/java/playground/vsp/openberlinscenario/planmodification/SplitActivityTypesBasedOnDuration.java @@ -103,11 +103,11 @@ public void run(String outputPopulationFile, String outputConfigFile, double tim } for (ActivityParams actParams : newActivityParams) { - scenario.getConfig().planCalcScore().addActivityParams(actParams); + scenario.getConfig().scoring().addActivityParams(actParams); } log.info("New activity parameters: "); - for (ActivityParams actParams : scenario.getConfig().planCalcScore().getActivityParams()) { + for (ActivityParams actParams : scenario.getConfig().scoring().getActivityParams()) { initialActivityParams.add(actParams); log.info(" -> " + actParams.getActivityType()); } diff --git a/contribs/vsp/src/main/java/playground/vsp/parkAndRide/example/PRRunner.java b/contribs/vsp/src/main/java/playground/vsp/parkAndRide/example/PRRunner.java index 094cacd5883..b3cebe02ae9 100644 --- a/contribs/vsp/src/main/java/playground/vsp/parkAndRide/example/PRRunner.java +++ b/contribs/vsp/src/main/java/playground/vsp/parkAndRide/example/PRRunner.java @@ -70,7 +70,7 @@ private void run() { ConfigUtils.loadConfig(config, configFile); final Controler controler = new Controler(config); - controler.getConfig().controler().setOverwriteFileSetting( + controler.getConfig().controller().setOverwriteFileSetting( true ? OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles : OutputDirectoryHierarchy.OverwriteFileSetting.failIfDirectoryExists ); @@ -79,7 +79,7 @@ private void run() { ActivityParams prActivityParams = new ActivityParams(PRConstants.PARKANDRIDE_ACTIVITY_TYPE); prActivityParams.setTypicalDuration(prSettings.getTypicalDuration()); - controler.getConfig().planCalcScore().addActivityParams(prActivityParams); + controler.getConfig().scoring().addActivityParams(prActivityParams); controler.setScoringFunctionFactory(new PRScoringFunctionFactory(controler.getScenario(), prSettings.getIntermodalTransferPenalty())); diff --git a/contribs/vsp/src/main/java/playground/vsp/pt/fare/PtFareModule.java b/contribs/vsp/src/main/java/playground/vsp/pt/fare/PtFareModule.java index 47753e0559f..9bd25cc81f4 100644 --- a/contribs/vsp/src/main/java/playground/vsp/pt/fare/PtFareModule.java +++ b/contribs/vsp/src/main/java/playground/vsp/pt/fare/PtFareModule.java @@ -8,8 +8,8 @@ public class PtFareModule extends AbstractModule { @Override public void install() { - getConfig().planCalcScore().getModes().get(TransportMode.pt).setDailyMonetaryConstant(0); - getConfig().planCalcScore().getModes().get(TransportMode.pt).setMarginalUtilityOfDistance(0); + getConfig().scoring().getModes().get(TransportMode.pt).setDailyMonetaryConstant(0); + getConfig().scoring().getModes().get(TransportMode.pt).setMarginalUtilityOfDistance(0); PtFareConfigGroup ptFareConfigGroup = ConfigUtils.addOrGetModule(this.getConfig(), PtFareConfigGroup.class); if (ptFareConfigGroup.getPtFareCalculation() == PtFareConfigGroup.PtFareCalculationModels.distanceBased) { DistanceBasedPtFareParams distanceBasedPtFareParams = ConfigUtils.addOrGetModule(this.getConfig(), DistanceBasedPtFareParams.class); diff --git a/contribs/vsp/src/main/java/playground/vsp/randomizedtransitrouter/RunOTFVisDebugRandomizedTransitRouterTravelTimeAndDisutility.java b/contribs/vsp/src/main/java/playground/vsp/randomizedtransitrouter/RunOTFVisDebugRandomizedTransitRouterTravelTimeAndDisutility.java index 88515eab97e..6f38b251bf5 100644 --- a/contribs/vsp/src/main/java/playground/vsp/randomizedtransitrouter/RunOTFVisDebugRandomizedTransitRouterTravelTimeAndDisutility.java +++ b/contribs/vsp/src/main/java/playground/vsp/randomizedtransitrouter/RunOTFVisDebugRandomizedTransitRouterTravelTimeAndDisutility.java @@ -46,13 +46,13 @@ */ public class RunOTFVisDebugRandomizedTransitRouterTravelTimeAndDisutility { - + public static void main(String[] args) { final Config config = ConfigUtils.loadConfig(args[0]) ; boolean doVisualization = true; - config.planCalcScore().setWriteExperiencedPlans(true) ; + config.scoring().setWriteExperiencedPlans(true) ; ConfigUtils.addOrGetModule(config, OTFVisConfigGroup.GROUP_NAME, OTFVisConfigGroup.class).setDrawTransitFacilities(true) ; // this DOES work ConfigUtils.addOrGetModule(config, OTFVisConfigGroup.GROUP_NAME, OTFVisConfigGroup.class).setDrawTransitFacilityIds(false); @@ -61,16 +61,16 @@ public static void main(String[] args) { ConfigUtils.addOrGetModule(config, OTFVisConfigGroup.GROUP_NAME, OTFVisConfigGroup.class).setScaleQuadTreeRect(true); final Scenario scenario = ScenarioUtils.loadScenario(config) ; - + final Controler ctrl = new Controler(scenario) ; - ctrl.getConfig().controler().setOverwriteFileSetting( + ctrl.getConfig().controller().setOverwriteFileSetting( true ? OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles : OutputDirectoryHierarchy.OverwriteFileSetting.failIfDirectoryExists ); ctrl.addOverridingModule(new RandomizingTransitRouterModule()); - + if (doVisualization){ ctrl.addOverridingModule(new AbstractModule() { @Override @@ -96,6 +96,6 @@ public Mobsim createMobsim(final Scenario sc, final EventsManager eventsManager) }); } ctrl.run() ; - + } } diff --git a/contribs/vsp/src/test/java/org/matsim/core/scoring/functions/PersonScoringParametersFromPersonAttributesIT.java b/contribs/vsp/src/test/java/org/matsim/core/scoring/functions/PersonScoringParametersFromPersonAttributesIT.java index f25b4e54347..7d838d4178a 100644 --- a/contribs/vsp/src/test/java/org/matsim/core/scoring/functions/PersonScoringParametersFromPersonAttributesIT.java +++ b/contribs/vsp/src/test/java/org/matsim/core/scoring/functions/PersonScoringParametersFromPersonAttributesIT.java @@ -48,10 +48,10 @@ public class PersonScoringParametersFromPersonAttributesIT { @Test public void testSetAttributeAndRunEquil(){ Config config = testUtils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("equil"), "config.xml")); - config.controler().setOutputDirectory(testUtils.getOutputDirectory()); - config.controler().setLastIteration(0); - config.planCalcScore().setPerforming_utils_hr(0.0d); - config.planCalcScore().getModes().get(TransportMode.car).setMarginalUtilityOfTraveling(0.0d); + config.controller().setOutputDirectory(testUtils.getOutputDirectory()); + config.controller().setLastIteration(0); + config.scoring().setPerforming_utils_hr(0.0d); + config.scoring().getModes().get(TransportMode.car).setMarginalUtilityOfTraveling(0.0d); config.plans().setInputFile("plans2.xml"); Scenario scenario = ScenarioUtils.loadScenario(config); diff --git a/contribs/vsp/src/test/java/org/matsim/integration/drtAndPt/PtAlongALine2Test.java b/contribs/vsp/src/test/java/org/matsim/integration/drtAndPt/PtAlongALine2Test.java index 9a97b6a9ce6..ef0cc856096 100644 --- a/contribs/vsp/src/test/java/org/matsim/integration/drtAndPt/PtAlongALine2Test.java +++ b/contribs/vsp/src/test/java/org/matsim/integration/drtAndPt/PtAlongALine2Test.java @@ -107,26 +107,26 @@ public void testPtAlongALineWithRaptorAndDrtServiceArea() { // === GBL: === - config.controler().setLastIteration(0); + config.controller().setLastIteration(0); // === ROUTER: === - config.plansCalcRoute().setAccessEgressType(AccessEgressType.accessEgressModeToLink); + config.routing().setAccessEgressType(AccessEgressType.accessEgressModeToLink); config.qsim().setVehiclesSource(QSimConfigGroup.VehiclesSource.modeVehicleTypesFromVehiclesData); // (as of today, will also influence router. kai, jun'19) if (drtMode == DrtMode.teleportBeeline) {// (configure teleportation router) - config.plansCalcRoute() + config.routing() .addModeRoutingParams( new RoutingConfigGroup.TeleportedModeParams().setMode(TransportMode.drt ).setTeleportedModeSpeed(100. / 3.6 ) ); if (drt2) { - config.plansCalcRoute() + config.routing() .addModeRoutingParams( new RoutingConfigGroup.TeleportedModeParams().setMode("drt2" ).setTeleportedModeSpeed(100. / 3.6 ) ); } if (drt3) { - config.plansCalcRoute() + config.routing() .addModeRoutingParams( new RoutingConfigGroup.TeleportedModeParams().setMode("drt3" ).setTeleportedModeSpeed(100. / 3.6 ) ); } @@ -140,14 +140,14 @@ public void testPtAlongALineWithRaptorAndDrtServiceArea() { if (drt3) { networkModes.add("drt3"); } - config.plansCalcRoute().setNetworkModes(networkModes); + config.routing().setNetworkModes(networkModes); } - config.plansCalcRoute() + config.routing() .addModeRoutingParams(new RoutingConfigGroup.TeleportedModeParams().setMode("walk" ).setTeleportedModeSpeed(5. / 3.6 ) ); // set up walk2 so we don't need walk in raptor: - config.plansCalcRoute() + config.routing() .addModeRoutingParams(new RoutingConfigGroup.TeleportedModeParams().setMode("walk2" ).setTeleportedModeSpeed(5. / 3.6 ) ); // === RAPTOR: === @@ -196,21 +196,21 @@ public void testPtAlongALineWithRaptorAndDrtServiceArea() { // === SCORING: === - double margUtlTravPt = config.planCalcScore().getModes().get(TransportMode.pt).getMarginalUtilityOfTraveling(); + double margUtlTravPt = config.scoring().getModes().get(TransportMode.pt).getMarginalUtilityOfTraveling(); if (drtMode != DrtMode.none) { // (scoring parameters for drt modes) - config.planCalcScore() + config.scoring() .addModeParams(new ModeParams(TransportMode.drt).setMarginalUtilityOfTraveling(margUtlTravPt)); if (drt2) { - config.planCalcScore() + config.scoring() .addModeParams(new ModeParams("drt2").setMarginalUtilityOfTraveling(margUtlTravPt)); } if (drt3) { - config.planCalcScore() + config.scoring() .addModeParams(new ModeParams("drt3").setMarginalUtilityOfTraveling(margUtlTravPt)); } } - config.planCalcScore().addModeParams(new ModeParams("walk2").setMarginalUtilityOfTraveling(margUtlTravPt)); + config.scoring().addModeParams(new ModeParams("walk2").setMarginalUtilityOfTraveling(margUtlTravPt)); // === QSIM: === @@ -269,7 +269,7 @@ public void testPtAlongALineWithRaptorAndDrtServiceArea() { } for (DrtConfigGroup drtConfigGroup : mm.getModalElements()) { - DrtConfigs.adjustDrtConfig(drtConfigGroup, config.planCalcScore(), config.plansCalcRoute()); + DrtConfigs.adjustDrtConfig(drtConfigGroup, config.scoring(), config.routing()); } } @@ -593,21 +593,21 @@ public void intermodalAccessEgressPicksWrongVariant() { // === GBL: === - config.controler().setLastIteration(0); + config.controller().setLastIteration(0); // === ROUTER: === - config.plansCalcRoute().setAccessEgressType(RoutingConfigGroup.AccessEgressType.accessEgressModeToLink); + config.routing().setAccessEgressType(RoutingConfigGroup.AccessEgressType.accessEgressModeToLink); config.qsim().setVehiclesSource(QSimConfigGroup.VehiclesSource.modeVehicleTypesFromVehiclesData); // (as of today, will also influence router. kai, jun'19) - config.plansCalcRoute().setNetworkModes(new HashSet<>(Arrays.asList(TransportMode.drt, "drt2"))); + config.routing().setNetworkModes(new HashSet<>(Arrays.asList(TransportMode.drt, "drt2"))); // set up walk2 so we don't use faulty walk in raptor: - config.plansCalcRoute().addModeRoutingParams(new RoutingConfigGroup.TeleportedModeParams("walk2").setTeleportedModeSpeed(5. / 3.6 ) ); + config.routing().addModeRoutingParams(new RoutingConfigGroup.TeleportedModeParams("walk2").setTeleportedModeSpeed(5. / 3.6 ) ); - config.plansCalcRoute() + config.routing() .addModeRoutingParams(new RoutingConfigGroup.TeleportedModeParams(TransportMode.walk).setTeleportedModeSpeed(0. ) ); // (when specifying "walk2", all default routing params are cleared. However, swiss rail raptor needs "walk" to function. kai, feb'20) @@ -647,14 +647,14 @@ public void intermodalAccessEgressPicksWrongVariant() { // === SCORING: === { - double margUtlTravPt = config.planCalcScore() + double margUtlTravPt = config.scoring() .getModes() .get(TransportMode.pt) .getMarginalUtilityOfTraveling(); - config.planCalcScore() + config.scoring() .addModeParams(new ModeParams(TransportMode.drt).setMarginalUtilityOfTraveling(margUtlTravPt)); - config.planCalcScore().addModeParams(new ModeParams("drt2").setMarginalUtilityOfTraveling(margUtlTravPt)); - config.planCalcScore().addModeParams(new ModeParams("walk2").setMarginalUtilityOfTraveling(margUtlTravPt)); + config.scoring().addModeParams(new ModeParams("drt2").setMarginalUtilityOfTraveling(margUtlTravPt)); + config.scoring().addModeParams(new ModeParams("walk2").setMarginalUtilityOfTraveling(margUtlTravPt)); } // === QSIM: === @@ -755,22 +755,22 @@ public void networkWalkDoesNotWorkWithRaptor() { // === GBL: === - config.controler().setLastIteration(0); + config.controller().setLastIteration(0); // === ROUTER: === - config.plansCalcRoute().setAccessEgressType(AccessEgressType.accessEgressModeToLink); + config.routing().setAccessEgressType(AccessEgressType.accessEgressModeToLink); config.qsim().setVehiclesSource(QSimConfigGroup.VehiclesSource.modeVehicleTypesFromVehiclesData); // (as of today, will also influence router. kai, jun'19) // remove teleportation walk router: - config.plansCalcRoute().removeModeRoutingParams(TransportMode.walk); + config.routing().removeModeRoutingParams(TransportMode.walk); // add network walk router: - Set networkModes = new HashSet<>(config.plansCalcRoute().getNetworkModes()); + Set networkModes = new HashSet<>(config.routing().getNetworkModes()); networkModes.add(TransportMode.walk); - config.plansCalcRoute().setNetworkModes(networkModes); + config.routing().setNetworkModes(networkModes); // === RAPTOR: === { diff --git a/contribs/vsp/src/test/java/org/matsim/integration/drtAndPt/PtAlongALineTest.java b/contribs/vsp/src/test/java/org/matsim/integration/drtAndPt/PtAlongALineTest.java index c01005e567c..67534b4b205 100644 --- a/contribs/vsp/src/test/java/org/matsim/integration/drtAndPt/PtAlongALineTest.java +++ b/contribs/vsp/src/test/java/org/matsim/integration/drtAndPt/PtAlongALineTest.java @@ -119,19 +119,19 @@ public void testDrtAlongALine() { } for (DrtConfigGroup drtCfg : multiModeDrtCfg.getModalElements()) { - DrtConfigs.adjustDrtConfig(drtCfg, config.planCalcScore(), config.plansCalcRoute()); + DrtConfigs.adjustDrtConfig(drtCfg, config.scoring(), config.routing()); } - config.controler().setOutputDirectory(utils.getOutputDirectory()); - config.controler().setLastIteration(0); - config.controler() + config.controller().setOutputDirectory(utils.getOutputDirectory()); + config.controller().setLastIteration(0); + config.controller() .setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists); { ReplanningConfigGroup.StrategySettings stratSets = new ReplanningConfigGroup.StrategySettings(); stratSets.setStrategyName(DefaultPlanStrategiesModule.DefaultStrategy.SubtourModeChoice); stratSets.setWeight(0.1); - config.strategy().addStrategySettings(stratSets); + config.replanning().addStrategySettings(stratSets); // config.subtourModeChoice().setModes(new String[] { TransportMode.car, "drt_A" }); } @@ -139,17 +139,17 @@ public void testDrtAlongALine() { ReplanningConfigGroup.StrategySettings stratSets = new ReplanningConfigGroup.StrategySettings(); stratSets.setStrategyName(DefaultPlanStrategiesModule.DefaultSelector.ChangeExpBeta); stratSets.setWeight(1.); - config.strategy().addStrategySettings(stratSets); + config.replanning().addStrategySettings(stratSets); } { ModeParams modeParams = new ModeParams("drt_A"); - config.planCalcScore().addModeParams(modeParams); + config.scoring().addModeParams(modeParams); } { ModeParams modeParams = new ModeParams("drt_A_walk"); - config.planCalcScore().addModeParams(modeParams); + config.scoring().addModeParams(modeParams); } Scenario scenario = ScenarioUtils.loadScenario(config); @@ -210,21 +210,21 @@ public void testPtAlongALineWithRaptorAndDrtStopFilterAttribute() { config.qsim().setSimStarttimeInterpretation(QSimConfigGroup.StarttimeInterpretation.onlyUseStarttime); // yy why? kai, jun'19 - config.plansCalcRoute().setAccessEgressType(RoutingConfigGroup.AccessEgressType.accessEgressModeToLink); + config.routing().setAccessEgressType(RoutingConfigGroup.AccessEgressType.accessEgressModeToLink); ModeParams accessWalk = new ModeParams(TransportMode.non_network_walk); accessWalk.setMarginalUtilityOfTraveling(0); - config.planCalcScore().addModeParams(accessWalk); + config.scoring().addModeParams(accessWalk); // (scoring parameters for drt modes) { ModeParams modeParams = new ModeParams(TransportMode.drt); - config.planCalcScore().addModeParams(modeParams); + config.scoring().addModeParams(modeParams); } config.qsim().setVehiclesSource(QSimConfigGroup.VehiclesSource.modeVehicleTypesFromVehiclesData); // (as of today, will also influence router. kai, jun'19) - config.controler().setLastIteration(0); + config.controller().setLastIteration(0); { // (raptor config) @@ -257,7 +257,7 @@ public void testPtAlongALineWithRaptorAndDrtStopFilterAttribute() { } for (DrtConfigGroup drtConfigGroup : mm.getModalElements()) { - DrtConfigs.adjustDrtConfig(drtConfigGroup, config.planCalcScore(), config.plansCalcRoute()); + DrtConfigs.adjustDrtConfig(drtConfigGroup, config.scoring(), config.routing()); } config.vspExperimental().setVspDefaultsCheckingLevel(VspExperimentalConfigGroup.VspDefaultsCheckingLevel.warn); @@ -309,11 +309,11 @@ static Config createConfig(String outputDir) { config.global().setNumberOfThreads(1); - config.controler().setOutputDirectory(outputDir); - config.controler().setLastIteration(0); + config.controller().setOutputDirectory(outputDir); + config.controller().setLastIteration(0); - config.plansCalcRoute().getModeRoutingParams().get(TransportMode.walk).setTeleportedModeSpeed(3.); - config.plansCalcRoute().getModeRoutingParams().get(TransportMode.bike).setTeleportedModeSpeed(10.); + config.routing().getModeRoutingParams().get(TransportMode.walk).setTeleportedModeSpeed(3.); + config.routing().getModeRoutingParams().get(TransportMode.bike).setTeleportedModeSpeed(10.); config.qsim().setEndTime(24. * 3600.); @@ -346,19 +346,19 @@ static Config createConfig(String outputDir) { private static void configureScoring(Config config) { ModeParams accessWalk = new ModeParams(TransportMode.non_network_walk); accessWalk.setMarginalUtilityOfTraveling(0); - config.planCalcScore().addModeParams(accessWalk); + config.scoring().addModeParams(accessWalk); ModeParams transitWalk = new ModeParams("transit_walk"); transitWalk.setMarginalUtilityOfTraveling(0); - config.planCalcScore().addModeParams(transitWalk); + config.scoring().addModeParams(transitWalk); ModeParams bike = new ModeParams("bike"); bike.setMarginalUtilityOfTraveling(0); - config.planCalcScore().addModeParams(bike); + config.scoring().addModeParams(bike); ModeParams drt = new ModeParams("drt"); drt.setMarginalUtilityOfTraveling(0); - config.planCalcScore().addModeParams(drt); + config.scoring().addModeParams(drt); } static SwissRailRaptorConfigGroup createRaptorConfigGroup(int radiusWalk, int radiusBike) { diff --git a/contribs/vsp/src/test/java/playground/vsp/TestScenario.java b/contribs/vsp/src/test/java/playground/vsp/TestScenario.java index aba2de831fc..24fde8c688a 100644 --- a/contribs/vsp/src/test/java/playground/vsp/TestScenario.java +++ b/contribs/vsp/src/test/java/playground/vsp/TestScenario.java @@ -45,8 +45,8 @@ public static Config loadConfig(MatsimTestUtils utils) { URL context = ExamplesUtils.getTestScenarioURL("kelheim"); Config config = ConfigUtils.loadConfig(IOUtils.extendUrl(context, "config.xml")); - config.controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists); - config.controler().setOutputDirectory(utils.getOutputDirectory()); + config.controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists); + config.controller().setOutputDirectory(utils.getOutputDirectory()); return config; } diff --git a/contribs/vsp/src/test/java/playground/vsp/cadyts/marginals/ModalDistanceAndCountsCadytsIT.java b/contribs/vsp/src/test/java/playground/vsp/cadyts/marginals/ModalDistanceAndCountsCadytsIT.java index 2164553bb3b..0974c7e40da 100644 --- a/contribs/vsp/src/test/java/playground/vsp/cadyts/marginals/ModalDistanceAndCountsCadytsIT.java +++ b/contribs/vsp/src/test/java/playground/vsp/cadyts/marginals/ModalDistanceAndCountsCadytsIT.java @@ -82,9 +82,9 @@ private Config createConfig() { Config config = ConfigUtils.createConfig(); String[] modes = new String[]{TransportMode.car, TransportMode.bike}; - config.controler().setOutputDirectory(this.utils.getOutputDirectory()); - config.controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists); - config.controler().setLastIteration(40); + config.controller().setOutputDirectory(this.utils.getOutputDirectory()); + config.controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists); + config.controller().setLastIteration(40); config.counts().setWriteCountsInterval(1); config.counts().setAverageCountsOverIterations(1); @@ -93,7 +93,7 @@ private Config createConfig() { home.setMinimalDuration(3600); home.setTypicalDuration(3600); home.setEarliestEndTime(0); - config.planCalcScore().addActivityParams(home); + config.scoring().addActivityParams(home); ScoringConfigGroup.ActivityParams work = new ScoringConfigGroup.ActivityParams("work"); work.setMinimalDuration(3600); @@ -101,32 +101,32 @@ private Config createConfig() { work.setEarliestEndTime(0); work.setOpeningTime(3600); work.setClosingTime(10 * 3600); - config.planCalcScore().addActivityParams(work); + config.scoring().addActivityParams(work); // have random selection of plans to generate heterogenity in the beginning, so that cadyts can calibrate its correction ReplanningConfigGroup.StrategySettings selectRandom = new ReplanningConfigGroup.StrategySettings(); selectRandom.setStrategyName(DefaultPlanStrategiesModule.DefaultSelector.SelectRandom); selectRandom.setDisableAfter(33); selectRandom.setWeight(0.5); - config.strategy().addStrategySettings(selectRandom); + config.replanning().addStrategySettings(selectRandom); // have change exp beta, so that mode distribution converges at the end of the simulation ReplanningConfigGroup.StrategySettings changeExpBeta = new ReplanningConfigGroup.StrategySettings(); changeExpBeta.setStrategyName(DefaultPlanStrategiesModule.DefaultSelector.ChangeExpBeta); changeExpBeta.setDisableAfter(38); changeExpBeta.setWeight(0.5); - config.strategy().addStrategySettings(changeExpBeta); + config.replanning().addStrategySettings(changeExpBeta); // at the end of the scenario pick the plans with the best score ReplanningConfigGroup.StrategySettings bestScore = new ReplanningConfigGroup.StrategySettings(); bestScore.setStrategyName(DefaultPlanStrategiesModule.DefaultSelector.BestScore); bestScore.setWeight(0.1); - config.strategy().addStrategySettings(bestScore); + config.replanning().addStrategySettings(bestScore); // remove teleported bike - config.plansCalcRoute().removeModeRoutingParams(TransportMode.bike); - config.plansCalcRoute().setNetworkModes(Arrays.asList(modes)); - config.plansCalcRoute().setAccessEgressType(RoutingConfigGroup.AccessEgressType.accessEgressModeToLink); + config.routing().removeModeRoutingParams(TransportMode.bike); + config.routing().setNetworkModes(Arrays.asList(modes)); + config.routing().setAccessEgressType(RoutingConfigGroup.AccessEgressType.accessEgressModeToLink); config.qsim().setMainModes(Arrays.asList(modes)); config.qsim().setLinkDynamics(QSimConfigGroup.LinkDynamics.PassingQ); diff --git a/contribs/vsp/src/test/java/playground/vsp/cadyts/marginals/ModalDistanceCadytsMultipleDistancesIT.java b/contribs/vsp/src/test/java/playground/vsp/cadyts/marginals/ModalDistanceCadytsMultipleDistancesIT.java index 124c01956d1..c1a5a6a1e74 100644 --- a/contribs/vsp/src/test/java/playground/vsp/cadyts/marginals/ModalDistanceCadytsMultipleDistancesIT.java +++ b/contribs/vsp/src/test/java/playground/vsp/cadyts/marginals/ModalDistanceCadytsMultipleDistancesIT.java @@ -137,9 +137,9 @@ private Config createConfig() { Config config = ConfigUtils.createConfig(); String[] modes = new String[]{TransportMode.car, TransportMode.bike}; - config.controler().setOutputDirectory(this.utils.getOutputDirectory()); - config.controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists); - config.controler().setLastIteration(20); + config.controller().setOutputDirectory(this.utils.getOutputDirectory()); + config.controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists); + config.controller().setLastIteration(20); config.counts().setWriteCountsInterval(1); config.counts().setAverageCountsOverIterations(1); @@ -148,7 +148,7 @@ private Config createConfig() { home.setMinimalDuration(6 * 3600); home.setTypicalDuration(6 * 3600); home.setEarliestEndTime(6 * 3600); - config.planCalcScore().addActivityParams(home); + config.scoring().addActivityParams(home); ScoringConfigGroup.ActivityParams work = new ScoringConfigGroup.ActivityParams("work"); work.setMinimalDuration(8 * 3600); @@ -156,25 +156,25 @@ private Config createConfig() { work.setEarliestEndTime(14 * 3600); work.setOpeningTime(6 * 3600); work.setClosingTime(18 * 3600); - config.planCalcScore().addActivityParams(work); + config.scoring().addActivityParams(work); // have random selection of plans to generate heterogenity in the beginning, so that cadyts can calibrate its correction ReplanningConfigGroup.StrategySettings selectRandom = new ReplanningConfigGroup.StrategySettings(); selectRandom.setStrategyName(DefaultPlanStrategiesModule.DefaultSelector.SelectRandom); selectRandom.setDisableAfter(17); selectRandom.setWeight(0.5); - config.strategy().addStrategySettings(selectRandom); + config.replanning().addStrategySettings(selectRandom); // have change exp beta, so that mode distribution converges at the end of the simulation ReplanningConfigGroup.StrategySettings changeExpBeta = new ReplanningConfigGroup.StrategySettings(); changeExpBeta.setStrategyName(DefaultPlanStrategiesModule.DefaultSelector.ChangeExpBeta); changeExpBeta.setWeight(0.5); - config.strategy().addStrategySettings(changeExpBeta); + config.replanning().addStrategySettings(changeExpBeta); // remove teleported bike - config.plansCalcRoute().removeModeRoutingParams(TransportMode.bike); - config.plansCalcRoute().setNetworkModes(Arrays.asList(modes)); - config.plansCalcRoute().setAccessEgressType(AccessEgressType.accessEgressModeToLink); + config.routing().removeModeRoutingParams(TransportMode.bike); + config.routing().setNetworkModes(Arrays.asList(modes)); + config.routing().setAccessEgressType(AccessEgressType.accessEgressModeToLink); config.qsim().setMainModes(Arrays.asList(modes)); config.qsim().setLinkDynamics(QSimConfigGroup.LinkDynamics.PassingQ); diff --git a/contribs/vsp/src/test/java/playground/vsp/cadyts/marginals/ModalDistanceCadytsSingleDistanceIT.java b/contribs/vsp/src/test/java/playground/vsp/cadyts/marginals/ModalDistanceCadytsSingleDistanceIT.java index 3f60fa30150..cbd93316434 100644 --- a/contribs/vsp/src/test/java/playground/vsp/cadyts/marginals/ModalDistanceCadytsSingleDistanceIT.java +++ b/contribs/vsp/src/test/java/playground/vsp/cadyts/marginals/ModalDistanceCadytsSingleDistanceIT.java @@ -141,9 +141,9 @@ private Config createConfig() { Config config = ConfigUtils.createConfig(); String[] modes = new String[]{TransportMode.car, TransportMode.bike}; - config.controler().setOutputDirectory(this.utils.getOutputDirectory()); - config.controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists); - config.controler().setLastIteration(20); + config.controller().setOutputDirectory(this.utils.getOutputDirectory()); + config.controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists); + config.controller().setLastIteration(20); config.counts().setWriteCountsInterval(1); config.counts().setAverageCountsOverIterations(1); @@ -152,7 +152,7 @@ private Config createConfig() { home.setMinimalDuration(6 * 3600); home.setTypicalDuration(6 * 3600); home.setEarliestEndTime(6 * 3600); - config.planCalcScore().addActivityParams(home); + config.scoring().addActivityParams(home); ScoringConfigGroup.ActivityParams work = new ScoringConfigGroup.ActivityParams("work"); work.setMinimalDuration(8 * 3600); @@ -160,25 +160,25 @@ private Config createConfig() { work.setEarliestEndTime(14 * 3600); work.setOpeningTime(6 * 3600); work.setClosingTime(18 * 3600); - config.planCalcScore().addActivityParams(work); + config.scoring().addActivityParams(work); // have random selection of plans to generate heterogenity in the beginning, so that cadyts can calibrate its correction ReplanningConfigGroup.StrategySettings selectRandom = new ReplanningConfigGroup.StrategySettings(); selectRandom.setStrategyName(DefaultPlanStrategiesModule.DefaultSelector.SelectRandom); selectRandom.setDisableAfter(17); selectRandom.setWeight(0.5); - config.strategy().addStrategySettings(selectRandom); + config.replanning().addStrategySettings(selectRandom); // have change exp beta, so that mode distribution converges at the end of the simulation ReplanningConfigGroup.StrategySettings changeExpBeta = new ReplanningConfigGroup.StrategySettings(); changeExpBeta.setStrategyName(DefaultPlanStrategiesModule.DefaultSelector.ChangeExpBeta); changeExpBeta.setWeight(0.5); - config.strategy().addStrategySettings(changeExpBeta); + config.replanning().addStrategySettings(changeExpBeta); // remove teleported bike - config.plansCalcRoute().removeModeRoutingParams(TransportMode.bike); - config.plansCalcRoute().setNetworkModes(Arrays.asList(modes)); - config.plansCalcRoute().setAccessEgressType(RoutingConfigGroup.AccessEgressType.accessEgressModeToLink); + config.routing().removeModeRoutingParams(TransportMode.bike); + config.routing().setNetworkModes(Arrays.asList(modes)); + config.routing().setAccessEgressType(RoutingConfigGroup.AccessEgressType.accessEgressModeToLink); config.qsim().setMainModes(Arrays.asList(modes)); config.qsim().setLinkDynamics(QSimConfigGroup.LinkDynamics.PassingQ); @@ -191,7 +191,7 @@ private Config createConfig() { config.travelTimeCalculator().setFilterModes(true); config.changeMode().setModes(modes); config.changeMode().setBehavior(ChangeModeConfigGroup.Behavior.fromSpecifiedModesToSpecifiedModes); - config.strategy().setFractionOfIterationsToDisableInnovation(0.8); + config.replanning().setFractionOfIterationsToDisableInnovation(0.8); return config; } diff --git a/contribs/vsp/src/test/java/playground/vsp/cadyts/marginals/TripEventHandlerTest.java b/contribs/vsp/src/test/java/playground/vsp/cadyts/marginals/TripEventHandlerTest.java index baeb3517fc9..83439dd2480 100644 --- a/contribs/vsp/src/test/java/playground/vsp/cadyts/marginals/TripEventHandlerTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/cadyts/marginals/TripEventHandlerTest.java @@ -48,11 +48,11 @@ public void test() throws MalformedURLException { config.plans().setHandlingOfPlansWithoutRoutingMode(HandlingOfPlansWithoutRoutingMode.useMainModeIdentifier); // use the config and run only one iteration - config.controler().setFirstIteration(0); - config.controler().setLastIteration(0); - config.controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists); - config.controler().setOutputDirectory(utils.getOutputDirectory()); - config.plansCalcRoute().setAccessEgressType(RoutingConfigGroup.AccessEgressType.accessEgressModeToLink); + config.controller().setFirstIteration(0); + config.controller().setLastIteration(0); + config.controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists); + config.controller().setOutputDirectory(utils.getOutputDirectory()); + config.routing().setAccessEgressType(RoutingConfigGroup.AccessEgressType.accessEgressModeToLink); Scenario scenario = ScenarioUtils.loadScenario(config); diff --git a/contribs/vsp/src/test/java/playground/vsp/congestion/AdvancedMarginalCongestionPricingIT.java b/contribs/vsp/src/test/java/playground/vsp/congestion/AdvancedMarginalCongestionPricingIT.java index 8c299d141e6..78942907bdf 100644 --- a/contribs/vsp/src/test/java/playground/vsp/congestion/AdvancedMarginalCongestionPricingIT.java +++ b/contribs/vsp/src/test/java/playground/vsp/congestion/AdvancedMarginalCongestionPricingIT.java @@ -241,7 +241,7 @@ public final void test1(){ String configFile = testUtils.getPackageInputDirectory() + "AdvancedMarginalCongestionPricingTest/config1.xml"; Config config = ConfigUtils.loadConfig( configFile ) ; - config.plansCalcRoute().setAccessEgressType(AccessEgressType.none); + config.routing().setAccessEgressType(AccessEgressType.none); final Scenario scenario = ScenarioUtils.loadScenario( config ); Controler controler = new Controler( scenario ); @@ -279,7 +279,7 @@ public void handleEvent(PersonMoneyEvent event) { final CongestionTollTimeDistanceTravelDisutilityFactory tollDisutilityCalculatorFactory = new CongestionTollTimeDistanceTravelDisutilityFactory( new RandomizingTimeDistanceTravelDisutilityFactory(TransportMode.car, config), - tollHandler, controler.getConfig().planCalcScore()); + tollHandler, controler.getConfig().scoring()); controler.addOverridingModule(new AbstractModule() { @Override public void install() { @@ -296,7 +296,7 @@ public ControlerListener get() { }); controler.addOverridingModule(new OTFVisFileWriterModule()); - controler.getConfig().controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles); + controler.getConfig().controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles); controler.run(); // test if there is only one congestion event and only one money event @@ -308,11 +308,11 @@ public ControlerListener get() { Assert.assertEquals("Wrong delay.", 2.0, delay, MatsimTestUtils.EPSILON); double amountFromEvent = moneyEvents.get(0).getAmount(); - double tripDelayDisutility = delay / 3600. * controler.getConfig().planCalcScore().getModes().get(TransportMode.car).getMarginalUtilityOfTraveling() * (-1); + double tripDelayDisutility = delay / 3600. * controler.getConfig().scoring().getModes().get(TransportMode.car).getMarginalUtilityOfTraveling() * (-1); // with delay --> 70.570685898554200 // without delay --> 70.573360291244900 double activityDelayDisutility = 70.573360291244900 - 70.570685898554200; - double amount = (-1) * (activityDelayDisutility + tripDelayDisutility) / controler.getConfig().planCalcScore().getMarginalUtilityOfMoney(); + double amount = (-1) * (activityDelayDisutility + tripDelayDisutility) / controler.getConfig().scoring().getMarginalUtilityOfMoney(); Assert.assertEquals("Wrong amount.", amount, amountFromEvent, MatsimTestUtils.EPSILON); } @@ -323,7 +323,7 @@ public final void test2(){ String configFile = testUtils.getPackageInputDirectory() + "AdvancedMarginalCongestionPricingTest/config2.xml"; Config config = ConfigUtils.loadConfig( configFile ) ; - config.plansCalcRoute().setAccessEgressType(AccessEgressType.none); + config.routing().setAccessEgressType(AccessEgressType.none); final Scenario scenario = ScenarioUtils.loadScenario( config ); Controler controler = new Controler( scenario ); @@ -360,7 +360,7 @@ public void handleEvent(PersonMoneyEvent event) { final TollHandler tollHandler = new TollHandler(controler.getScenario()); final CongestionTollTimeDistanceTravelDisutilityFactory tollDisutilityCalculatorFactory = new CongestionTollTimeDistanceTravelDisutilityFactory( new RandomizingTimeDistanceTravelDisutilityFactory(TransportMode.car, config), - tollHandler, controler.getConfig().planCalcScore()); + tollHandler, controler.getConfig().scoring()); controler.addOverridingModule(new AbstractModule() { @Override public void install() { @@ -376,7 +376,7 @@ public ControlerListener get() { } }); controler.addOverridingModule(new OTFVisFileWriterModule()); - controler.getConfig().controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles); + controler.getConfig().controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles); controler.run(); // test if there is only one congestion event and only one money event @@ -388,7 +388,7 @@ public ControlerListener get() { Assert.assertEquals("Wrong delay.", 2.0, delay, MatsimTestUtils.EPSILON); double amountFromEvent = moneyEvents.get(0).getAmount(); - double tripDelayDisutility = delay / 3600. * controler.getConfig().planCalcScore().getModes().get(TransportMode.car).getMarginalUtilityOfTraveling() * (-1); + double tripDelayDisutility = delay / 3600. * controler.getConfig().scoring().getModes().get(TransportMode.car).getMarginalUtilityOfTraveling() * (-1); // home duration morning: 28800. // home duration evening with delay: (24 * 3600.) - 57705. @@ -398,7 +398,7 @@ public ControlerListener get() { // without delay --> 80.584243964094500 double activityDelayDisutility = 80.584243964094500 - 80.581739442040600; - double amount = (-1) * (activityDelayDisutility + tripDelayDisutility) / controler.getConfig().planCalcScore().getMarginalUtilityOfMoney(); + double amount = (-1) * (activityDelayDisutility + tripDelayDisutility) / controler.getConfig().scoring().getMarginalUtilityOfMoney(); Assert.assertEquals("Wrong amount.", amount, amountFromEvent, MatsimTestUtils.EPSILON); } @@ -409,7 +409,7 @@ public final void test3(){ String configFile = testUtils.getPackageInputDirectory() + "AdvancedMarginalCongestionPricingTest/config3.xml"; Config config = ConfigUtils.loadConfig( configFile ) ; - config.plansCalcRoute().setAccessEgressType(AccessEgressType.none); + config.routing().setAccessEgressType(AccessEgressType.none); final Scenario scenario = ScenarioUtils.loadScenario( config); Controler controler = new Controler( scenario ); @@ -446,7 +446,7 @@ public void handleEvent(PersonMoneyEvent event) { final TollHandler tollHandler = new TollHandler(controler.getScenario()); final CongestionTollTimeDistanceTravelDisutilityFactory tollDisutilityCalculatorFactory = new CongestionTollTimeDistanceTravelDisutilityFactory( new RandomizingTimeDistanceTravelDisutilityFactory(TransportMode.car, config), - tollHandler, controler.getConfig().planCalcScore()); + tollHandler, controler.getConfig().scoring()); controler.addOverridingModule(new AbstractModule() { @Override public void install() { @@ -462,7 +462,7 @@ public ControlerListener get() { } }); controler.addOverridingModule(new OTFVisFileWriterModule()); - controler.getConfig().controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles); + controler.getConfig().controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles); controler.run(); // test if there are three congestion events and three money events @@ -477,7 +477,7 @@ public final void test4(){ String configFile = testUtils.getPackageInputDirectory() + "AdvancedMarginalCongestionPricingTest/config4.xml"; Config config = ConfigUtils.loadConfig( configFile ) ; - config.plansCalcRoute().setAccessEgressType(AccessEgressType.none); + config.routing().setAccessEgressType(AccessEgressType.none); final Scenario scenario = ScenarioUtils.loadScenario( config ); Controler controler = new Controler( scenario ); @@ -514,7 +514,7 @@ public void handleEvent(PersonMoneyEvent event) { final TollHandler tollHandler = new TollHandler(controler.getScenario()); final CongestionTollTimeDistanceTravelDisutilityFactory tollDisutilityCalculatorFactory = new CongestionTollTimeDistanceTravelDisutilityFactory( new RandomizingTimeDistanceTravelDisutilityFactory(TransportMode.car, config), - tollHandler, controler.getConfig().planCalcScore()); + tollHandler, controler.getConfig().scoring()); controler.addOverridingModule(new AbstractModule() { @Override public void install() { @@ -530,7 +530,7 @@ public ControlerListener get() { } }); controler.addOverridingModule(new OTFVisFileWriterModule()); - controler.getConfig().controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles); + controler.getConfig().controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles); controler.run(); // test if there are three congestion events and three money events diff --git a/contribs/vsp/src/test/java/playground/vsp/congestion/MarginalCongestionHandlerFlowSpillbackQueueQsimTest.java b/contribs/vsp/src/test/java/playground/vsp/congestion/MarginalCongestionHandlerFlowSpillbackQueueQsimTest.java index a878b7ff8d0..0a5aae8bb70 100644 --- a/contribs/vsp/src/test/java/playground/vsp/congestion/MarginalCongestionHandlerFlowSpillbackQueueQsimTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/congestion/MarginalCongestionHandlerFlowSpillbackQueueQsimTest.java @@ -317,7 +317,7 @@ public final void testRouting(){ Config config = ConfigUtils.loadConfig( configFile ) ; - config.plansCalcRoute().setAccessEgressType(RoutingConfigGroup.AccessEgressType.none); + config.routing().setAccessEgressType(RoutingConfigGroup.AccessEgressType.none); final Scenario scenario = ScenarioUtils.loadScenario( config ); Controler controler = new Controler( scenario ); @@ -326,7 +326,7 @@ public final void testRouting(){ final CongestionTollTimeDistanceTravelDisutilityFactory tollDisutilityCalculatorFactory = new CongestionTollTimeDistanceTravelDisutilityFactory( new RandomizingTimeDistanceTravelDisutilityFactory(TransportMode.car, config), - tollHandler, controler.getConfig().planCalcScore()); + tollHandler, controler.getConfig().scoring()); controler.addOverridingModule(new AbstractModule() { @Override public void install() { @@ -402,14 +402,14 @@ public void handleEvent(LinkLeaveEvent event) { @Override public void notifyIterationStarts(IterationStartsEvent event) { // last but one iteration - if(((event.getServices().getConfig().controler().getLastIteration())-(event.getIteration()))==1){ + if(((event.getServices().getConfig().controller().getLastIteration())-(event.getIteration()))==1){ avgValue1 = tollHandler.getAvgToll(linkId2_, 28800); avgValue2 = tollHandler.getAvgToll(linkId2_, 29700); avgOldValue1 = tollHandler.getAvgTollOldValue(linkId2_, 28800); avgOldValue2 = tollHandler.getAvgTollOldValue(linkId2_, 28800); } // last iteration - else if(((event.getServices().getConfig().controler().getLastIteration())-(event.getIteration()))==0){ + else if(((event.getServices().getConfig().controller().getLastIteration())-(event.getIteration()))==0){ avgValue3 = tollHandler.getAvgToll(linkId2_, 28800); avgValue4 = tollHandler.getAvgToll(linkId2_, 29700); avgOldValue3 = tollHandler.getAvgTollOldValue(linkId2_, 28800); @@ -419,7 +419,7 @@ else if(((event.getServices().getConfig().controler().getLastIteration())-(event }); - controler.getConfig().controler().setOverwriteFileSetting( + controler.getConfig().controller().setOverwriteFileSetting( OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles ); controler.run(); diff --git a/contribs/vsp/src/test/java/playground/vsp/congestion/MarginalCongestionHandlerV3Test.java b/contribs/vsp/src/test/java/playground/vsp/congestion/MarginalCongestionHandlerV3Test.java index 8fb1bd44714..2c040502c4d 100644 --- a/contribs/vsp/src/test/java/playground/vsp/congestion/MarginalCongestionHandlerV3Test.java +++ b/contribs/vsp/src/test/java/playground/vsp/congestion/MarginalCongestionHandlerV3Test.java @@ -70,7 +70,7 @@ public final void testCongestionExample(){ final List congestionEvents = new ArrayList(); Config config = ConfigUtils.loadConfig( configFile ) ; - config.plansCalcRoute().setAccessEgressType(RoutingConfigGroup.AccessEgressType.none); + config.routing().setAccessEgressType(RoutingConfigGroup.AccessEgressType.none); final Controler controler = new Controler(config); controler.addOverridingModule(new AbstractModule() { @@ -92,7 +92,7 @@ public void install() { } }); - controler.getConfig().controler().setOverwriteFileSetting( OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles ); + controler.getConfig().controller().setOverwriteFileSetting( OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles ); controler.run(); // process diff --git a/contribs/vsp/src/test/java/playground/vsp/ev/CreateUrbanEVTestScenario.java b/contribs/vsp/src/test/java/playground/vsp/ev/CreateUrbanEVTestScenario.java index 3eba4b6c109..94a9ea4604c 100644 --- a/contribs/vsp/src/test/java/playground/vsp/ev/CreateUrbanEVTestScenario.java +++ b/contribs/vsp/src/test/java/playground/vsp/ev/CreateUrbanEVTestScenario.java @@ -45,17 +45,17 @@ static Scenario createTestScenario(){ evReplanningCfg.setCriticalSOC(0.4); //TODO actually, should also work with all AccessEgressTypes but we have to check (write JUnit test) - config.plansCalcRoute().setAccessEgressType( RoutingConfigGroup.AccessEgressType.none ); + config.routing().setAccessEgressType( RoutingConfigGroup.AccessEgressType.none ); //register charging interaction activities for car - config.planCalcScore().addActivityParams( + config.scoring().addActivityParams( new ScoringConfigGroup.ActivityParams( TransportMode.car + UrbanEVModule.PLUGOUT_INTERACTION).setScoringThisActivityAtAll(false ) ); - config.planCalcScore().addActivityParams( + config.scoring().addActivityParams( new ScoringConfigGroup.ActivityParams( TransportMode.car + UrbanEVModule.PLUGIN_INTERACTION).setScoringThisActivityAtAll( false ) ); config.network().setInputFile("1pctNetwork.xml"); - config.controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles); - config.controler().setLastIteration(5); - config.controler().setWriteEventsInterval(1); + config.controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles); + config.controller().setLastIteration(5); + config.controller().setWriteEventsInterval(1); //set VehicleSource config.qsim().setVehiclesSource(QSimConfigGroup.VehiclesSource.fromVehiclesData); config.qsim().setEndTime(20*3600); diff --git a/contribs/vsp/src/test/java/playground/vsp/ev/TransferFinalSocToNextIterTest.java b/contribs/vsp/src/test/java/playground/vsp/ev/TransferFinalSocToNextIterTest.java index 27d07e6f589..b77b0352fc0 100644 --- a/contribs/vsp/src/test/java/playground/vsp/ev/TransferFinalSocToNextIterTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/ev/TransferFinalSocToNextIterTest.java @@ -52,8 +52,8 @@ public class TransferFinalSocToNextIterTest { @Test public void test() { //adapt scenario - scenario.getConfig().controler().setLastIteration(LAST_ITERATION); - scenario.getConfig().controler().setOutputDirectory("test/output/playground/vsp/ev/FinalSoc2VehicleTypeTest/"); + scenario.getConfig().controller().setLastIteration(LAST_ITERATION); + scenario.getConfig().controller().setOutputDirectory("test/output/playground/vsp/ev/FinalSoc2VehicleTypeTest/"); var vehicle1 = scenario.getVehicles().getVehicles().get(Id.create("Triple Charger_car", Vehicle.class)); ElectricVehicleSpecifications.setInitialSoc(vehicle1, INITIAL_SOC); diff --git a/contribs/vsp/src/test/java/playground/vsp/ev/UrbanEVTests.java b/contribs/vsp/src/test/java/playground/vsp/ev/UrbanEVTests.java index c4fc69df74c..aa1e6143b24 100644 --- a/contribs/vsp/src/test/java/playground/vsp/ev/UrbanEVTests.java +++ b/contribs/vsp/src/test/java/playground/vsp/ev/UrbanEVTests.java @@ -63,9 +63,9 @@ public class UrbanEVTests { @BeforeClass public static void run() { Scenario scenario = CreateUrbanEVTestScenario.createTestScenario(); - scenario.getConfig().controler().setOutputDirectory("test/output/playground/vsp/ev/UrbanEVTests/"); + scenario.getConfig().controller().setOutputDirectory("test/output/playground/vsp/ev/UrbanEVTests/"); - scenario.getConfig().controler().setLastIteration(0); + scenario.getConfig().controller().setLastIteration(0); //modify population overridePopulation(scenario); diff --git a/contribs/vsp/src/test/java/playground/vsp/flowEfficiency/HierarchicalFLowEfficiencyCalculatorTest.java b/contribs/vsp/src/test/java/playground/vsp/flowEfficiency/HierarchicalFLowEfficiencyCalculatorTest.java index da0ab06db96..d8033195348 100644 --- a/contribs/vsp/src/test/java/playground/vsp/flowEfficiency/HierarchicalFLowEfficiencyCalculatorTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/flowEfficiency/HierarchicalFLowEfficiencyCalculatorTest.java @@ -1,7 +1,6 @@ package playground.vsp.flowEfficiency; import com.google.inject.Provides; -import com.google.inject.name.Names; import org.junit.Assert; import org.junit.Before; import org.junit.Rule; @@ -26,7 +25,6 @@ import org.matsim.contrib.dvrp.run.DvrpConfigGroup; import org.matsim.contrib.dvrp.run.DvrpModule; import org.matsim.contrib.dvrp.run.DvrpQSimComponents; -import org.matsim.contrib.dvrp.vrpagent.VrpAgentSourceQSimModule; import org.matsim.core.api.experimental.events.EventsManager; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; @@ -91,7 +89,7 @@ public void simulate(){ "eight_shared_taxi_config.xml"); Config config = ConfigUtils.loadConfig(configUrl, new DvrpConfigGroup(), new MultiModeDrtConfigGroup(), new OTFVisConfigGroup()); - config.controler().setOutputDirectory(utils.getOutputDirectory()); + config.controller().setOutputDirectory(utils.getOutputDirectory()); config.qsim().setEndTime(4*3600); MultiModeDrtConfigGroup multiModeDrtConfigGroup = ConfigUtils.addOrGetModule(config, MultiModeDrtConfigGroup.class); @@ -301,4 +299,4 @@ public void reset(int iteration) { } -} \ No newline at end of file +} diff --git a/contribs/vsp/src/test/java/playground/vsp/pt/fare/PtTripFareEstimatorTest.java b/contribs/vsp/src/test/java/playground/vsp/pt/fare/PtTripFareEstimatorTest.java index 24d58706664..e4b686fc810 100644 --- a/contribs/vsp/src/test/java/playground/vsp/pt/fare/PtTripFareEstimatorTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/pt/fare/PtTripFareEstimatorTest.java @@ -52,7 +52,7 @@ public void setUp() throws Exception { Config config = TestScenario.loadConfig(utils); - Map modes = config.planCalcScore().getScoringParameters("person").getModes(); + Map modes = config.scoring().getScoringParameters("person").getModes(); ScoringConfigGroup.ModeParams pt = modes.get(TransportMode.pt); ScoringConfigGroup.ModeParams walk = modes.get(TransportMode.walk); diff --git a/contribs/vsp/src/test/java/playground/vsp/pt/ptdisturbances/EditTripsTest.java b/contribs/vsp/src/test/java/playground/vsp/pt/ptdisturbances/EditTripsTest.java index d82509af72c..d56ed2539a7 100644 --- a/contribs/vsp/src/test/java/playground/vsp/pt/ptdisturbances/EditTripsTest.java +++ b/contribs/vsp/src/test/java/playground/vsp/pt/ptdisturbances/EditTripsTest.java @@ -120,7 +120,7 @@ public void testAgentStaysAtStop() { Config config = ConfigUtils .loadConfig(configURL); String outputDirectory = utils.getOutputDirectory(); - config.controler() + config.controller() .setOutputDirectory(outputDirectory); Scenario scenario = ScenarioUtils.loadScenario(config); scenario.getPopulation().getPersons().clear(); @@ -160,7 +160,7 @@ public void testAgentLeavesStop() { Config config = ConfigUtils.loadConfig(configURL); config.transit().setRoutingAlgorithmType(TransitRoutingAlgorithmType.DijkstraBased); String outputDirectory = utils.getOutputDirectory(); - config.controler().setOutputDirectory(outputDirectory); + config.controller().setOutputDirectory(outputDirectory); Scenario scenario = ScenarioUtils.loadScenario(config); scenario.getPopulation().getPersons().clear(); double activityEndTime = 7. * 3600 + 15. * 60; @@ -198,7 +198,7 @@ public void testAgentStaysInVehicle() { Config config = ConfigUtils .loadConfig(configURL);; String outputDirectory = utils.getOutputDirectory(); - config.controler() + config.controller() .setOutputDirectory(outputDirectory); config.network().setTimeVariantNetwork(true); Scenario scenario = ScenarioUtils.loadScenario(config); @@ -235,7 +235,7 @@ public void testAgentLeavesVehicleAtNextStop() { Config config = ConfigUtils .loadConfig(configURL); String outputDirectory = utils.getOutputDirectory(); - config.controler() + config.controller() .setOutputDirectory(outputDirectory); Scenario scenario = ScenarioUtils.loadScenario(config); scenario.getPopulation().getPersons().clear(); @@ -279,7 +279,7 @@ public void testAgentIsAtTeleportLegAndLeavesStop() { Config config = ConfigUtils.loadConfig(configURL); config.transit().setRoutingAlgorithmType(TransitRoutingAlgorithmType.DijkstraBased); String outputDirectory = utils.getOutputDirectory(); - config.controler().setOutputDirectory(outputDirectory); + config.controller().setOutputDirectory(outputDirectory); Scenario scenario = ScenarioUtils.loadScenario(config); scenario.getPopulation().getPersons().clear(); double activityEndTime = 7. * 3600 + 22. * 60; @@ -318,10 +318,10 @@ public void testAgentIsAtTeleportLegAndWaitsAtStop_walkUnattractive() { Config config = ConfigUtils .loadConfig(configURL);; String outputDirectory = utils.getOutputDirectory(); - config.controler() + config.controller() .setOutputDirectory(outputDirectory); - config.planCalcScore().getModes().get(TransportMode.walk).setMarginalUtilityOfTraveling( - config.planCalcScore().getModes().get(TransportMode.walk).getMarginalUtilityOfTraveling() - 3); + config.scoring().getModes().get(TransportMode.walk).setMarginalUtilityOfTraveling( + config.scoring().getModes().get(TransportMode.walk).getMarginalUtilityOfTraveling() - 3); Scenario scenario = ScenarioUtils.loadScenario(config); scenario.getPopulation().getPersons().clear(); double activityEndTime = 7. * 3600 + 22. * 60; @@ -358,7 +358,7 @@ public void testAgentIsAtTeleportLegAndWaitsAtStop() { Config config = ConfigUtils.loadConfig(configURL); config.transit().setRoutingAlgorithmType(TransitRoutingAlgorithmType.DijkstraBased); String outputDirectory = utils.getOutputDirectory(); - config.controler().setOutputDirectory(outputDirectory); + config.controller().setOutputDirectory(outputDirectory); Scenario scenario = ScenarioUtils.loadScenario(config); scenario.getPopulation().getPersons().clear(); double activityEndTime = 7. * 3600 + 22. * 60; @@ -396,7 +396,7 @@ public void testOneAgentEveryFourSeconds() { Config config = ConfigUtils .loadConfig(configURL); String outputDirectory = utils.getOutputDirectory(); - config.controler() + config.controller() .setOutputDirectory(outputDirectory); Scenario scenario = ScenarioUtils.loadScenario(config); scenario.getPopulation().getPersons().clear(); @@ -421,7 +421,7 @@ public void testOneAgentEveryFourSeconds() { } assertTrue("Number of used lines ist not plausible", numberOfUsedLines == 1 || numberOfUsedLines == 2); } - System.out.println(config.controler().getOutputDirectory()); + System.out.println(config.controller().getOutputDirectory()); } diff --git a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/IndividualRaptorParametersForPerson.java b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/IndividualRaptorParametersForPerson.java index 9f276c3cf9f..447e81c7b30 100644 --- a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/IndividualRaptorParametersForPerson.java +++ b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/IndividualRaptorParametersForPerson.java @@ -41,7 +41,7 @@ public RaptorParameters getRaptorParameters(Person person) { raptorParameters.setMarginalUtilityOfWaitingPt_utl_s( scoringParameters.marginalUtilityOfWaitingPt_s - marginalUtilityOfPerforming); - ScoringConfigGroup pcsConfig = config.planCalcScore(); + ScoringConfigGroup pcsConfig = config.scoring(); for (Map.Entry e : pcsConfig.getModes().entrySet()) { String mode = e.getKey(); diff --git a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/RaptorUtils.java b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/RaptorUtils.java index 7a9e3b38034..63b080cfdd8 100644 --- a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/RaptorUtils.java +++ b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/RaptorUtils.java @@ -36,7 +36,7 @@ private RaptorUtils() { } public static RaptorStaticConfig createStaticConfig(Config config) { - RoutingConfigGroup pcrConfig = config.plansCalcRoute(); + RoutingConfigGroup pcrConfig = config.routing(); SwissRailRaptorConfigGroup srrConfig = ConfigUtils.addOrGetModule(config, SwissRailRaptorConfigGroup.class); RaptorStaticConfig staticConfig = new RaptorStaticConfig(); @@ -73,7 +73,7 @@ public static RaptorParameters createParameters(Config config) { raptorParams.setMarginalUtilityOfWaitingPt_utl_s(trConfig.getMarginalUtilityOfWaitingPt_utl_s()); - ScoringConfigGroup pcsConfig = config.planCalcScore(); + ScoringConfigGroup pcsConfig = config.scoring(); double marginalUtilityPerforming = pcsConfig.getPerforming_utils_hr() / 3600.0; for (Map.Entry e : pcsConfig.getModes().entrySet()) { String mode = e.getKey(); diff --git a/matsim/src/main/java/org/matsim/analysis/IterationTravelStatsControlerListener.java b/matsim/src/main/java/org/matsim/analysis/IterationTravelStatsControlerListener.java index 4f2b25530d0..17ea8796459 100644 --- a/matsim/src/main/java/org/matsim/analysis/IterationTravelStatsControlerListener.java +++ b/matsim/src/main/java/org/matsim/analysis/IterationTravelStatsControlerListener.java @@ -90,8 +90,8 @@ public void notifyIterationEnds(IterationEndsEvent event) { pkMbyModeCalculator.addIteration(event.getIteration(), experiencedPlansService.getExperiencedPlans()); pHbyModeCalculator.writeOutput(); pkMbyModeCalculator.writeOutput(); - final boolean writingTripsAtAll = config.controler().getWriteTripsInterval() > 0; - final boolean regularWriteEvents = writingTripsAtAll && ((event.getIteration() > 0 && event.getIteration() % config.controler().getWriteTripsInterval() == 0) || event.isLastIteration()); + final boolean writingTripsAtAll = config.controller().getWriteTripsInterval() > 0; + final boolean regularWriteEvents = writingTripsAtAll && ((event.getIteration() > 0 && event.getIteration() % config.controller().getWriteTripsInterval() == 0) || event.isLastIteration()); if (regularWriteEvents || (writingTripsAtAll && event.getIteration() == 0)) { new TripsAndLegsCSVWriter(scenario, customTripsWriterExtension, customLegsWriterExtension, mainModeIdentifier, customTimeWriter).write(experiencedPlansService.getExperiencedPlans() , outputDirectoryHierarchy.getIterationFilename(event.getIteration(), Controler.DefaultFiles.tripscsv) @@ -106,7 +106,7 @@ public void notifyIterationEnds(IterationEndsEvent event) { public void notifyShutdown(ShutdownEvent event) { travelDistanceStats.close(); - if (config.controler().getWriteTripsInterval() > 0) { + if (config.controller().getWriteTripsInterval() > 0) { writePersonsCSV(); } } diff --git a/matsim/src/main/java/org/matsim/analysis/TravelDistanceStats.java b/matsim/src/main/java/org/matsim/analysis/TravelDistanceStats.java index 060e5ae9e43..7387cb0536d 100644 --- a/matsim/src/main/java/org/matsim/analysis/TravelDistanceStats.java +++ b/matsim/src/main/java/org/matsim/analysis/TravelDistanceStats.java @@ -81,7 +81,7 @@ public class TravelDistanceStats { * @throws UncheckedIOException */ public TravelDistanceStats(final Config config, final String filename, final boolean createPNG) throws UncheckedIOException { - this(config.controler(), filename, filename + "legs", filename + "trips", createPNG); + this(config.controller(), filename, filename + "legs", filename + "trips", createPNG); } private TravelDistanceStats(ControllerConfigGroup controllerConfigGroup, String travelDistanceStatsFileName, diff --git a/matsim/src/main/java/org/matsim/core/config/Config.java b/matsim/src/main/java/org/matsim/core/config/Config.java index b577ea51114..de7facd728a 100644 --- a/matsim/src/main/java/org/matsim/core/config/Config.java +++ b/matsim/src/main/java/org/matsim/core/config/Config.java @@ -400,7 +400,7 @@ public final GlobalConfigGroup global() { return (GlobalConfigGroup) this.getModule(GlobalConfigGroup.GROUP_NAME); } - public final ControllerConfigGroup controler() { + public final ControllerConfigGroup controller() { return (ControllerConfigGroup) this.getModule(ControllerConfigGroup.GROUP_NAME); } @@ -408,7 +408,7 @@ public final CountsConfigGroup counts() { return (CountsConfigGroup) this.getModule(CountsConfigGroup.GROUP_NAME); } - public final ScoringConfigGroup planCalcScore() { + public final ScoringConfigGroup scoring() { return (ScoringConfigGroup) this.getModule(ScoringConfigGroup.GROUP_NAME); } @@ -428,7 +428,7 @@ public final FacilitiesConfigGroup facilities() { return (FacilitiesConfigGroup) this.getModule(FacilitiesConfigGroup.GROUP_NAME); } - public final ReplanningConfigGroup strategy() { + public final ReplanningConfigGroup replanning() { return (ReplanningConfigGroup) this.getModule(ReplanningConfigGroup.GROUP_NAME); } @@ -440,7 +440,7 @@ public ScenarioConfigGroup scenario() { return (ScenarioConfigGroup) this.getModule(ScenarioConfigGroup.GROUP_NAME); } - public RoutingConfigGroup plansCalcRoute() { + public RoutingConfigGroup routing() { return (RoutingConfigGroup) this.getModule(RoutingConfigGroup.GROUP_NAME); } @@ -472,7 +472,7 @@ public TimeAllocationMutatorConfigGroup timeAllocationMutator() { return (TimeAllocationMutatorConfigGroup) this.getModule(TimeAllocationMutatorConfigGroup.GROUP_NAME); } - public EventsManagerConfigGroup parallelEventHandling() { + public EventsManagerConfigGroup eventsManager() { return (EventsManagerConfigGroup) this.getModule(EventsManagerConfigGroup.GROUP_NAME); } diff --git a/matsim/src/main/java/org/matsim/core/config/ConfigUtils.java b/matsim/src/main/java/org/matsim/core/config/ConfigUtils.java index ba671deeb5c..8747648e176 100644 --- a/matsim/src/main/java/org/matsim/core/config/ConfigUtils.java +++ b/matsim/src/main/java/org/matsim/core/config/ConfigUtils.java @@ -236,7 +236,7 @@ public static void modifyFilePaths(final Config config, final String pathPrefix) if (!prefix.endsWith("/") && !prefix.endsWith(File.separator)) { prefix = prefix + File.separator; } - config.controler().setOutputDirectory(getAbsolutePath(prefix, config.controler().getOutputDirectory())); + config.controller().setOutputDirectory(getAbsolutePath(prefix, config.controller().getOutputDirectory())); config.network().setInputFile(getAbsolutePath(prefix, config.network().getInputFile())); config.plans().setInputFile(getAbsolutePath(prefix, config.plans().getInputFile())); config.facilities().setInputFile(getAbsolutePath(prefix, config.facilities().getInputFile())); @@ -263,7 +263,7 @@ private static String getAbsolutePath(final String prefix, final String path) { // (Had the problem in RandomizingTransitRotuerIT.) kai, dec'19 public static Id createAvailableStrategyId(Config config) { long maxStrategyId = 0; - for( StrategySettings strategySettings : config.strategy().getStrategySettings() ){ + for( StrategySettings strategySettings : config.replanning().getStrategySettings() ){ maxStrategyId = Math.max( maxStrategyId , Long.parseLong( strategySettings.getId().toString() ) ); } return Id.create(maxStrategyId + 1, StrategySettings.class); diff --git a/matsim/src/main/java/org/matsim/core/config/consistency/ConfigConsistencyCheckerImpl.java b/matsim/src/main/java/org/matsim/core/config/consistency/ConfigConsistencyCheckerImpl.java index 30040a7ee6e..f00ec94def2 100644 --- a/matsim/src/main/java/org/matsim/core/config/consistency/ConfigConsistencyCheckerImpl.java +++ b/matsim/src/main/java/org/matsim/core/config/consistency/ConfigConsistencyCheckerImpl.java @@ -68,29 +68,29 @@ static boolean checkConsistencyBetweenRouterAndTravelTimeCalculator( final Confi } /*package because of test */ static void checkPlanCalcScore(final Config c) { - ModeParams ptModeParams = c.planCalcScore().getModes().get(TransportMode.pt); + ModeParams ptModeParams = c.scoring().getModes().get(TransportMode.pt); if (ptModeParams!=null && ptModeParams.getMarginalUtilityOfTraveling() > 0) { log.warn(ScoringConfigGroup.GROUP_NAME + ".travelingPt is > 0. This values specifies a utility. " + "Typically, this should be a disutility, i.e. have a negative value."); } - ModeParams carModeParams = c.planCalcScore().getModes().get(TransportMode.car); + ModeParams carModeParams = c.scoring().getModes().get(TransportMode.car); if (carModeParams!=null && carModeParams.getMarginalUtilityOfTraveling() > 0) { log.warn(ScoringConfigGroup.GROUP_NAME + ".traveling is > 0. This values specifies a utility. " + "Typically, this should be a disutility, i.e. have a negative value."); } - ModeParams bikeModeParams = c.planCalcScore().getModes().get(TransportMode.bike); + ModeParams bikeModeParams = c.scoring().getModes().get(TransportMode.bike); if (bikeModeParams!=null && bikeModeParams.getMarginalUtilityOfTraveling() > 0) { log.warn(ScoringConfigGroup.GROUP_NAME + ".travelingBike is > 0. This values specifies a utility. " + "Typically, this should be a disutility, i.e. have a negative value."); } - ModeParams walkModeParams = c.planCalcScore().getModes().get(TransportMode.walk); + ModeParams walkModeParams = c.scoring().getModes().get(TransportMode.walk); if (walkModeParams!=null && walkModeParams.getMarginalUtilityOfTraveling() > 0) { log.warn(ScoringConfigGroup.GROUP_NAME + ".travelingWalk is > 0. This values specifies a utility. " + "Typically, this should be a disutility, i.e. have a negative value."); } - ActivityParams ptAct = c.planCalcScore().getActivityParams(PtConstants.TRANSIT_ACTIVITY_TYPE) ; + ActivityParams ptAct = c.scoring().getActivityParams(PtConstants.TRANSIT_ACTIVITY_TYPE) ; if ( ptAct != null ) { // if ( ptAct.getClosingTime()!=0. && ptAct.getClosingTime()!=Time.getUndefinedTime() ) { // if ( !c.vspExperimental().isAbleToOverwritePtInteractionParams()==true ) { @@ -110,7 +110,7 @@ static boolean checkConsistencyBetweenRouterAndTravelTimeCalculator( final Confi private static void checkEventsFormatLanesSignals(final Config c) { if (c.qsim().isUseLanes()) { - if (!c.controler().getEventsFileFormats().contains(EventsFileFormat.xml)){ + if (!c.controller().getEventsFileFormats().contains(EventsFileFormat.xml)){ log.error("Xml events are not enabled, but lanes and possibly signal systems" + "are enalbed. Events from this features will only be written to the xml format, consider" + "to add xml events in the controler config module"); @@ -119,7 +119,7 @@ private static void checkEventsFormatLanesSignals(final Config c) { } private static void checkScenarioFeaturesEnabled(final Config c) { - if (! ("qsim".equals(c.controler().getMobsim()) || c.qsim() != null)){ + if (! ("qsim".equals(c.controller().getMobsim()) || c.qsim() != null)){ log.warn("The signal system implementation is only supported by the org.matsim.ptproject.qsim mobility simulation that is not activated. Please make sure you are using the correct" + "mobility simulation. This warning can be ingored if a customized mobility simulation developed outside of org.matsim is used and set correctly."); } @@ -127,7 +127,7 @@ private static void checkScenarioFeaturesEnabled(final Config c) { private static void checkTravelTimeCalculationRoutingConfiguration(final Config config){ - if (config.controler().isLinkToLinkRoutingEnabled() && + if (config.controller().isLinkToLinkRoutingEnabled() && !config.travelTimeCalculator().isCalculateLinkToLinkTravelTimes()){ throw new IllegalStateException("LinkToLinkRouting is activated in config and" + " link to link traveltime calculation is not enabled but required!"); @@ -135,7 +135,7 @@ private static void checkTravelTimeCalculationRoutingConfiguration(final Config if (config.travelTimeCalculator().isCalculateLinkTravelTimes() && config.travelTimeCalculator().isCalculateLinkToLinkTravelTimes() && - !config.controler().isLinkToLinkRoutingEnabled()) { + !config.controller().isLinkToLinkRoutingEnabled()) { log.warn("Config enables link travel time calculation and link to link " + "travel time calculation. This requires at least twice as much memory as " + "if only one method is used, however it might be necessary to enable " + @@ -153,8 +153,8 @@ private static void checkTravelTimeCalculationRoutingConfiguration(final Config "available if using the remove stuck vehicles option!"); } - if ( config.controler().isLinkToLinkRoutingEnabled() && - config.controler().getRoutingAlgorithmType() != RoutingAlgorithmType.Dijkstra ) { + if ( config.controller().isLinkToLinkRoutingEnabled() && + config.controller().getRoutingAlgorithmType() != RoutingAlgorithmType.Dijkstra ) { log.warn("We don't know if non-Dijkstra routing works together with LinkToLink routing."); } @@ -163,7 +163,7 @@ private static void checkTravelTimeCalculationRoutingConfiguration(final Config private static void checkLaneDefinitionRoutingConfiguration(final Config config) { if ((config.qsim().isUseLanes()) && - !config.controler().isLinkToLinkRoutingEnabled()){ + !config.controller().isLinkToLinkRoutingEnabled()){ log.warn("Using lanes without enabling linktolinkrouting might not lead to expected simulation results"); } } diff --git a/matsim/src/main/java/org/matsim/core/config/consistency/VspConfigConsistencyCheckerImpl.java b/matsim/src/main/java/org/matsim/core/config/consistency/VspConfigConsistencyCheckerImpl.java index 162a2d3b744..901d5da4b5c 100644 --- a/matsim/src/main/java/org/matsim/core/config/consistency/VspConfigConsistencyCheckerImpl.java +++ b/matsim/src/main/java/org/matsim/core/config/consistency/VspConfigConsistencyCheckerImpl.java @@ -130,7 +130,7 @@ public void checkConsistency(Config config) { // === interaction between config groups: boolean containsModeChoice = false ; - for ( StrategySettings settings : config.strategy().getStrategySettings() ) { + for ( StrategySettings settings : config.replanning().getStrategySettings() ) { if ( settings.getStrategyName().contains("Mode") ) { containsModeChoice = true ; } @@ -189,7 +189,7 @@ private static void checkTravelTimeCalculatorConfigGroup( Config config, Level l } private static boolean checkStrategyConfigGroup( Config config, Level lvl, boolean problem ){ boolean found = false ; - Collection settingsColl = config.strategy().getStrategySettings(); + Collection settingsColl = config.replanning().getStrategySettings(); for ( StrategySettings settings : settingsColl ) { if ( settings.getStrategyName().equalsIgnoreCase("ChangeExpBeta") ) { found = true ; @@ -202,7 +202,7 @@ private static boolean checkStrategyConfigGroup( Config config, Level lvl, boole } // added may'16 - if ( config.strategy().getFractionOfIterationsToDisableInnovation()==Double.POSITIVE_INFINITY ) { + if ( config.replanning().getFractionOfIterationsToDisableInnovation()==Double.POSITIVE_INFINITY ) { problem = true ; System.out.flush() ; log.log( lvl, "You have not set fractionOfIterationsToDisableInnovation; vsp default is to set this to 0.8 or similar. Add the following config lines:" ) ; @@ -213,7 +213,7 @@ private static boolean checkStrategyConfigGroup( Config config, Level lvl, boole // added nov'15 boolean usingTimeMutator = false ; - for ( StrategySettings it : config.strategy().getStrategySettings() ) { + for ( StrategySettings it : config.replanning().getStrategySettings() ) { if ( DefaultStrategy.TimeAllocationMutator.equals( it.getName() ) ) { usingTimeMutator = true ; break ; @@ -243,7 +243,7 @@ private static boolean checkStrategyConfigGroup( Config config, Level lvl, boole // added jun'22 boolean usingSMC = false ; - for ( StrategySettings it : config.strategy().getStrategySettings() ) { + for ( StrategySettings it : config.replanning().getStrategySettings() ) { if ( DefaultStrategy.SubtourModeChoice.equals( it.getName() ) ) { usingSMC = true ; break ; @@ -339,7 +339,7 @@ private static boolean checkPlansConfigGroup( Config config, Level lvl, boolean } private static boolean checkPlanCalcScoreConfigGroup( Config config, Level lvl, boolean problem ){ // use beta_brain=1 // added as of nov'12 - if ( config.planCalcScore().getBrainExpBeta() != 1. ) { + if ( config.scoring().getBrainExpBeta() != 1. ) { problem = true ; System.out.flush() ; log.log( lvl, "You are using a brainExpBeta != 1; vsp default is 1. (Different values may cause conceptual " + @@ -350,14 +350,14 @@ private static boolean checkPlanCalcScoreConfigGroup( Config config, Level lvl, } // added aug'13: - if ( config.planCalcScore().getMarginalUtlOfWaiting_utils_hr() != 0. ) { + if ( config.scoring().getMarginalUtlOfWaiting_utils_hr() != 0. ) { problem = true ; System.out.flush() ; log.log( lvl, "found marginal utility of waiting != 0. vsp default is setting this to 0. " ) ; } // added apr'15: - for ( ActivityParams params : config.planCalcScore().getActivityParams() ) { + for ( ActivityParams params : config.scoring().getActivityParams() ) { if ( PtConstants.TRANSIT_ACTIVITY_TYPE.equals( params.getActivityType() ) ) { // they have typicalDurationScoreComputation==relative, but are not scored anyways. benjamin/kai, nov'15 continue ; @@ -373,7 +373,7 @@ private static boolean checkPlanCalcScoreConfigGroup( Config config, Level lvl, throw new RuntimeException("unexpected setting; aborting ... ") ; } } - for ( ModeParams params : config.planCalcScore().getModes().values() ) { + for ( ModeParams params : config.scoring().getModes().values() ) { if ( params.getMonetaryDistanceRate() > 0. ) { problem = true ; System.out.flush() ; @@ -385,28 +385,28 @@ private static boolean checkPlanCalcScoreConfigGroup( Config config, Level lvl, } } - if ( config.planCalcScore().getModes().get(TransportMode.car ) != null && config.planCalcScore().getModes().get(TransportMode.car ).getMonetaryDistanceRate() > 0 ) { + if ( config.scoring().getModes().get(TransportMode.car ) != null && config.scoring().getModes().get(TransportMode.car ).getMonetaryDistanceRate() > 0 ) { problem = true ; } - final ModeParams modeParamsPt = config.planCalcScore().getModes().get(TransportMode.pt ); + final ModeParams modeParamsPt = config.scoring().getModes().get(TransportMode.pt ); if ( modeParamsPt!=null && modeParamsPt.getMonetaryDistanceRate() > 0 ) { problem = true ; System.out.flush() ; log.error("found monetary distance rate pt > 0. You probably want a value < 0 here." ) ; } - if ( config.planCalcScore().getMarginalUtilityOfMoney() < 0. ) { + if ( config.scoring().getMarginalUtilityOfMoney() < 0. ) { problem = true ; System.out.flush() ; log.error("found marginal utility of money < 0. You almost certainly want a value > 0 here. " ) ; } // added feb'16 - if ( config.plansCalcRoute().getAccessEgressType().equals(RoutingConfigGroup.AccessEgressType.none ) ) { + if ( config.routing().getAccessEgressType().equals(RoutingConfigGroup.AccessEgressType.none ) ) { log.log( lvl, "found `PlansCalcRouteConfigGroup.AccessEgressType.none'; vsp should use `accessEgressModeToLink' or " + "some other value or talk to Kai." ) ; } // added oct'17: - if ( config.planCalcScore().getFractionOfIterationsToStartScoreMSA() == null || config.planCalcScore().getFractionOfIterationsToStartScoreMSA() >= 1. ) { + if ( config.scoring().getFractionOfIterationsToStartScoreMSA() == null || config.scoring().getFractionOfIterationsToStartScoreMSA() >= 1. ) { problem = true ; System.out.flush() ; log.log( lvl, "You are not setting fractionOfIterationsToStartScoreMSA; vsp default is to set this to something like 0.8. " + @@ -417,7 +417,7 @@ private static boolean checkPlanCalcScoreConfigGroup( Config config, Level lvl, } // added apr'21: - for( Map.Entry entry : config.planCalcScore().getScoringParametersPerSubpopulation().entrySet() ){ + for( Map.Entry entry : config.scoring().getScoringParametersPerSubpopulation().entrySet() ){ for( ActivityParams activityParam : entry.getValue().getActivityParams() ){ if( activityParam.getMinimalDuration().isDefined() ){ log.log( lvl, "Vsp default is to not define minimal duration. Activity type=" + activityParam.getActivityType() + "; subpopulation=" + entry.getKey() ); @@ -426,7 +426,7 @@ private static boolean checkPlanCalcScoreConfigGroup( Config config, Level lvl, } // added may'23 - for ( ModeParams params : config.planCalcScore().getModes().values() ){ + for ( ModeParams params : config.scoring().getModes().values() ){ if ( config.vspExperimental().getCheckingOfMarginalUtilityOfTravellng()== CheckingOfMarginalUtilityOfTravellng.allZero ){ if( params.getMarginalUtilityOfTraveling() != 0. ){ log.log( lvl, "You are setting the marginal utility of traveling with mode " + params.getMode() + " to " + params.getMarginalUtilityOfTraveling() @@ -478,7 +478,7 @@ private static boolean checkFacilitiesConfigGroup( Config config, Level lvl, boo return problem; } private static boolean checkControlerConfigGroup( Config config, Level lvl, boolean problem ){ - Set formats = config.controler().getEventsFileFormats(); + Set formats = config.controller().getEventsFileFormats(); if ( !formats.contains( EventsFileFormat.xml ) ) { problem = true ; System.out.flush() ; @@ -486,7 +486,7 @@ private static boolean checkControlerConfigGroup( Config config, Level lvl, bool } // may'21 - switch ( config.controler().getRoutingAlgorithmType() ) { + switch ( config.controller().getRoutingAlgorithmType() ) { case Dijkstra: case AStarLandmarks: log.log( lvl, "you are not using SpeedyALT as routing algorithm. vsp default (since may'21) is to use SpeedeALT.") ; diff --git a/matsim/src/main/java/org/matsim/core/config/groups/ControllerConfigGroup.java b/matsim/src/main/java/org/matsim/core/config/groups/ControllerConfigGroup.java index f9488228a42..f1d8bae8b6a 100644 --- a/matsim/src/main/java/org/matsim/core/config/groups/ControllerConfigGroup.java +++ b/matsim/src/main/java/org/matsim/core/config/groups/ControllerConfigGroup.java @@ -430,7 +430,7 @@ public void setWriteEventsUntilIteration(int val) { } @Override protected void checkConsistency(Config config) { - if ( config.controler().getOverwriteFileSetting() == OverwriteFileSetting.overwriteExistingFiles ) { + if ( config.controller().getOverwriteFileSetting() == OverwriteFileSetting.overwriteExistingFiles ) { log.warn( "setting overwriting behavior to "+overwriteFileSetting ); log.warn( "this is not recommended, as it might result in a directory containing output from several model runs" ); log.warn( "prefer the options "+OverwriteFileSetting.deleteDirectoryIfExists+" or "+OverwriteFileSetting.failIfDirectoryExists ); diff --git a/matsim/src/main/java/org/matsim/core/config/groups/ScoringConfigGroup.java b/matsim/src/main/java/org/matsim/core/config/groups/ScoringConfigGroup.java index d2d926805d6..2f7955e23fc 100644 --- a/matsim/src/main/java/org/matsim/core/config/groups/ScoringConfigGroup.java +++ b/matsim/src/main/java/org/matsim/core/config/groups/ScoringConfigGroup.java @@ -633,7 +633,7 @@ protected final void checkConsistency(final Config config) { for (ScoringParameterSet scoringParameterSet : this.getScoringParametersPerSubpopulation().values()) { - for (String mode : config.plansCalcRoute().getNetworkModes()) { + for (String mode : config.routing().getNetworkModes()) { createAndAddInteractionActivity( scoringParameterSet, mode ); } // (In principle, the for loop following next should be sufficient, i.e. taking the necessary modes from scoring. diff --git a/matsim/src/main/java/org/matsim/core/controler/AbstractController.java b/matsim/src/main/java/org/matsim/core/controler/AbstractController.java index a335453cea5..f18d01fa576 100644 --- a/matsim/src/main/java/org/matsim/core/controler/AbstractController.java +++ b/matsim/src/main/java/org/matsim/core/controler/AbstractController.java @@ -46,7 +46,7 @@ private Integer thisIteration = null; - + protected AbstractController() { this(new ControlerListenerManagerImpl(), new IterationStopWatch(), null); } @@ -97,7 +97,7 @@ public void shutdown(boolean unexpected) { protected abstract void runMobSim(); protected abstract void prepareForSim(); - + protected abstract void prepareForMobsim() ; /** @@ -112,11 +112,11 @@ public void shutdown(boolean unexpected) { protected abstract boolean shouldTerminate(int iteration); private void doIterations(Config config) throws MatsimRuntimeModifications.UnexpectedShutdownException { - int iteration = config.controler().getFirstIteration(); - + int iteration = config.controller().getFirstIteration(); + // Special case if lastIteration == -1 -> Do not run any Mobsim - boolean doTerminate = config.controler().getLastIteration() < iteration; - + boolean doTerminate = config.controller().getLastIteration() < iteration; + while (!doTerminate) { boolean isLastIteration = mayTerminateAfterIteration(iteration); iteration(config, iteration, isLastIteration); @@ -124,7 +124,7 @@ private void doIterations(Config config) throws MatsimRuntimeModifications.Unexp iteration++; } } - + final String MARKER = "### "; private void iteration(final Config config, final int iteration, boolean isLastIteration) throws MatsimRuntimeModifications.UnexpectedShutdownException { @@ -143,7 +143,7 @@ public void run() { } }); - if (iteration > config.controler().getFirstIteration()) { + if (iteration > config.controller().getFirstIteration()) { iterationStep("replanning", new Runnable() { @Override public void run() { @@ -176,7 +176,7 @@ public void run() { } catch (UncheckedIOException e) { log.error("Could not write stopwatch file.", e); } - if (config.controler().isCreateGraphs()) { + if (config.controller().isCreateGraphs()) { this.getStopwatch().writeGraphFile(this.getControlerIO().getOutputFilename("stopwatch")); } log.info(MARKER + "ITERATION " + iteration + " ENDS"); @@ -196,7 +196,7 @@ public void run() { controlerListenerManagerImpl.fireControlerBeforeMobsimEvent(iteration, isLastIteration); } }); - + iterationStep( "prepareForMobsim", new Runnable(){ @Override public void run() { diff --git a/matsim/src/main/java/org/matsim/core/controler/Controler.java b/matsim/src/main/java/org/matsim/core/controler/Controler.java index 43f893d8a41..bc7fbdc47da 100755 --- a/matsim/src/main/java/org/matsim/core/controler/Controler.java +++ b/matsim/src/main/java/org/matsim/core/controler/Controler.java @@ -194,7 +194,7 @@ private Controler(final String configFileName, final Config config, Scenario sce //scenario = ScenarioUtils.createScenario(this.config); //ScenarioUtils.loadScenario(scenario) ; } - this.config.parallelEventHandling().makeLocked(); + this.config.eventsManager().makeLocked(); this.scenario = scenario; this.overrides = scenario == null ? new ScenarioByConfigModule() : diff --git a/matsim/src/main/java/org/matsim/core/controler/OutputDirectoryHierarchy.java b/matsim/src/main/java/org/matsim/core/controler/OutputDirectoryHierarchy.java index fa69f8d803c..86272160a77 100644 --- a/matsim/src/main/java/org/matsim/core/controler/OutputDirectoryHierarchy.java +++ b/matsim/src/main/java/org/matsim/core/controler/OutputDirectoryHierarchy.java @@ -72,7 +72,7 @@ public enum OverwriteFileSetting {failIfDirectoryExists, overwriteExistingFiles, * @param config */ public OutputDirectoryHierarchy( Config config ) { - this( config.controler().getOutputDirectory(), config.controler().getRunId(), config.controler().getOverwriteFileSetting(), config.controler().getCompressionType() ); + this( config.controller().getOutputDirectory(), config.controller().getRunId(), config.controller().getOverwriteFileSetting(), config.controller().getCompressionType() ); } public OutputDirectoryHierarchy(String outputPath, OverwriteFileSetting overwriteFiles, ControllerConfigGroup.CompressionType defaultCompressionType) { diff --git a/matsim/src/main/java/org/matsim/core/controler/PrepareForSimImpl.java b/matsim/src/main/java/org/matsim/core/controler/PrepareForSimImpl.java index e1e15970ef7..628a67c532a 100644 --- a/matsim/src/main/java/org/matsim/core/controler/PrepareForSimImpl.java +++ b/matsim/src/main/java/org/matsim/core/controler/PrepareForSimImpl.java @@ -266,7 +266,7 @@ private Map getVehicleTypesForAllNetworkAndMainModes() { } Set modes = new HashSet<>(qSimConfigGroup.getMainModes()); - modes.addAll(scenario.getConfig().plansCalcRoute().getNetworkModes()); + modes.addAll(scenario.getConfig().routing().getNetworkModes()); for (String mode : modes) { VehicleType type; diff --git a/matsim/src/main/java/org/matsim/core/controler/corelisteners/DumpDataAtEndImpl.java b/matsim/src/main/java/org/matsim/core/controler/corelisteners/DumpDataAtEndImpl.java index 21388d19e1e..74d2d84ce14 100644 --- a/matsim/src/main/java/org/matsim/core/controler/corelisteners/DumpDataAtEndImpl.java +++ b/matsim/src/main/java/org/matsim/core/controler/corelisteners/DumpDataAtEndImpl.java @@ -200,7 +200,7 @@ private void dumpOutputLegs(int iteration) { } private void dumpExperiencedPlans(int iteration) { - if (this.config.planCalcScore().isWriteExperiencedPlans() ) { + if (this.config.scoring().isWriteExperiencedPlans() ) { try { IOUtils.copyFile(this.controlerIO.getIterationFilename(iteration, Controler.DefaultFiles.experiencedPlans), this.controlerIO.getOutputFilename(Controler.DefaultFiles.experiencedPlans)); diff --git a/matsim/src/main/java/org/matsim/core/events/EventsManagerModule.java b/matsim/src/main/java/org/matsim/core/events/EventsManagerModule.java index ca7c38ce61b..f6c8b093339 100644 --- a/matsim/src/main/java/org/matsim/core/events/EventsManagerModule.java +++ b/matsim/src/main/java/org/matsim/core/events/EventsManagerModule.java @@ -34,10 +34,10 @@ public final class EventsManagerModule extends AbstractModule { @Override public void install() { - if (BooleanUtils.isTrue(getConfig().parallelEventHandling().getOneThreadPerHandler())) { + if (BooleanUtils.isTrue(getConfig().eventsManager().getOneThreadPerHandler())) { bindEventsManager().to(ParallelEventsManager.class).in(Singleton.class); - } else if (getConfig().parallelEventHandling().getNumberOfThreads() != null) { - if (BooleanUtils.isTrue(getConfig().parallelEventHandling().getSynchronizeOnSimSteps())) { + } else if (getConfig().eventsManager().getNumberOfThreads() != null) { + if (BooleanUtils.isTrue(getConfig().eventsManager().getSynchronizeOnSimSteps())) { bindEventsManager().to(SimStepParallelEventsManagerImpl.class).in(Singleton.class); } else { bindEventsManager().to(ParallelEventsManagerImpl.class).in(Singleton.class); diff --git a/matsim/src/main/java/org/matsim/core/events/ParallelEventsManager.java b/matsim/src/main/java/org/matsim/core/events/ParallelEventsManager.java index 287cc7eb216..996816efebe 100644 --- a/matsim/src/main/java/org/matsim/core/events/ParallelEventsManager.java +++ b/matsim/src/main/java/org/matsim/core/events/ParallelEventsManager.java @@ -59,7 +59,7 @@ public final class ParallelEventsManager implements EventsManager { @Inject ParallelEventsManager(Config config) { - this(config.parallelEventHandling().getSynchronizeOnSimSteps() != null ? config.parallelEventHandling().getSynchronizeOnSimSteps() : true, config.parallelEventHandling().getEventsQueueSize()); + this(config.eventsManager().getSynchronizeOnSimSteps() != null ? config.eventsManager().getSynchronizeOnSimSteps() : true, config.eventsManager().getEventsQueueSize()); } diff --git a/matsim/src/main/java/org/matsim/core/events/ParallelEventsManagerImpl.java b/matsim/src/main/java/org/matsim/core/events/ParallelEventsManagerImpl.java index 64287c3acdb..820e8874ee2 100644 --- a/matsim/src/main/java/org/matsim/core/events/ParallelEventsManagerImpl.java +++ b/matsim/src/main/java/org/matsim/core/events/ParallelEventsManagerImpl.java @@ -82,10 +82,10 @@ public final class ParallelEventsManagerImpl implements EventsManager { @Inject ParallelEventsManagerImpl(Config config) { - if (config.parallelEventHandling().getEstimatedNumberOfEvents() != null) { - preInputBufferMaxLength = (int) (config.parallelEventHandling().getEstimatedNumberOfEvents() / 10); + if (config.eventsManager().getEstimatedNumberOfEvents() != null) { + preInputBufferMaxLength = (int) (config.eventsManager().getEstimatedNumberOfEvents() / 10); } - init(config.parallelEventHandling().getNumberOfThreads()); + init(config.eventsManager().getNumberOfThreads()); } /** diff --git a/matsim/src/main/java/org/matsim/core/mobsim/DefaultMobsimModule.java b/matsim/src/main/java/org/matsim/core/mobsim/DefaultMobsimModule.java index 95bf5b8f13f..eb5463a2e7c 100644 --- a/matsim/src/main/java/org/matsim/core/mobsim/DefaultMobsimModule.java +++ b/matsim/src/main/java/org/matsim/core/mobsim/DefaultMobsimModule.java @@ -34,13 +34,13 @@ public class DefaultMobsimModule extends AbstractModule { @Override public void install() { - if (getConfig().controler().getMobsim().equals(ControllerConfigGroup.MobsimType.qsim.toString())) { + if (getConfig().controller().getMobsim().equals(ControllerConfigGroup.MobsimType.qsim.toString())) { install(new QSimModule()); // bind( RelativePositionOfEntryExitOnLink.class ).toInstance( () -> 1. ); - } else if (getConfig().controler().getMobsim().equals(ControllerConfigGroup.MobsimType.JDEQSim.toString())) { + } else if (getConfig().controller().getMobsim().equals(ControllerConfigGroup.MobsimType.JDEQSim.toString())) { bindMobsim().to(JDEQSimulation.class); // bind( RelativePositionOfEntryExitOnLink.class ).toInstance( () -> 0. ); - } else if (getConfig().controler().getMobsim().equals(ControllerConfigGroup.MobsimType.hermes.toString())) { + } else if (getConfig().controller().getMobsim().equals(ControllerConfigGroup.MobsimType.hermes.toString())) { bindMobsim().toProvider(HermesProvider.class); } else if (getConfig().getModule(ExternalMobimConfigGroup.GROUP_NAME) != null && ((ExternalMobimConfigGroup)getConfig().getModule( diff --git a/matsim/src/main/java/org/matsim/core/mobsim/hermes/HermesConfigGroup.java b/matsim/src/main/java/org/matsim/core/mobsim/hermes/HermesConfigGroup.java index 61f82aa42ce..044f374dfb1 100644 --- a/matsim/src/main/java/org/matsim/core/mobsim/hermes/HermesConfigGroup.java +++ b/matsim/src/main/java/org/matsim/core/mobsim/hermes/HermesConfigGroup.java @@ -20,7 +20,6 @@ import jakarta.validation.constraints.Positive; import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.TransportMode; import org.matsim.core.config.Config; import org.matsim.core.config.ReflectiveConfigGroup; @@ -168,7 +167,7 @@ public Map getComments() { @Override protected void checkConsistency(Config config) { super.checkConsistency(config); - if (config.parallelEventHandling().getOneThreadPerHandler()!=true && config.controler().getMobsim().equals("hermes")){ + if (config.eventsManager().getOneThreadPerHandler()!=true && config.controller().getMobsim().equals("hermes")){ LogManager.getLogger(getClass()).warn("Hermes should be run with one thread per handler."); } } diff --git a/matsim/src/main/java/org/matsim/core/mobsim/qsim/DefaultTeleportationEngine.java b/matsim/src/main/java/org/matsim/core/mobsim/qsim/DefaultTeleportationEngine.java index 2b7d7823a67..86d1759be15 100644 --- a/matsim/src/main/java/org/matsim/core/mobsim/qsim/DefaultTeleportationEngine.java +++ b/matsim/src/main/java/org/matsim/core/mobsim/qsim/DefaultTeleportationEngine.java @@ -96,7 +96,7 @@ public boolean handleDeparture(double now, MobsimAgent agent, Id linkId) { double travelTime = agent.getExpectedTravelTime().seconds() ; if ( withTravelTimeCheck ) { - Double speed = scenario.getConfig().plansCalcRoute().getTeleportedModeSpeeds().get( agent.getMode() ) ; + Double speed = scenario.getConfig().routing().getTeleportedModeSpeeds().get( agent.getMode() ) ; Facility dpfac = agent.getCurrentFacility() ; Facility arfac = agent.getDestinationFacility() ; travelTime = DefaultTeleportationEngine.travelTimeCheck(travelTime, speed, dpfac, arfac); diff --git a/matsim/src/main/java/org/matsim/core/population/io/PopulationReaderMatsimV5.java b/matsim/src/main/java/org/matsim/core/population/io/PopulationReaderMatsimV5.java index b3a6fbf06c2..ccd67415f17 100644 --- a/matsim/src/main/java/org/matsim/core/population/io/PopulationReaderMatsimV5.java +++ b/matsim/src/main/java/org/matsim/core/population/io/PopulationReaderMatsimV5.java @@ -269,9 +269,9 @@ private void finishLastRoute() { Coord toCoord = getCoord(this.curract); if (fromCoord != null && toCoord != null) { double dist = CoordUtils.calcEuclideanDistance(fromCoord, toCoord); - if ( this.scenario.getConfig().plansCalcRoute(). + if ( this.scenario.getConfig().routing(). getModeRoutingParams().containsKey( this.currleg.getMode() ) ) { - double estimatedNetworkDistance = dist * this.scenario.getConfig().plansCalcRoute(). + double estimatedNetworkDistance = dist * this.scenario.getConfig().routing(). getModeRoutingParams().get( this.currleg.getMode() ).getBeelineDistanceFactor() ; this.currRoute.setDistance(estimatedNetworkDistance); } @@ -376,9 +376,9 @@ private void endRoute(final String content) { Coord toCoord = getCoord(this.curract); if (fromCoord != null && toCoord != null) { double dist = CoordUtils.calcEuclideanDistance(fromCoord, toCoord); - if ( this.scenario.getConfig().plansCalcRoute(). + if ( this.scenario.getConfig().routing(). getModeRoutingParams().containsKey( this.currleg.getMode() ) ) { - double estimatedNetworkDistance = dist * this.scenario.getConfig().plansCalcRoute(). + double estimatedNetworkDistance = dist * this.scenario.getConfig().routing(). getModeRoutingParams().get( this.currleg.getMode() ).getBeelineDistanceFactor() ; this.currRoute.setDistance(estimatedNetworkDistance); } diff --git a/matsim/src/main/java/org/matsim/core/population/io/PopulationReaderMatsimV6.java b/matsim/src/main/java/org/matsim/core/population/io/PopulationReaderMatsimV6.java index dfbd02452d7..725ffb83654 100644 --- a/matsim/src/main/java/org/matsim/core/population/io/PopulationReaderMatsimV6.java +++ b/matsim/src/main/java/org/matsim/core/population/io/PopulationReaderMatsimV6.java @@ -396,9 +396,9 @@ private void finishLastRoute() { Coord toCoord = getCoord(this.curract); if (fromCoord != null && toCoord != null) { double dist = CoordUtils.calcEuclideanDistance(fromCoord, toCoord); - if ( this.scenario.getConfig().plansCalcRoute(). + if ( this.scenario.getConfig().routing(). getModeRoutingParams().containsKey( this.currleg.getMode() ) ) { - double estimatedNetworkDistance = dist * this.scenario.getConfig().plansCalcRoute(). + double estimatedNetworkDistance = dist * this.scenario.getConfig().routing(). getModeRoutingParams().get( this.currleg.getMode() ).getBeelineDistanceFactor() ; this.currRoute.setDistance(estimatedNetworkDistance); } @@ -507,9 +507,9 @@ private void endRoute(final String content) { Coord toCoord = getCoord(this.curract); if (fromCoord != null && toCoord != null) { double dist = CoordUtils.calcEuclideanDistance(fromCoord, toCoord); - if ( this.scenario.getConfig().plansCalcRoute(). + if ( this.scenario.getConfig().routing(). getModeRoutingParams().containsKey( this.currleg.getMode() ) ) { - double estimatedNetworkDistance = dist * this.scenario.getConfig().plansCalcRoute(). + double estimatedNetworkDistance = dist * this.scenario.getConfig().routing(). getModeRoutingParams().get( this.currleg.getMode() ).getBeelineDistanceFactor() ; this.currRoute.setDistance(estimatedNetworkDistance); } diff --git a/matsim/src/main/java/org/matsim/core/replanning/StrategyManagerModule.java b/matsim/src/main/java/org/matsim/core/replanning/StrategyManagerModule.java index 591329a5bcf..d42fde9fabe 100644 --- a/matsim/src/main/java/org/matsim/core/replanning/StrategyManagerModule.java +++ b/matsim/src/main/java/org/matsim/core/replanning/StrategyManagerModule.java @@ -59,7 +59,7 @@ public void install() { // (this will bind a Map that has StrategySettings as key, and PlanStrategy as value. Not sure why StrategySettings as key, and not just the name, but possibly this is mean to allow adding // the same strategy multiple times, with possibly different settings.) - for (ReplanningConfigGroup.StrategySettings settings : getConfig().strategy().getStrategySettings()) { + for (ReplanningConfigGroup.StrategySettings settings : getConfig().replanning().getStrategySettings()) { String name = settings.getStrategyName() ; if (name.equals("ExternalModule")) { // plan strategy is some external executable: diff --git a/matsim/src/main/java/org/matsim/core/replanning/annealing/ReplanningAnnealer.java b/matsim/src/main/java/org/matsim/core/replanning/annealing/ReplanningAnnealer.java index 5752b8d7dfc..b576833d9fd 100644 --- a/matsim/src/main/java/org/matsim/core/replanning/annealing/ReplanningAnnealer.java +++ b/matsim/src/main/java/org/matsim/core/replanning/annealing/ReplanningAnnealer.java @@ -91,7 +91,7 @@ public void notifyStartup(StartupEvent event) { this.currentValues.put(av.getAnnealParameter(), av.getStartValue()); header.add(av.getAnnealParameter().name()); if (av.getAnnealParameter().equals(AnnealParameterOption.globalInnovationRate)) { - header.addAll(this.config.strategy().getStrategySettings().stream() + header.addAll(this.config.replanning().getStrategySettings().stream() .filter(s -> Objects.equals(av.getDefaultSubpopulation(), s.getSubpopulation())) .map(ReplanningConfigGroup.StrategySettings::getStrategyName) .collect(Collectors.toList())); @@ -112,7 +112,7 @@ public void notifyStartup(StartupEvent event) { @Override public void notifyIterationStarts(IterationStartsEvent event) { - this.currentIter = event.getIteration() - this.config.controler().getFirstIteration(); + this.currentIter = event.getIteration() - this.config.controller().getFirstIteration(); Map annealStats = new HashMap<>(); for (AnnealingVariable av : this.saConfig.getAnnealingVariables().values()) { if (this.currentIter > 0) { @@ -140,7 +140,7 @@ public void notifyIterationStarts(IterationStartsEvent event) { break; case linear: double slope = (av.getStartValue() - av.getEndValue()) - / (this.config.controler().getFirstIteration() - this.innovationStop); + / (this.config.controller().getFirstIteration() - this.innovationStop); this.currentValues.compute(av.getAnnealParameter(), (k, v) -> this.currentIter * slope + av.getStartValue()); break; @@ -180,13 +180,13 @@ private void writeIterationstats(int currentIter, Map annealStat private void anneal(IterationStartsEvent event, AnnealingVariable av, double annealValue, Map annealStats) { switch (av.getAnnealParameter()) { case BrainExpBeta: - this.config.planCalcScore().setBrainExpBeta(annealValue); + this.config.scoring().setBrainExpBeta(annealValue); break; case PathSizeLogitBeta: - this.config.planCalcScore().setPathSizeLogitBeta(annealValue); + this.config.scoring().setPathSizeLogitBeta(annealValue); break; case learningRate: - this.config.planCalcScore().setLearningRate(annealValue); + this.config.scoring().setLearningRate(annealValue); break; case globalInnovationRate: if (this.currentIter > this.innovationStop) { @@ -195,7 +195,7 @@ private void anneal(IterationStartsEvent event, AnnealingVariable av, double ann List annealValues = annealReplanning(annealValue, event.getServices().getStrategyManager(), av.getDefaultSubpopulation()); int i = 0; - for (ReplanningConfigGroup.StrategySettings ss : this.config.strategy().getStrategySettings()) { + for (ReplanningConfigGroup.StrategySettings ss : this.config.replanning().getStrategySettings()) { if (Objects.equals(ss.getSubpopulation(), av.getDefaultSubpopulation())) { annealStats.put(ss.getStrategyName(), String.format(Locale.US, "%.4f", annealValues.get(i))); i++; @@ -262,7 +262,7 @@ private double getStrategyWeights(Config config, String subpopulation, StratType if (this.currentIter == this.innovationStop + 1 && stratType.equals(StratType.allInnovation)) { return 0.0; } - Collection strategies = config.strategy().getStrategySettings(); + Collection strategies = config.replanning().getStrategySettings(); double totalWeights = 0.0; for (ReplanningConfigGroup.StrategySettings strategy : strategies) { if (Objects.equals(strategy.getSubpopulation(), subpopulation)) { @@ -289,12 +289,12 @@ private double getStrategyWeights(Config config, String subpopulation, StratType } private int getInnovationStop(Config config) { - int globalInnovationDisableAfter = (int) ((config.controler().getLastIteration() - config.controler().getFirstIteration()) - * config.strategy().getFractionOfIterationsToDisableInnovation() + config.controler().getFirstIteration()); + int globalInnovationDisableAfter = (int) ((config.controller().getLastIteration() - config.controller().getFirstIteration()) + * config.replanning().getFractionOfIterationsToDisableInnovation() + config.controller().getFirstIteration()); int innoStop = -1; - for (ReplanningConfigGroup.StrategySettings strategy : config.strategy().getStrategySettings()) { + for (ReplanningConfigGroup.StrategySettings strategy : config.replanning().getStrategySettings()) { // check if this modules should be disabled after some iterations int maxIter = strategy.getDisableAfter(); if ((maxIter > globalInnovationDisableAfter || maxIter == -1) && isInnovationStrategy(strategy.getStrategyName())) { @@ -312,20 +312,20 @@ private int getInnovationStop(Config config) { } } - return Math.min(innoStop, config.controler().getLastIteration()); + return Math.min(innoStop, config.controller().getLastIteration()); } private void checkAndFixStartValue(ReplanningAnnealerConfigGroup.AnnealingVariable av, StartupEvent event) { double configValue; switch (av.getAnnealParameter()) { case BrainExpBeta: - configValue = this.config.planCalcScore().getBrainExpBeta(); + configValue = this.config.scoring().getBrainExpBeta(); break; case PathSizeLogitBeta: - configValue = this.config.planCalcScore().getPathSizeLogitBeta(); + configValue = this.config.scoring().getPathSizeLogitBeta(); break; case learningRate: - configValue = this.config.planCalcScore().getLearningRate(); + configValue = this.config.scoring().getLearningRate(); break; case globalInnovationRate: double innovationWeights = getStrategyWeights(this.config, av.getDefaultSubpopulation(), StratType.allInnovation); @@ -362,7 +362,7 @@ private void rescaleStartupWeights(double innovationStartValue, Config config, S stratMan.changeWeightOfStrategy(strategy, subpopulation, weight); } // adapt also in config for the record - Collection strategiesConfig = config.strategy().getStrategySettings(); + Collection strategiesConfig = config.replanning().getStrategySettings(); for (ReplanningConfigGroup.StrategySettings strategy : strategiesConfig) { if (Objects.equals(strategy.getSubpopulation(), subpopulation)) { double weight = strategy.getWeight(); diff --git a/matsim/src/main/java/org/matsim/core/replanning/modules/ExternalModule.java b/matsim/src/main/java/org/matsim/core/replanning/modules/ExternalModule.java index 7b55091f023..773e7a67148 100644 --- a/matsim/src/main/java/org/matsim/core/replanning/modules/ExternalModule.java +++ b/matsim/src/main/java/org/matsim/core/replanning/modules/ExternalModule.java @@ -27,7 +27,6 @@ import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.population.Person; import org.matsim.api.core.v01.population.Plan; -import org.matsim.api.core.v01.population.Plan; import org.matsim.api.core.v01.population.Population; import org.matsim.api.core.v01.population.PopulationWriter; import org.matsim.api.core.v01.replanning.PlanStrategyModule; @@ -79,11 +78,11 @@ interface ExeRunnerDelegate { private String outFileRoot = ""; private final OutputDirectoryHierarchy controler; - + private int currentIteration = -1; - + private Population exportPopulation; - + private Map, Plan> plansToMutate = new HashMap<>(); public ExternalModule(final String exePath, final String moduleId, final OutputDirectoryHierarchy controler, final Scenario scenario) { @@ -120,7 +119,7 @@ public void handlePlan(final Plan plan) { // Creating a dummy population which only contains the plans which are passed here. // I need to copy the plans because I am not supposed to add a plan to a different Person. // I also need to memorize the plans which are passed here, because I am supposed to mutate them. - + final Person personWithOnlySelectedPlan = this.exportPopulation.getFactory().createPerson(plan.getPerson().getId()); final Plan planForNewPerson = PopulationUtils.createPlan(personWithOnlySelectedPlan); PopulationUtils.copyFromTo(plan, planForNewPerson); @@ -149,7 +148,7 @@ private void exportPopulation() { private void prepareExternalExeConfig() { Config extConfig; - String configFileName = this.scenario.getConfig().strategy().getExternalExeConfigTemplate(); + String configFileName = this.scenario.getConfig().replanning().getExternalExeConfigTemplate(); if (configFileName == null) { extConfig = new Config(); } else { diff --git a/matsim/src/main/java/org/matsim/core/replanning/strategies/DefaultPlanStrategiesModule.java b/matsim/src/main/java/org/matsim/core/replanning/strategies/DefaultPlanStrategiesModule.java index d66df199ebc..18ff8e31436 100644 --- a/matsim/src/main/java/org/matsim/core/replanning/strategies/DefaultPlanStrategiesModule.java +++ b/matsim/src/main/java/org/matsim/core/replanning/strategies/DefaultPlanStrategiesModule.java @@ -51,19 +51,19 @@ public enum DefaultPlansRemover { WorstPlanSelector, SelectRandom, SelectExpBeta @Override public void install() { - if (getConfig().strategy().getPlanSelectorForRemoval().equals(DefaultPlansRemover.WorstPlanSelector.toString())) { + if (getConfig().replanning().getPlanSelectorForRemoval().equals(DefaultPlansRemover.WorstPlanSelector.toString())) { bindPlanSelectorForRemoval().to(WorstPlanForRemovalSelector.class); } - if (getConfig().strategy().getPlanSelectorForRemoval().equals(DefaultPlansRemover.SelectRandom.toString())) { + if (getConfig().replanning().getPlanSelectorForRemoval().equals(DefaultPlansRemover.SelectRandom.toString())) { bindPlanSelectorForRemoval().to(new TypeLiteral>(){}); } - if (getConfig().strategy().getPlanSelectorForRemoval().equals(DefaultPlansRemover.SelectExpBetaForRemoval.toString())) { + if (getConfig().replanning().getPlanSelectorForRemoval().equals(DefaultPlansRemover.SelectExpBetaForRemoval.toString())) { bindPlanSelectorForRemoval().toProvider(ExpBetaPlanSelectorForRemoval.class); } - if (getConfig().strategy().getPlanSelectorForRemoval().equals(DefaultPlansRemover.ChangeExpBetaForRemoval.toString())) { + if (getConfig().replanning().getPlanSelectorForRemoval().equals(DefaultPlansRemover.ChangeExpBetaForRemoval.toString())) { bindPlanSelectorForRemoval().toProvider(ExpBetaPlanChangerForRemoval.class); } - if (getConfig().strategy().getPlanSelectorForRemoval().equals(DefaultPlansRemover.PathSizeLogitSelectorForRemoval.toString())) { + if (getConfig().replanning().getPlanSelectorForRemoval().equals(DefaultPlansRemover.PathSizeLogitSelectorForRemoval.toString())) { bindPlanSelectorForRemoval().toProvider(PathSizeLogitSelectorForRemoval.class); } @@ -73,7 +73,7 @@ public void install() { // that's fine: The StrategyManager will still only add those strategies to itself which are configured. // But we don't want to clutter the container here. Set usedStrategyNames = new HashSet<>(); - for (ReplanningConfigGroup.StrategySettings settings : getConfig().strategy().getStrategySettings()) { + for (ReplanningConfigGroup.StrategySettings settings : getConfig().replanning().getStrategySettings()) { usedStrategyNames.add(settings.getStrategyName()); } diff --git a/matsim/src/main/java/org/matsim/core/router/LeastCostPathCalculatorModule.java b/matsim/src/main/java/org/matsim/core/router/LeastCostPathCalculatorModule.java index d0e8b99a210..d88a07ebe12 100644 --- a/matsim/src/main/java/org/matsim/core/router/LeastCostPathCalculatorModule.java +++ b/matsim/src/main/java/org/matsim/core/router/LeastCostPathCalculatorModule.java @@ -37,11 +37,11 @@ public void install() { // kai/mm, jan'17 Config config = getConfig(); - if (config.controler().getRoutingAlgorithmType().equals(ControllerConfigGroup.RoutingAlgorithmType.Dijkstra)) { + if (config.controller().getRoutingAlgorithmType().equals(ControllerConfigGroup.RoutingAlgorithmType.Dijkstra)) { bind(LeastCostPathCalculatorFactory.class).to(DijkstraFactory.class); - } else if (config.controler().getRoutingAlgorithmType().equals(ControllerConfigGroup.RoutingAlgorithmType.AStarLandmarks)) { + } else if (config.controller().getRoutingAlgorithmType().equals(ControllerConfigGroup.RoutingAlgorithmType.AStarLandmarks)) { bind(LeastCostPathCalculatorFactory.class).to(AStarLandmarksFactory.class); - } else if (config.controler().getRoutingAlgorithmType().equals(ControllerConfigGroup.RoutingAlgorithmType.SpeedyALT)) { + } else if (config.controller().getRoutingAlgorithmType().equals(ControllerConfigGroup.RoutingAlgorithmType.SpeedyALT)) { bind(LeastCostPathCalculatorFactory.class).to(SpeedyALTFactory.class); } } diff --git a/matsim/src/main/java/org/matsim/core/router/NetworkRoutingInclAccessEgressModule.java b/matsim/src/main/java/org/matsim/core/router/NetworkRoutingInclAccessEgressModule.java index ed34a5be20d..748b8c2e1d5 100644 --- a/matsim/src/main/java/org/matsim/core/router/NetworkRoutingInclAccessEgressModule.java +++ b/matsim/src/main/java/org/matsim/core/router/NetworkRoutingInclAccessEgressModule.java @@ -112,7 +112,7 @@ public final class NetworkRoutingInclAccessEgressModule implements RoutingModule this.config = scenario.getConfig(); this.accessToNetworkRouter = accessToNetworkRouter; this.egressFromNetworkRouter = egressFromNetworkRouter; - this.accessEgressType = config.plansCalcRoute().getAccessEgressType(); + this.accessEgressType = config.routing().getAccessEgressType(); this.timeInterpretation = timeInterpretation; if (accessEgressType.equals(AccessEgressType.none)) { throw new RuntimeException("trying to use access/egress but not switched on in config. " @@ -323,7 +323,7 @@ private static void routeBushwhackingLeg(Person person, Leg leg, Coord fromCoord Id dpLinkId, Id arLinkId, PopulationFactory pf, Config config) { final RoutingConfigGroup.TeleportedModeParams params; RoutingConfigGroup.TeleportedModeParams tmp; - final Map paramsMap = config.plansCalcRoute().getModeRoutingParams(); + final Map paramsMap = config.routing().getModeRoutingParams(); if ((tmp = paramsMap.get(TransportMode.non_network_walk)) != null) { params = tmp; } else if ((tmp = paramsMap.get(TransportMode.walk)) != null) { diff --git a/matsim/src/main/java/org/matsim/core/router/TripRouterModule.java b/matsim/src/main/java/org/matsim/core/router/TripRouterModule.java index 3202125dca4..bba1a592379 100644 --- a/matsim/src/main/java/org/matsim/core/router/TripRouterModule.java +++ b/matsim/src/main/java/org/matsim/core/router/TripRouterModule.java @@ -47,20 +47,20 @@ public void install() { install(new LeastCostPathCalculatorModule()); install(new TransitRouterModule()); bind(SingleModeNetworksCache.class).asEagerSingleton(); - RoutingConfigGroup routeConfigGroup = getConfig().plansCalcRoute(); + RoutingConfigGroup routeConfigGroup = getConfig().routing(); for (String mode : routeConfigGroup.getTeleportedModeFreespeedFactors().keySet()) { if (getConfig().transit().isUseTransit() && getConfig().transit().getTransitModes().contains(mode)) { // default config contains "pt" as teleported mode, but if we have simulated transit, this is supposed to override it // better solve this on the config level eventually. continue; } - addRoutingModuleBinding(mode).toProvider(new FreespeedFactorRouting(getConfig().plansCalcRoute().getModeRoutingParams().get(mode))); + addRoutingModuleBinding(mode).toProvider(new FreespeedFactorRouting(getConfig().routing().getModeRoutingParams().get(mode))); } for (String mode : routeConfigGroup.getTeleportedModeSpeeds().keySet()) { - addRoutingModuleBinding(mode).toProvider(new BeelineTeleportationRouting(getConfig().plansCalcRoute().getModeRoutingParams().get(mode))); + addRoutingModuleBinding(mode).toProvider(new BeelineTeleportationRouting(getConfig().routing().getModeRoutingParams().get(mode))); } - boolean linkToLinkRouting = getConfig().controler().isLinkToLinkRoutingEnabled(); + boolean linkToLinkRouting = getConfig().controller().isLinkToLinkRoutingEnabled(); if (linkToLinkRouting) { bind(NetworkTurnInfoBuilderI.class).to(NetworkTurnInfoBuilder.class) ; } diff --git a/matsim/src/main/java/org/matsim/core/router/costcalculators/RandomizingTimeDistanceTravelDisutilityFactory.java b/matsim/src/main/java/org/matsim/core/router/costcalculators/RandomizingTimeDistanceTravelDisutilityFactory.java index 0aa08467797..68389ef5d99 100644 --- a/matsim/src/main/java/org/matsim/core/router/costcalculators/RandomizingTimeDistanceTravelDisutilityFactory.java +++ b/matsim/src/main/java/org/matsim/core/router/costcalculators/RandomizingTimeDistanceTravelDisutilityFactory.java @@ -57,8 +57,8 @@ public RandomizingTimeDistanceTravelDisutilityFactory( final String mode, Config // material from injection, but there are many uses of this class outside injection. this.mode = mode; - this.cnScoringGroup = config.planCalcScore(); - this.sigma = config.plansCalcRoute().getRoutingRandomness(); + this.cnScoringGroup = config.scoring(); + this.sigma = config.routing().getRoutingRandomness(); } @Override diff --git a/matsim/src/main/java/org/matsim/core/router/costcalculators/TravelDisutilityModule.java b/matsim/src/main/java/org/matsim/core/router/costcalculators/TravelDisutilityModule.java index 8d3d3d01b05..1be425e7f0f 100644 --- a/matsim/src/main/java/org/matsim/core/router/costcalculators/TravelDisutilityModule.java +++ b/matsim/src/main/java/org/matsim/core/router/costcalculators/TravelDisutilityModule.java @@ -29,7 +29,7 @@ public class TravelDisutilityModule extends AbstractModule { @Override public void install() { - RoutingConfigGroup routeConfigGroup = getConfig().plansCalcRoute(); + RoutingConfigGroup routeConfigGroup = getConfig().routing(); for (String mode : routeConfigGroup.getNetworkModes()) { final RandomizingTimeDistanceTravelDisutilityFactory builder = new RandomizingTimeDistanceTravelDisutilityFactory( mode, getConfig() ); diff --git a/matsim/src/main/java/org/matsim/core/scenario/ScenarioLoaderImpl.java b/matsim/src/main/java/org/matsim/core/scenario/ScenarioLoaderImpl.java index 7685b927f9a..f203ab0d6c4 100644 --- a/matsim/src/main/java/org/matsim/core/scenario/ScenarioLoaderImpl.java +++ b/matsim/src/main/java/org/matsim/core/scenario/ScenarioLoaderImpl.java @@ -220,7 +220,7 @@ private void loadPopulation() { "file is used for the 10pct and the 1pct scenario. The material that is still there will follow. kai, jun'19" ); - final String outputDirectory = this.config.controler().getOutputDirectory(); + final String outputDirectory = this.config.controller().getOutputDirectory(); // final File outDir = new File( outputDirectory ); // if ( outDir.exists() && outDir.canWrite() ){ // // since ScenarioLoader is supposed to only read material, there are cases where the output directory does not exist at @@ -336,7 +336,7 @@ private void loadVehicles() throws UncheckedIOException { if ( vehiclesFile != null ) { log.info("loading vehicles from " + vehiclesFile ); new MatsimVehicleReader(this.scenario.getVehicles()).readURL(IOUtils.extendUrl(this.config.getContext(), vehiclesFile ) ); - } + } else { log.info("no vehicles file set in config, not loading any vehicles"); } diff --git a/matsim/src/main/java/org/matsim/core/scoring/ScoringFunctionsForPopulation.java b/matsim/src/main/java/org/matsim/core/scoring/ScoringFunctionsForPopulation.java index 43547e4173c..db1695f5492 100644 --- a/matsim/src/main/java/org/matsim/core/scoring/ScoringFunctionsForPopulation.java +++ b/matsim/src/main/java/org/matsim/core/scoring/ScoringFunctionsForPopulation.java @@ -95,7 +95,7 @@ final class ScoringFunctionsForPopulation implements BasicEventHandler { @Inject ScoringFunctionsForPopulation(ControlerListenerManager controlerListenerManager, EventsManager eventsManager, EventsToActivities eventsToActivities, EventsToLegs eventsToLegs, Population population, ScoringFunctionFactory scoringFunctionFactory, Config config) { - ControllerConfigGroup controllerConfigGroup = config.controler(); + ControllerConfigGroup controllerConfigGroup = config.controller(); if (controllerConfigGroup.getEventTypeToCreateScoringFunctions() == ControllerConfigGroup.EventTypeToCreateScoringFunctions.IterationStarts) { controlerListenerManager.addControlerListener((IterationStartsListener) event -> init()); diff --git a/matsim/src/main/java/org/matsim/core/scoring/functions/ScoringParameters.java b/matsim/src/main/java/org/matsim/core/scoring/functions/ScoringParameters.java index f9a347f4ed5..9193c2685bc 100644 --- a/matsim/src/main/java/org/matsim/core/scoring/functions/ScoringParameters.java +++ b/matsim/src/main/java/org/matsim/core/scoring/functions/ScoringParameters.java @@ -109,8 +109,8 @@ public Builder( final Scenario scenario, final Person person ) { this( - scenario.getConfig().planCalcScore(), - scenario.getConfig().planCalcScore().getScoringParameters( PopulationUtils.getSubpopulation( person ) ), + scenario.getConfig().scoring(), + scenario.getConfig().scoring().getScoringParameters( PopulationUtils.getSubpopulation( person ) ), scenario.getConfig().scenario() ); } diff --git a/matsim/src/main/java/org/matsim/core/scoring/functions/SubpopulationScoringParameters.java b/matsim/src/main/java/org/matsim/core/scoring/functions/SubpopulationScoringParameters.java index ffd603b2b3b..ac1c1b67bb7 100644 --- a/matsim/src/main/java/org/matsim/core/scoring/functions/SubpopulationScoringParameters.java +++ b/matsim/src/main/java/org/matsim/core/scoring/functions/SubpopulationScoringParameters.java @@ -51,7 +51,7 @@ public class SubpopulationScoringParameters implements ScoringParametersForPerso } public SubpopulationScoringParameters(Scenario scenario) { - this(scenario.getConfig().plans(), scenario.getConfig().planCalcScore(), scenario.getConfig().scenario(), scenario.getPopulation(), scenario.getConfig().transit()); + this(scenario.getConfig().plans(), scenario.getConfig().scoring(), scenario.getConfig().scenario(), scenario.getPopulation(), scenario.getConfig().transit()); } @Override diff --git a/matsim/src/main/java/org/matsim/core/trafficmonitoring/TravelTimeCalculatorModule.java b/matsim/src/main/java/org/matsim/core/trafficmonitoring/TravelTimeCalculatorModule.java index 08eccd999b6..687cc456271 100644 --- a/matsim/src/main/java/org/matsim/core/trafficmonitoring/TravelTimeCalculatorModule.java +++ b/matsim/src/main/java/org/matsim/core/trafficmonitoring/TravelTimeCalculatorModule.java @@ -37,7 +37,6 @@ import jakarta.inject.Inject; import jakarta.inject.Provider; -import java.util.Map; /** @@ -60,7 +59,7 @@ public void install() { } // go through all modes: // for (final String mode : CollectionUtils.stringToSet(getConfig().travelTimeCalculator().getAnalyzedModesAsString() )) { - for (final String mode : getConfig().plansCalcRoute().getNetworkModes() ) { + for (final String mode : getConfig().routing().getNetworkModes() ) { // generate and bind the observer: bind(TravelTimeCalculator.class).annotatedWith(Names.named(mode)).toProvider(new SingleModeTravelTimeCalculatorProvider(mode)).in(Singleton.class); @@ -89,7 +88,7 @@ public void install() { // bind the TravelTime objects. In this case, this just passes on the same information from TravelTimeCalculator to each individual mode: if (getConfig().travelTimeCalculator().isCalculateLinkTravelTimes()) { // for (String mode : CollectionUtils.stringToSet(getConfig().travelTimeCalculator().getAnalyzedModesAsString() )) { - for ( String mode : getConfig().plansCalcRoute().getNetworkModes() ) { + for ( String mode : getConfig().routing().getNetworkModes() ) { addTravelTimeBinding(mode).toProvider(ObservedLinkTravelTimes.class); } } diff --git a/matsim/src/main/java/org/matsim/facilities/FacilitiesFromPopulation.java b/matsim/src/main/java/org/matsim/facilities/FacilitiesFromPopulation.java index 7b80a8d26e2..62ba74d01d3 100644 --- a/matsim/src/main/java/org/matsim/facilities/FacilitiesFromPopulation.java +++ b/matsim/src/main/java/org/matsim/facilities/FacilitiesFromPopulation.java @@ -86,7 +86,7 @@ public FacilitiesFromPopulation( Scenario scenario ) { this.addEmptyActivityOptions = true ; this.facilitiesSource = facilityConfigGroup.getFacilitiesSource(); this.network = scenario.getNetwork() ; - this.scoringConfigGroup = scenario.getConfig().planCalcScore() ; + this.scoringConfigGroup = scenario.getConfig().scoring() ; this.scenario = scenario; } public void setFacilitiesSource( final FacilitiesSource facilitiesSource ) { diff --git a/matsim/src/main/java/org/matsim/guice/DependencyGraphControlerListener.java b/matsim/src/main/java/org/matsim/guice/DependencyGraphControlerListener.java index 242757de4d9..37492d3f785 100644 --- a/matsim/src/main/java/org/matsim/guice/DependencyGraphControlerListener.java +++ b/matsim/src/main/java/org/matsim/guice/DependencyGraphControlerListener.java @@ -68,7 +68,7 @@ class DependencyGraphControlerListener implements StartupListener { } public void notifyStartup(StartupEvent event) { - if (event.getServices().getConfig().controler().isCreateGraphs()) { + if (event.getServices().getConfig().controller().isCreateGraphs()) { try (PrintWriter out = new PrintWriter(new File(controlerIO.getOutputFilename("modules.dot")))) { MatsimGrapher grapher = new MatsimGrapher(new AbstractInjectorGrapher.GrapherParameters() .setAliasCreator(bindings -> { diff --git a/matsim/src/main/java/org/matsim/pt/ReconstructingUmlaufBuilder.java b/matsim/src/main/java/org/matsim/pt/ReconstructingUmlaufBuilder.java index 14aede08b8f..a35eddeb6c5 100644 --- a/matsim/src/main/java/org/matsim/pt/ReconstructingUmlaufBuilder.java +++ b/matsim/src/main/java/org/matsim/pt/ReconstructingUmlaufBuilder.java @@ -66,7 +66,7 @@ public int compare(UmlaufStueck o1, UmlaufStueck o2) { @Inject public ReconstructingUmlaufBuilder( Scenario scenario ) { // (normal constructor used from TransitQSimEngine for testing :-(. kai, mar'20) yy change - this.umlaufInterpolator = new UmlaufInterpolator(scenario.getNetwork(), scenario.getConfig().planCalcScore()); + this.umlaufInterpolator = new UmlaufInterpolator(scenario.getNetwork(), scenario.getConfig().scoring()); this.transitLines = scenario.getTransitSchedule().getTransitLines().values(); this.vehicles = scenario.getTransitVehicles(); this.umlaufIdsByVehicleId = new HashMap<>(); diff --git a/matsim/src/main/java/org/matsim/pt/counts/PtCountControlerListener.java b/matsim/src/main/java/org/matsim/pt/counts/PtCountControlerListener.java index 703930250d9..34ce1915824 100644 --- a/matsim/src/main/java/org/matsim/pt/counts/PtCountControlerListener.java +++ b/matsim/src/main/java/org/matsim/pt/counts/PtCountControlerListener.java @@ -37,9 +37,6 @@ import org.matsim.core.controler.listener.BeforeMobsimListener; import org.matsim.core.controler.listener.IterationEndsListener; import org.matsim.core.controler.listener.StartupListener; -import org.matsim.core.utils.geometry.CoordinateTransformation; -import org.matsim.core.utils.geometry.transformations.TransformationFactory; -import org.matsim.counts.CountSimComparison; import org.matsim.counts.Counts; import org.matsim.counts.MatsimCountsReader; import org.matsim.counts.algorithms.CountsComparisonAlgorithm; @@ -47,7 +44,6 @@ import jakarta.inject.Inject; import java.util.HashMap; -import java.util.List; import java.util.Map; import java.util.Map.Entry; @@ -122,7 +118,7 @@ public void notifyAfterMobsim(AfterMobsimEvent event) { } private boolean isActiveInThisIteration( int iter ) { - return iter % config.ptCounts().getPtCountsInterval() == 0 && iter >= config.controler().getFirstIteration(); + return iter % config.ptCounts().getPtCountsInterval() == 0 && iter >= config.controller().getFirstIteration(); } @Override diff --git a/matsim/src/main/java/org/matsim/pt/router/TransitRouterConfig.java b/matsim/src/main/java/org/matsim/pt/router/TransitRouterConfig.java index 13dd4eda240..e18700156bf 100644 --- a/matsim/src/main/java/org/matsim/pt/router/TransitRouterConfig.java +++ b/matsim/src/main/java/org/matsim/pt/router/TransitRouterConfig.java @@ -103,7 +103,7 @@ public class TransitRouterConfig implements MatsimParameters { private boolean cacheTree; public TransitRouterConfig(final Config config) { - this(config.planCalcScore(), config.plansCalcRoute(), config.transitRouter(), config.vspExperimental()); + this(config.scoring(), config.routing(), config.transitRouter(), config.vspExperimental()); } public TransitRouterConfig(final ScoringConfigGroup pcsConfig, final RoutingConfigGroup pcrConfig, diff --git a/matsim/src/main/java/org/matsim/pt/router/TransitRouterImplFactory.java b/matsim/src/main/java/org/matsim/pt/router/TransitRouterImplFactory.java index 9842e1b09ac..d72c3ce1f54 100644 --- a/matsim/src/main/java/org/matsim/pt/router/TransitRouterImplFactory.java +++ b/matsim/src/main/java/org/matsim/pt/router/TransitRouterImplFactory.java @@ -42,8 +42,8 @@ public class TransitRouterImplFactory implements Provider { @Inject TransitRouterImplFactory(final TransitSchedule schedule, final EventsManager events, final Config config) { this(schedule, new TransitRouterConfig( - config.planCalcScore(), - config.plansCalcRoute(), + config.scoring(), + config.routing(), config.transitRouter(), config.vspExperimental())); events.addHandler((TransitScheduleChangedEventHandler) event -> { diff --git a/matsim/src/main/java/org/matsim/run/Events2Snapshot.java b/matsim/src/main/java/org/matsim/run/Events2Snapshot.java index c6bee1ead04..def875888c7 100644 --- a/matsim/src/main/java/org/matsim/run/Events2Snapshot.java +++ b/matsim/src/main/java/org/matsim/run/Events2Snapshot.java @@ -204,7 +204,7 @@ private void loadSnapshotWriters(final String outputDir) { this.visualizer.addSnapshotWriter(this.writer); } - Collection snapshotFormats = this.config.controler().getSnapshotFormat(); + Collection snapshotFormats = this.config.controller().getSnapshotFormat(); for( SnapshotFormat snapshotFormat : snapshotFormats ){ switch( snapshotFormat ){ diff --git a/matsim/src/main/java/org/matsim/run/InitRoutes.java b/matsim/src/main/java/org/matsim/run/InitRoutes.java index 86818565166..923a94d937c 100644 --- a/matsim/src/main/java/org/matsim/run/InitRoutes.java +++ b/matsim/src/main/java/org/matsim/run/InitRoutes.java @@ -137,7 +137,7 @@ public void run(final String[] args) { final StreamingPopulationWriter plansWriter = new StreamingPopulationWriter(); Gbl.assertNotNull(this.plansfile); plansWriter.startStreaming(this.plansfile); - final FreespeedTravelTimeAndDisutility timeCostCalc = new FreespeedTravelTimeAndDisutility(config.planCalcScore()); + final FreespeedTravelTimeAndDisutility timeCostCalc = new FreespeedTravelTimeAndDisutility(config.scoring()); com.google.inject.Injector injector = Injector.createInjector(scenario.getConfig(), new AbstractModule() { @Override public void install() { diff --git a/matsim/src/main/java/org/matsim/run/RunMatsim.java b/matsim/src/main/java/org/matsim/run/RunMatsim.java index ef8e2f43618..8ceafae61db 100644 --- a/matsim/src/main/java/org/matsim/run/RunMatsim.java +++ b/matsim/src/main/java/org/matsim/run/RunMatsim.java @@ -32,31 +32,31 @@ public class RunMatsim { private final org.matsim.core.controler.Controler controler; - + public RunMatsim(final String[] args) { this.controler = new org.matsim.core.controler.Controler(args); } - + public RunMatsim(final String configFilename) { this.controler = new org.matsim.core.controler.Controler(configFilename); } - + public void setOverwriteFiles(final boolean overwriteFiles) { - this.controler.getConfig().controler().setOverwriteFileSetting( + this.controler.getConfig().controller().setOverwriteFileSetting( overwriteFiles ? OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles : OutputDirectoryHierarchy.OverwriteFileSetting.failIfDirectoryExists ); } - + public Scenario getScenario() { return this.controler.getScenario() ; } - + public void run() { this.controler.run(); } - + public static void main(String[] args) { new RunMatsim(args).run(); } -} \ No newline at end of file +} diff --git a/matsim/src/main/java/org/matsim/run/gui/Gui.java b/matsim/src/main/java/org/matsim/run/gui/Gui.java index 8d79c2b083a..edbd65e199a 100644 --- a/matsim/src/main/java/org/matsim/run/gui/Gui.java +++ b/matsim/src/main/java/org/matsim/run/gui/Gui.java @@ -499,7 +499,7 @@ public void loadConfigFile(final File configFile) { txtConfigfilename.setText(configFilename); File par = configFile.getParentFile(); - File outputDir = new File(par, config.controler().getOutputDirectory()); + File outputDir = new File(par, config.controller().getOutputDirectory()); try { txtOutput.setText(outputDir.getCanonicalPath()); } catch (IOException e1) { diff --git a/matsim/src/main/java/org/matsim/vis/snapshotwriters/SnapshotWritersModule.java b/matsim/src/main/java/org/matsim/vis/snapshotwriters/SnapshotWritersModule.java index a21d7196690..858446f845b 100644 --- a/matsim/src/main/java/org/matsim/vis/snapshotwriters/SnapshotWritersModule.java +++ b/matsim/src/main/java/org/matsim/vis/snapshotwriters/SnapshotWritersModule.java @@ -40,13 +40,13 @@ public class SnapshotWritersModule extends AbstractModule { @Override public void install() { - if (getConfig().controler().getSnapshotFormat().contains(SnapshotFormat.transims)) { + if (getConfig().controller().getSnapshotFormat().contains(SnapshotFormat.transims)) { addSnapshotWriterBinding().toProvider(TransimsSnapshotWriterFactory.class); } - if (getConfig().controler().getSnapshotFormat().contains(SnapshotFormat.positionevents)) { + if (getConfig().controller().getSnapshotFormat().contains(SnapshotFormat.positionevents)) { addSnapshotWriterBinding().toProvider(PositionEventsWriterFactory.class); } - if (getConfig().controler().getWriteSnapshotsInterval() != 0) { + if (getConfig().controller().getWriteSnapshotsInterval() != 0) { addMobsimListenerBinding().toProvider(SnapshotWriterManagerProvider.class); } } diff --git a/matsim/src/main/java/org/matsim/withinday/controller/ExampleWithinDayController.java b/matsim/src/main/java/org/matsim/withinday/controller/ExampleWithinDayController.java index 2eb4470272c..504a6005756 100644 --- a/matsim/src/main/java/org/matsim/withinday/controller/ExampleWithinDayController.java +++ b/matsim/src/main/java/org/matsim/withinday/controller/ExampleWithinDayController.java @@ -133,7 +133,7 @@ public static void main(final String[] args) { } Config config = ConfigUtils.loadConfig( args[0] , new WithinDayConfigGroup() ) ; - config.controler().setRoutingAlgorithmType( ControllerConfigGroup.RoutingAlgorithmType.Dijkstra ); + config.controller().setRoutingAlgorithmType( ControllerConfigGroup.RoutingAlgorithmType.Dijkstra ); Scenario scenario = ScenarioUtils.loadScenario( config) ; diff --git a/matsim/src/main/java/org/matsim/withinday/controller/ExecutedPlansServiceImpl.java b/matsim/src/main/java/org/matsim/withinday/controller/ExecutedPlansServiceImpl.java index eff6b0d3b57..e0c426d28c7 100644 --- a/matsim/src/main/java/org/matsim/withinday/controller/ExecutedPlansServiceImpl.java +++ b/matsim/src/main/java/org/matsim/withinday/controller/ExecutedPlansServiceImpl.java @@ -112,7 +112,7 @@ public void notifyAfterMobsim(AfterMobsimEvent event) { // write this in every iteration in order to be consistent with previous design. I think this should be changed. kai, jun'16 // as a quick fix, writing this as often as the base plans file. kai, jun'23 - if ( event.getIteration() % scenario.getConfig().controler().getWritePlansInterval() == 0 ){ + if ( event.getIteration() % scenario.getConfig().controller().getWritePlansInterval() == 0 ){ String outputFile = controlerIO.getIterationFilename( event.getIteration(), EXECUTEDPLANSFILE ); writeExecutedPlans( outputFile ); } diff --git a/matsim/src/main/java/org/matsim/withinday/trafficmonitoring/WithinDayTravelTimeModule.java b/matsim/src/main/java/org/matsim/withinday/trafficmonitoring/WithinDayTravelTimeModule.java index 880d31b6465..da440f5385e 100644 --- a/matsim/src/main/java/org/matsim/withinday/trafficmonitoring/WithinDayTravelTimeModule.java +++ b/matsim/src/main/java/org/matsim/withinday/trafficmonitoring/WithinDayTravelTimeModule.java @@ -33,7 +33,7 @@ public WithinDayTravelTimeModule() { @Override public void install() { - if (getConfig().controler().getRoutingAlgorithmType() != ControllerConfigGroup.RoutingAlgorithmType.Dijkstra) { + if (getConfig().controller().getRoutingAlgorithmType() != ControllerConfigGroup.RoutingAlgorithmType.Dijkstra) { throw new RuntimeException( "for me, in KNAccidentScenario, this works with Dijkstra (default until spring 2019), and does not work with AStarLandmarks " + "(default afterwards). I have not tried the other routing options, nor have I systematically debugged. KN, feb'19"); diff --git a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/RaptorStopFinderTest.java b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/RaptorStopFinderTest.java index dee5ae97f8f..0a2157d88d6 100644 --- a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/RaptorStopFinderTest.java +++ b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/RaptorStopFinderTest.java @@ -1668,7 +1668,7 @@ public void testDefaultStopFinder_testMultipleModes() { ScoringConfigGroup.ModeParams modeParams = new ScoringConfigGroup.ModeParams("zoomer"); modeParams.setMarginalUtilityOfTraveling(0.); - f0.scenario.getConfig().planCalcScore().addModeParams(modeParams); + f0.scenario.getConfig().scoring().addModeParams(modeParams); f0.srrConfig.setUseIntermodalAccessEgress(true); SwissRailRaptorConfigGroup.IntermodalAccessEgressParameterSet zoomerAccess = new SwissRailRaptorConfigGroup.IntermodalAccessEgressParameterSet(); @@ -1734,7 +1734,7 @@ public void testDefaultStopFinder_testMultipleModes() { ScoringConfigGroup.ModeParams modeParams = new ScoringConfigGroup.ModeParams("zoomer"); modeParams.setMarginalUtilityOfTraveling(0.); - f0.scenario.getConfig().planCalcScore().addModeParams(modeParams); + f0.scenario.getConfig().scoring().addModeParams(modeParams); f0.srrConfig.setUseIntermodalAccessEgress(true); SwissRailRaptorConfigGroup.IntermodalAccessEgressParameterSet zoomerAccess = new SwissRailRaptorConfigGroup.IntermodalAccessEgressParameterSet(); diff --git a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorIntermodalTest.java b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorIntermodalTest.java index e920e0ca443..6b4881afdeb 100644 --- a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorIntermodalTest.java +++ b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorIntermodalTest.java @@ -58,7 +58,7 @@ public void testIntermodalTrip() { ScoringConfigGroup.ModeParams walk = new ScoringConfigGroup.ModeParams(TransportMode.walk); walk.setMarginalUtilityOfTraveling(0.0); - f.config.planCalcScore().addModeParams(walk); + f.config.scoring().addModeParams(walk); Map routingModules = new HashMap<>(); routingModules.put(TransportMode.walk, @@ -150,7 +150,7 @@ public void testIntermodalTrip_TripRouterIntegration() { ScoringConfigGroup.ModeParams walk = new ScoringConfigGroup.ModeParams(TransportMode.walk); walk.setMarginalUtilityOfTraveling(0.0); - f.config.planCalcScore().addModeParams(walk); + f.config.scoring().addModeParams(walk); SwissRailRaptorData data = SwissRailRaptorData.create(f.scenario.getTransitSchedule(), null, RaptorUtils.createStaticConfig(f.config), f.scenario.getNetwork(), null); DefaultRaptorStopFinder stopFinder = new DefaultRaptorStopFinder(new DefaultRaptorIntermodalAccessEgress(), routingModules); @@ -203,7 +203,7 @@ public void testIntermodalTrip_walkOnlyNoSubpop() { ScoringConfigGroup.ModeParams walk = new ScoringConfigGroup.ModeParams(TransportMode.walk); walk.setMarginalUtilityOfTraveling(-8.0); - f.config.planCalcScore().addModeParams(walk); + f.config.scoring().addModeParams(walk); Map routingModules = new HashMap<>(); routingModules.put(TransportMode.walk, @@ -255,7 +255,7 @@ public void testIntermodalTrip_withoutPt() { ScoringConfigGroup.ModeParams walk = new ScoringConfigGroup.ModeParams(TransportMode.walk); walk.setMarginalUtilityOfTraveling(0.0); - f.config.planCalcScore().addModeParams(walk); + f.config.scoring().addModeParams(walk); Map routingModules = new HashMap<>(); routingModules.put(TransportMode.walk, @@ -289,13 +289,13 @@ public void testIntermodalTrip_withoutPt() { public void testDirectWalkFactor() { IntermodalFixture f = new IntermodalFixture(); - f.config.planCalcScore().setPerforming_utils_hr(6.0); + f.config.scoring().setPerforming_utils_hr(6.0); ScoringConfigGroup.ModeParams walk = new ScoringConfigGroup.ModeParams(TransportMode.walk); walk.setMarginalUtilityOfTraveling(0.0); - f.config.planCalcScore().addModeParams(walk); + f.config.scoring().addModeParams(walk); ScoringConfigGroup.ModeParams bike = new ScoringConfigGroup.ModeParams("bike"); bike.setMarginalUtilityOfTraveling(0.0); - f.config.planCalcScore().addModeParams(bike); + f.config.scoring().addModeParams(bike); Map routingModules = new HashMap<>(); routingModules.put(TransportMode.walk, @@ -387,7 +387,7 @@ public void testAccessEgressModeFasterThanPt() { ScoringConfigGroup.ModeParams walk = new ScoringConfigGroup.ModeParams(TransportMode.walk); walk.setMarginalUtilityOfTraveling(0.0); - f.config.planCalcScore().addModeParams(walk); + f.config.scoring().addModeParams(walk); Map routingModules = new HashMap<>(); routingModules.put(TransportMode.walk, @@ -482,11 +482,11 @@ public void testIntermodalTrip_competingAccess() { // we need to set special values for walk and bike as the defaults are the same for walk, bike and waiting // which would result in all options having the same cost in the end. - f.config.planCalcScore().getModes().get(TransportMode.bike).setMarginalUtilityOfTraveling(-8); + f.config.scoring().getModes().get(TransportMode.bike).setMarginalUtilityOfTraveling(-8); ScoringConfigGroup.ModeParams walk = new ScoringConfigGroup.ModeParams(TransportMode.walk); walk.setMarginalUtilityOfTraveling(-7); - f.config.planCalcScore().addModeParams(walk); + f.config.scoring().addModeParams(walk); f.srrConfig.setUseIntermodalAccessEgress(true); IntermodalAccessEgressParameterSet walkAccess = new IntermodalAccessEgressParameterSet(); @@ -577,11 +577,11 @@ public void testIntermodalTrip_RandomAccessEgressModeRaptorStopFinder() { // we need to set special values for walk and bike as the defaults are the same for walk, bike and waiting // which would result in all options having the same cost in the end. - f.config.planCalcScore().getModes().get(TransportMode.bike).setMarginalUtilityOfTraveling(-8); + f.config.scoring().getModes().get(TransportMode.bike).setMarginalUtilityOfTraveling(-8); ScoringConfigGroup.ModeParams walk = new ScoringConfigGroup.ModeParams(TransportMode.walk); walk.setMarginalUtilityOfTraveling(-7); - f.config.planCalcScore().addModeParams(walk); + f.config.scoring().addModeParams(walk); f.srrConfig.setUseIntermodalAccessEgress(true); IntermodalAccessEgressParameterSet walkAccess = new IntermodalAccessEgressParameterSet(); @@ -917,7 +917,7 @@ public void testIntermodalTrip_tripLengthShare() { ScoringConfigGroup.ModeParams walk = new ScoringConfigGroup.ModeParams(TransportMode.walk); walk.setMarginalUtilityOfTraveling(0.0); - f.config.planCalcScore().addModeParams(walk); + f.config.scoring().addModeParams(walk); Map routingModules = new HashMap<>(); routingModules.put(TransportMode.walk, @@ -987,7 +987,7 @@ public void testIntermodalTrip_activityInteraction() { PopulationFactory populationFactory = scenario.getPopulation().getFactory(); ScoringConfigGroup.ModeParams walk = new ScoringConfigGroup.ModeParams(TransportMode.walk); walk.setMarginalUtilityOfTraveling(0.0); - f.config.planCalcScore().addModeParams(walk); + f.config.scoring().addModeParams(walk); Map routingModules = new HashMap<>(); routingModules.put(TransportMode.walk, @@ -1108,7 +1108,7 @@ public void testIntermodalTrip_activityInteractionAdd() { PopulationFactory populationFactory = scenario.getPopulation().getFactory(); ScoringConfigGroup.ModeParams walk = new ScoringConfigGroup.ModeParams(TransportMode.walk); walk.setMarginalUtilityOfTraveling(0.0); - f.config.planCalcScore().addModeParams(walk); + f.config.scoring().addModeParams(walk); Map routingModules = new HashMap<>(); routingModules.put(TransportMode.walk, @@ -1404,7 +1404,7 @@ public IntermodalTransferFixture() { // we need to set special values for walk and bike as the defaults are the same for walk, bike and waiting // which would result in all options having the same cost in the end. - this.config.planCalcScore().getModes().get(TransportMode.bike).setMarginalUtilityOfTraveling(-8); + this.config.scoring().getModes().get(TransportMode.bike).setMarginalUtilityOfTraveling(-8); this.config.transitRouter().setMaxBeelineWalkConnectionDistance(150); @@ -1427,7 +1427,7 @@ public IntermodalTransferFixture() { */ ScoringConfigGroup.ModeParams walk = new ScoringConfigGroup.ModeParams(TransportMode.walk); walk.setMarginalUtilityOfTraveling(-7); - this.config.planCalcScore().addModeParams(walk); + this.config.scoring().addModeParams(walk); this.srrConfig.setUseIntermodalAccessEgress(true); IntermodalAccessEgressParameterSet walkAccess = new IntermodalAccessEgressParameterSet(); diff --git a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorModuleTest.java b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorModuleTest.java index fa2d951a881..9a799b5976e 100644 --- a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorModuleTest.java +++ b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorModuleTest.java @@ -78,10 +78,10 @@ public void setUp() { @Test public void testInitialization() { Config config = ConfigUtils.createConfig(); - config.controler().setLastIteration(0); - config.controler().setOutputDirectory(this.utils.getOutputDirectory()); - config.controler().setCreateGraphs(false); - config.controler().setDumpDataAtEnd(false); + config.controller().setLastIteration(0); + config.controller().setOutputDirectory(this.utils.getOutputDirectory()); + config.controller().setCreateGraphs(false); + config.controller().setDumpDataAtEnd(false); config.transit().setUseTransit(true); Scenario scenario = ScenarioUtils.createScenario(config); Controler controler = new Controler(scenario); @@ -143,21 +143,21 @@ public void testIntermodalIntegration() { Config config = f.config; ScoringConfigGroup.ActivityParams homeScoring = new ScoringConfigGroup.ActivityParams("home"); homeScoring.setTypicalDuration(16*3600); - f.config.planCalcScore().addActivityParams(homeScoring); + f.config.scoring().addActivityParams(homeScoring); ScoringConfigGroup.ActivityParams workScoring = new ScoringConfigGroup.ActivityParams("work"); workScoring.setTypicalDuration(8*3600); - f.config.planCalcScore().addActivityParams(workScoring); + f.config.scoring().addActivityParams(workScoring); ScoringConfigGroup.ModeParams walk = new ScoringConfigGroup.ModeParams(TransportMode.walk); walk.setMarginalUtilityOfTraveling(0.0); - f.config.planCalcScore().addModeParams(walk); + f.config.scoring().addModeParams(walk); // prepare rest of config - config.controler().setLastIteration(0); - config.controler().setOutputDirectory(this.utils.getOutputDirectory()); - config.controler().setCreateGraphs(false); - config.controler().setDumpDataAtEnd(false); + config.controller().setLastIteration(0); + config.controller().setOutputDirectory(this.utils.getOutputDirectory()); + config.controller().setCreateGraphs(false); + config.controller().setDumpDataAtEnd(false); config.qsim().setEndTime(10*3600); config.transit().setUseTransit(true); Controler controler = new Controler(f.scenario); @@ -257,24 +257,24 @@ public void testTransitScheduleUpdate() { Config config = f.config; ScoringConfigGroup.ActivityParams homeScoring = new ScoringConfigGroup.ActivityParams("home"); homeScoring.setTypicalDuration(16*3600); - f.config.planCalcScore().addActivityParams(homeScoring); + f.config.scoring().addActivityParams(homeScoring); ScoringConfigGroup.ActivityParams workScoring = new ScoringConfigGroup.ActivityParams("work"); workScoring.setTypicalDuration(8*3600); - f.config.planCalcScore().addActivityParams(workScoring); + f.config.scoring().addActivityParams(workScoring); - f.config.planCalcScore().getOrCreateModeParams(TransportMode.walk).setMarginalUtilityOfTraveling(0.0); + f.config.scoring().getOrCreateModeParams(TransportMode.walk).setMarginalUtilityOfTraveling(0.0); StrategySettings reRoute = new StrategySettings(); reRoute.setStrategyName("ReRoute"); reRoute.setWeight(1.0); - config.strategy().addStrategySettings(reRoute); - config.strategy().setMaxAgentPlanMemorySize(1); + config.replanning().addStrategySettings(reRoute); + config.replanning().setMaxAgentPlanMemorySize(1); // prepare rest of config - config.controler().setLastIteration(1); - config.controler().setOutputDirectory(this.utils.getOutputDirectory()); - config.controler().setCreateGraphs(false); - config.controler().setDumpDataAtEnd(false); + config.controller().setLastIteration(1); + config.controller().setOutputDirectory(this.utils.getOutputDirectory()); + config.controller().setCreateGraphs(false); + config.controller().setDumpDataAtEnd(false); config.qsim().setEndTime(10*3600); config.transit().setUseTransit(true); Controler controler = new Controler(f.scenario); @@ -333,21 +333,21 @@ public void testRaptorParametersForPerson() { srrConfig.setScoringParameters(ch.sbb.matsim.config.SwissRailRaptorConfigGroup.ScoringParameters.Individual); Config config = ConfigUtils.createConfig(srrConfig); - config.controler().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); - config.controler().setLastIteration(0); - config.controler().setOutputDirectory(this.utils.getOutputDirectory()); + config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); + config.controller().setLastIteration(0); + config.controller().setOutputDirectory(this.utils.getOutputDirectory()); config.transit().setUseTransit(true); - config.planCalcScore().getOrCreateScoringParameters("default").setPerforming_utils_hr(3600.0 * 50.0); - config.planCalcScore().getOrCreateScoringParameters("sub").setPerforming_utils_hr(3600.0 * 50.0); + config.scoring().getOrCreateScoringParameters("default").setPerforming_utils_hr(3600.0 * 50.0); + config.scoring().getOrCreateScoringParameters("sub").setPerforming_utils_hr(3600.0 * 50.0); for (String mode : Arrays.asList("car", "walk", "pt")) { - config.planCalcScore().getOrCreateScoringParameters("default").getOrCreateModeParams(mode); - config.planCalcScore().getOrCreateScoringParameters("sub").getOrCreateModeParams(mode); + config.scoring().getOrCreateScoringParameters("default").getOrCreateModeParams(mode); + config.scoring().getOrCreateScoringParameters("sub").getOrCreateModeParams(mode); } - config.planCalcScore().getOrCreateScoringParameters("default").setMarginalUtlOfWaitingPt_utils_hr(-3600.0 * 30.0); - config.planCalcScore().getOrCreateScoringParameters("sub").setMarginalUtlOfWaitingPt_utils_hr(-3600.0 * 10.0); + config.scoring().getOrCreateScoringParameters("default").setMarginalUtlOfWaitingPt_utils_hr(-3600.0 * 30.0); + config.scoring().getOrCreateScoringParameters("sub").setMarginalUtlOfWaitingPt_utils_hr(-3600.0 * 10.0); Scenario scenario = ScenarioUtils.createScenario(config); diff --git a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorTest.java b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorTest.java index cb850cb2235..40628983e1b 100644 --- a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorTest.java +++ b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorTest.java @@ -360,7 +360,7 @@ public void testTransferWeights() { */ Fixture f = new Fixture(); f.init(); - f.config.planCalcScore().setUtilityOfLineSwitch(0); + f.config.scoring().setUtilityOfLineSwitch(0); RaptorParameters raptorParams = RaptorUtils.createParameters(f.config); TransitRouter router = createTransitRouter(f.schedule, f.config, f.network); List legs = router.calcRoute(DefaultRoutingRequest.withoutAttributes(new FakeFacility(new Coord(11900, 5100)), new FakeFacility(new Coord(24100, 4950)), 6.0*3600 - 5.0*60, null)); @@ -375,7 +375,7 @@ public void testTransferWeights() { Config config = ConfigUtils.createConfig(); double transferUtility = 300.0 * raptorParams.getMarginalUtilityOfTravelTime_utl_s(TransportMode.pt); // corresponds to 5 minutes transit travel time - config.planCalcScore().setUtilityOfLineSwitch(transferUtility); + config.scoring().setUtilityOfLineSwitch(transferUtility); raptorParams = RaptorUtils.createParameters(config); Assert.assertEquals(-transferUtility, raptorParams.getTransferPenaltyFixCostPerTransfer(), 0.0); router = createTransitRouter(f.schedule, config, f.network); @@ -399,7 +399,7 @@ public void testTransferTime() { */ Fixture f = new Fixture(); f.init(); - f.config.planCalcScore().setUtilityOfLineSwitch(0); + f.config.scoring().setUtilityOfLineSwitch(0); f.config.transitRouter().setAdditionalTransferTime(0); TransitRouter router = createTransitRouter(f.schedule, f.config, f.network); List legs = router.calcRoute(DefaultRoutingRequest.withoutAttributes(new FakeFacility(new Coord(11900, 5100)), new FakeFacility(new Coord(24100, 4950)), 6.0*3600 - 5.0*60, null)); @@ -514,7 +514,7 @@ public void testLongTransferTime_withTransitRouterWrapper() { Assert.assertEquals(1895.0, legDuration, 0.0); RoutingModule walkRoutingModule = DefaultRoutingModules.createTeleportationRouter(TransportMode.transit_walk, f.scenario, - f.config.plansCalcRoute().getModeRoutingParams().get(TransportMode.walk)); + f.config.routing().getModeRoutingParams().get(TransportMode.walk)); TransitRouterWrapper wrapper = new TransitRouterWrapper( router, @@ -552,7 +552,7 @@ public void testLongTransferTime_withTransitRouterWrapper() { Assert.assertEquals(5500.0, legDuration, 0.0); RoutingModule walkRoutingModule = DefaultRoutingModules.createTeleportationRouter(TransportMode.transit_walk, f.scenario, - f.config.plansCalcRoute().getModeRoutingParams().get(TransportMode.walk)); + f.config.routing().getModeRoutingParams().get(TransportMode.walk)); TransitRouterWrapper wrapper = new TransitRouterWrapper( router, @@ -581,7 +581,7 @@ public void testLongTransferTime_withTransitRouterWrapper() { Assert.assertNull("The router should not find a route and return null, but did return something else.", legs); RoutingModule walkRoutingModule = DefaultRoutingModules.createTeleportationRouter(TransportMode.transit_walk, f.scenario, - f.config.plansCalcRoute().getModeRoutingParams().get(TransportMode.walk)); + f.config.routing().getModeRoutingParams().get(TransportMode.walk)); TransitRouterWrapper routingModule = new TransitRouterWrapper( router, @@ -862,12 +862,12 @@ private Config prepareConfig(double transferFixedCost, double transferRelativeCo Config config = ConfigUtils.createConfig(srrConfig); config.transitRouter().setDirectWalkFactor(1.0); - double beelineDistanceFactor = config.plansCalcRoute().getModeRoutingParams().get( TransportMode.walk ).getBeelineDistanceFactor(); + double beelineDistanceFactor = config.routing().getModeRoutingParams().get( TransportMode.walk ).getBeelineDistanceFactor(); RoutingConfigGroup.TeleportedModeParams walkParameters = new RoutingConfigGroup.TeleportedModeParams(TransportMode.walk); walkParameters.setTeleportedModeSpeed(beelineDistanceFactor); // set it such that the beelineWalkSpeed is exactly 1 - config.plansCalcRoute().addParameterSet(walkParameters); + config.routing().addParameterSet(walkParameters); - config.planCalcScore().setUtilityOfLineSwitch(-transferFixedCost); + config.scoring().setUtilityOfLineSwitch(-transferFixedCost); srrConfig.setTransferPenaltyBaseCost(transferFixedCost); srrConfig.setTransferPenaltyCostPerTravelTimeHour(transferRelativeCostFactor); @@ -896,11 +896,11 @@ public void testModeMapping() { ModeParams railParams = new ModeParams("rail"); railParams.setMarginalUtilityOfTraveling(-6.0); - f.config.planCalcScore().addModeParams(railParams); + f.config.scoring().addModeParams(railParams); ModeParams roadParams = new ModeParams("road"); roadParams.setMarginalUtilityOfTraveling(-6.0); - f.config.planCalcScore().addModeParams(roadParams); + f.config.scoring().addModeParams(roadParams); TransitRouter router = createTransitRouter(f.schedule, f.config, f.network); Coord toCoord = new Coord(16100, 10050); @@ -958,11 +958,11 @@ public void testModeMappingCosts() { ModeParams railParams = new ModeParams("rail"); railParams.setMarginalUtilityOfTraveling(-6.0); - config.planCalcScore().addModeParams(railParams); + config.scoring().addModeParams(railParams); ModeParams roadParams = new ModeParams("road"); roadParams.setMarginalUtilityOfTraveling(-6.0); - config.planCalcScore().addModeParams(roadParams); + config.scoring().addModeParams(roadParams); } { // test with similar costs, the red line should still be cheaper @@ -990,7 +990,7 @@ public void testModeMappingCosts() { // (the access/egress legs to red are each 2 meters shorter than to green line, which adds a little additional penalty for the green line, about 0.02) ModeParams roadParams = new ModeParams("road"); roadParams.setMarginalUtilityOfTraveling(2.83); - config.planCalcScore().addModeParams(roadParams); + config.scoring().addModeParams(roadParams); TransitRouter router = createTransitRouter(f.schedule, config, f.network); List legs = router.calcRoute(DefaultRoutingRequest.withoutAttributes(new FakeFacility(fromCoord), new FakeFacility(toCoord), 6.0 * 3600 - 5 * 60, null)); @@ -1225,10 +1225,10 @@ private static class TransferFixture { this.config.transitRouter().setSearchRadius(500.0); this.config.transitRouter().setMaxBeelineWalkConnectionDistance(100.0); - double beelineDistanceFactor = this.config.plansCalcRoute().getModeRoutingParams().get( TransportMode.walk ).getBeelineDistanceFactor(); + double beelineDistanceFactor = this.config.routing().getModeRoutingParams().get( TransportMode.walk ).getBeelineDistanceFactor(); RoutingConfigGroup.TeleportedModeParams walkParameters = new RoutingConfigGroup.TeleportedModeParams(TransportMode.walk); walkParameters.setTeleportedModeSpeed(beelineDistanceFactor); // set it such that the beelineWalkSpeed is exactly 1 - this.config.plansCalcRoute().addParameterSet(walkParameters); + this.config.routing().addParameterSet(walkParameters); // network Network network = this.scenario.getNetwork(); diff --git a/matsim/src/test/java/org/matsim/analysis/IterationTravelStatsControlerListenerTest.java b/matsim/src/test/java/org/matsim/analysis/IterationTravelStatsControlerListenerTest.java index f36eb79f670..d665683747a 100644 --- a/matsim/src/test/java/org/matsim/analysis/IterationTravelStatsControlerListenerTest.java +++ b/matsim/src/test/java/org/matsim/analysis/IterationTravelStatsControlerListenerTest.java @@ -1,5 +1,5 @@ /** - * + * */ package org.matsim.analysis; @@ -43,19 +43,19 @@ public class IterationTravelStatsControlerListenerTest { final IdMap map = new IdMap<>(Person.class); Config config = ConfigUtils.createConfig(); - + private int person; private int executed_score; private int first_act_x; private int first_act_y; private int first_act_type; - + @Rule public MatsimTestUtils utils = new MatsimTestUtils(); - + @Test public void testIterationTravelStatsControlerListener() { - + Plans plans = new Plans(); /**************************** @@ -78,9 +78,9 @@ public void testIterationTravelStatsControlerListener() { * Plan 4-----creating plan 4 **************************************/ Plan plan4 = plans.createPlanFour(); - + Scenario scenario = ScenarioUtils.createScenario(config); - + Person person1 = PopulationUtils.getFactory().createPerson(Id.create("1", Person.class));; person1.addPlan(plan1); Person person2 = PopulationUtils.getFactory().createPerson(Id.create("2", Person.class));; @@ -89,18 +89,18 @@ public void testIterationTravelStatsControlerListener() { person3.addPlan(plan3); Person person4 = PopulationUtils.getFactory().createPerson(Id.create("4", Person.class));; person4.addPlan(plan4); - + scenario.getPopulation().addPerson(person1); scenario.getPopulation().addPerson(person2); scenario.getPopulation().addPerson(person3); scenario.getPopulation().addPerson(person4); - + performTest(scenario, utils.getOutputDirectory() + "/IterationTravelStatsControlerListener"); } - + private void performTest(Scenario scenario, String outputDirectory) { - - config.controler().setOutputDirectory(utils.getOutputDirectory()); + + config.controller().setOutputDirectory(utils.getOutputDirectory()); ShutdownEvent shutdownEvent = new ShutdownEvent(null, false, 0); com.google.inject.Injector injector = Injector.createInjector(config, new AbstractModule() { @Override @@ -121,11 +121,11 @@ public void install() { ltcl.notifyShutdown(shutdownEvent); readAndValidateValues(scenario); } - + private Activity identifyFirstActivity(Person person) { return (Activity) person.getSelectedPlan().getPlanElements().get(0); } - + private void readAndValidateValues(Scenario scenario) { String file = utils.getOutputDirectory() + "/output_persons.csv.gz"; @@ -163,9 +163,9 @@ private void readAndValidateValues(Scenario scenario) { e.printStackTrace(); } - + } - + private void decideColumns(String[] columnNames) { Integer i = 0; @@ -184,7 +184,7 @@ private void decideColumns(String[] columnNames) { case "first_act_x": first_act_x = i; break; - + case "first_act_y": first_act_y = i; break; diff --git a/matsim/src/test/java/org/matsim/analysis/LinkStatsControlerListenerTest.java b/matsim/src/test/java/org/matsim/analysis/LinkStatsControlerListenerTest.java index 2518d3f0635..e72013364c3 100644 --- a/matsim/src/test/java/org/matsim/analysis/LinkStatsControlerListenerTest.java +++ b/matsim/src/test/java/org/matsim/analysis/LinkStatsControlerListenerTest.java @@ -65,8 +65,8 @@ public void testlinksOutputCSV() throws IOException { String outputDirectory = util.getOutputDirectory(); Config config = this.util.loadConfig("test/scenarios/equil/config_plans1.xml"); - config.controler().setLastIteration(10); - config.controler().setOutputDirectory(outputDirectory); + config.controller().setLastIteration(10); + config.controller().setOutputDirectory(outputDirectory); Controler c = new Controler(config); c.run(); @@ -84,7 +84,7 @@ public void testlinksOutputCSV() throws IOException { @Test public void testUseVolumesOfIteration() { Config config = ConfigUtils.createConfig(); - config.controler().setOutputDirectory(util.getOutputDirectory()); + config.controller().setOutputDirectory(util.getOutputDirectory()); final Scenario scenario = ScenarioUtils.createScenario(config); com.google.inject.Injector injector = Injector.createInjector(config, new AbstractModule() { @Override @@ -320,38 +320,38 @@ public void test_writeLinkStatsInterval() { controler.addOverridingModule(new AbstractModule() { @Override public void install() { - if (getConfig().controler().getMobsim().equals("dummy")) { + if (getConfig().controller().getMobsim().equals("dummy")) { bind(Mobsim.class).toProvider(DummyMobsimFactory.class); } } }); - config.controler().setMobsim("dummy"); - config.controler().setFirstIteration(0); - config.controler().setLastIteration(7); - - controler.getConfig().controler().setCreateGraphs(false); - controler.getConfig().controler().setDumpDataAtEnd(false); - controler.getConfig().controler().setWriteEventsInterval(0); - config.controler().setWritePlansInterval(0); + config.controller().setMobsim("dummy"); + config.controller().setFirstIteration(0); + config.controller().setLastIteration(7); + + controler.getConfig().controller().setCreateGraphs(false); + controler.getConfig().controller().setDumpDataAtEnd(false); + controler.getConfig().controller().setWriteEventsInterval(0); + config.controller().setWritePlansInterval(0); controler.run(); - Assert.assertTrue(new File(config.controler().getOutputDirectory() + "ITERS/it.0/0.linkstats.txt.gz").exists()); - Assert.assertFalse(new File(config.controler().getOutputDirectory() + "ITERS/it.1/1.linkstats.txt.gz").exists()); - Assert.assertFalse(new File(config.controler().getOutputDirectory() + "ITERS/it.2/2.linkstats.txt.gz").exists()); - Assert.assertTrue(new File(config.controler().getOutputDirectory() + "ITERS/it.3/3.linkstats.txt.gz").exists()); - Assert.assertFalse(new File(config.controler().getOutputDirectory() + "ITERS/it.4/4.linkstats.txt.gz").exists()); - Assert.assertFalse(new File(config.controler().getOutputDirectory() + "ITERS/it.5/5.linkstats.txt.gz").exists()); - Assert.assertTrue(new File(config.controler().getOutputDirectory() + "ITERS/it.6/6.linkstats.txt.gz").exists()); - Assert.assertFalse(new File(config.controler().getOutputDirectory() + "ITERS/it.7/7.linkstats.txt.gz").exists()); + Assert.assertTrue(new File(config.controller().getOutputDirectory() + "ITERS/it.0/0.linkstats.txt.gz").exists()); + Assert.assertFalse(new File(config.controller().getOutputDirectory() + "ITERS/it.1/1.linkstats.txt.gz").exists()); + Assert.assertFalse(new File(config.controller().getOutputDirectory() + "ITERS/it.2/2.linkstats.txt.gz").exists()); + Assert.assertTrue(new File(config.controller().getOutputDirectory() + "ITERS/it.3/3.linkstats.txt.gz").exists()); + Assert.assertFalse(new File(config.controller().getOutputDirectory() + "ITERS/it.4/4.linkstats.txt.gz").exists()); + Assert.assertFalse(new File(config.controller().getOutputDirectory() + "ITERS/it.5/5.linkstats.txt.gz").exists()); + Assert.assertTrue(new File(config.controller().getOutputDirectory() + "ITERS/it.6/6.linkstats.txt.gz").exists()); + Assert.assertFalse(new File(config.controller().getOutputDirectory() + "ITERS/it.7/7.linkstats.txt.gz").exists()); } @Test public void testReset_CorrectlyExecuted() throws IOException { Config config = this.util.loadConfig((String) null); - config.controler().setMobsim("dummy"); - config.controler().setFirstIteration(0); - config.controler().setLastIteration(7); - config.controler().setWritePlansInterval(0); + config.controller().setMobsim("dummy"); + config.controller().setFirstIteration(0); + config.controller().setLastIteration(7); + config.controller().setWritePlansInterval(0); LinkStatsConfigGroup lsConfig = config.linkStats(); lsConfig.setWriteLinkStatsInterval(3); @@ -367,31 +367,31 @@ public void testReset_CorrectlyExecuted() throws IOException { controler.addOverridingModule(new AbstractModule() { @Override public void install() { - if (getConfig().controler().getMobsim().equals("dummy")) { + if (getConfig().controller().getMobsim().equals("dummy")) { bind(Mobsim.class).toProvider(DummyMobsimFactory.class); } } }); - controler.getConfig().controler().setCreateGraphs(false); - controler.getConfig().controler().setDumpDataAtEnd(false); - controler.getConfig().controler().setWriteEventsInterval(0); + controler.getConfig().controller().setCreateGraphs(false); + controler.getConfig().controller().setDumpDataAtEnd(false); + controler.getConfig().controller().setWriteEventsInterval(0); controler.run(); - Assert.assertFalse(new File(config.controler().getOutputDirectory() + "ITERS/it.0/0.linkstats.txt.gz").exists()); - Assert.assertFalse(new File(config.controler().getOutputDirectory() + "ITERS/it.1/1.linkstats.txt.gz").exists()); - Assert.assertFalse(new File(config.controler().getOutputDirectory() + "ITERS/it.2/2.linkstats.txt.gz").exists()); - Assert.assertTrue(new File(config.controler().getOutputDirectory() + "ITERS/it.3/3.linkstats.txt.gz").exists()); - Assert.assertFalse(new File(config.controler().getOutputDirectory() + "ITERS/it.4/4.linkstats.txt.gz").exists()); - Assert.assertFalse(new File(config.controler().getOutputDirectory() + "ITERS/it.5/5.linkstats.txt.gz").exists()); - Assert.assertTrue(new File(config.controler().getOutputDirectory() + "ITERS/it.6/6.linkstats.txt.gz").exists()); - Assert.assertFalse(new File(config.controler().getOutputDirectory() + "ITERS/it.7/7.linkstats.txt.gz").exists()); + Assert.assertFalse(new File(config.controller().getOutputDirectory() + "ITERS/it.0/0.linkstats.txt.gz").exists()); + Assert.assertFalse(new File(config.controller().getOutputDirectory() + "ITERS/it.1/1.linkstats.txt.gz").exists()); + Assert.assertFalse(new File(config.controller().getOutputDirectory() + "ITERS/it.2/2.linkstats.txt.gz").exists()); + Assert.assertTrue(new File(config.controller().getOutputDirectory() + "ITERS/it.3/3.linkstats.txt.gz").exists()); + Assert.assertFalse(new File(config.controller().getOutputDirectory() + "ITERS/it.4/4.linkstats.txt.gz").exists()); + Assert.assertFalse(new File(config.controller().getOutputDirectory() + "ITERS/it.5/5.linkstats.txt.gz").exists()); + Assert.assertTrue(new File(config.controller().getOutputDirectory() + "ITERS/it.6/6.linkstats.txt.gz").exists()); + Assert.assertFalse(new File(config.controller().getOutputDirectory() + "ITERS/it.7/7.linkstats.txt.gz").exists()); - double[] volumes = getVolumes(config.controler().getOutputDirectory() + "ITERS/it.3/3.linkstats.txt"); + double[] volumes = getVolumes(config.controller().getOutputDirectory() + "ITERS/it.3/3.linkstats.txt"); Assert.assertEquals(3, volumes[0], 1e-8); Assert.assertEquals(3.5, volumes[1], 1e-8); Assert.assertEquals(4, volumes[2], 1e-8); - volumes = getVolumes(config.controler().getOutputDirectory() + "ITERS/it.6/6.linkstats.txt"); + volumes = getVolumes(config.controller().getOutputDirectory() + "ITERS/it.6/6.linkstats.txt"); Assert.assertEquals(6, volumes[0], 1e-8); Assert.assertEquals(6.5, volumes[1], 1e-8); Assert.assertEquals(7, volumes[2], 1e-8); diff --git a/matsim/src/test/java/org/matsim/analysis/OutputTravelStatsTest.java b/matsim/src/test/java/org/matsim/analysis/OutputTravelStatsTest.java index a0b143b7642..2ed4392921c 100644 --- a/matsim/src/test/java/org/matsim/analysis/OutputTravelStatsTest.java +++ b/matsim/src/test/java/org/matsim/analysis/OutputTravelStatsTest.java @@ -44,9 +44,9 @@ public void testActivitiesOutputCSV() throws IOException { String outputDirectory = util.getOutputDirectory(); Config config = this.util.loadConfig("test/scenarios/equil/config_plans1.xml"); - config.controler().setLastIteration(10); - config.controler().setWriteTripsInterval(1); - config.controler().setOutputDirectory(outputDirectory); + config.controller().setLastIteration(10); + config.controller().setWriteTripsInterval(1); + config.controller().setOutputDirectory(outputDirectory); Controler c = new Controler(config); c.run(); diff --git a/matsim/src/test/java/org/matsim/core/config/ConfigReaderMatsimV2Test.java b/matsim/src/test/java/org/matsim/core/config/ConfigReaderMatsimV2Test.java index 2930c9770f9..b2650dd0264 100644 --- a/matsim/src/test/java/org/matsim/core/config/ConfigReaderMatsimV2Test.java +++ b/matsim/src/test/java/org/matsim/core/config/ConfigReaderMatsimV2Test.java @@ -33,7 +33,7 @@ public void testModuleNameAlias() { r2.getConfigAliases().addAlias("theController", ControllerConfigGroup.GROUP_NAME); r2.readStream(bais); - Assert.assertEquals(27, config.controler().getLastIteration()); + Assert.assertEquals(27, config.controller().getLastIteration()); } @Test @@ -55,7 +55,7 @@ public void testParamNameAlias() { r2.getConfigAliases().addAlias("theLastIteration", "lastIteration"); r2.readStream(bais); - Assert.assertEquals(23, config.controler().getLastIteration()); + Assert.assertEquals(23, config.controller().getLastIteration()); } @Test @@ -78,7 +78,7 @@ public void testModuleAndParamNameAlias() { r2.getConfigAliases().addAlias("theLastIteration", "lastIteration"); r2.readStream(bais); - Assert.assertEquals(23, config.controler().getLastIteration()); + Assert.assertEquals(23, config.controller().getLastIteration()); } /** @@ -267,7 +267,7 @@ public void testAliasWithParamSets() { r2.getConfigAliases().addAlias("theMode", "mode", "scoring", "scoringParameters", "modeParams"); r2.readStream(bais); - Assert.assertEquals(-5.6, config.planCalcScore().getModes().get("car").getMarginalUtilityOfTraveling(), 1e-7); - Assert.assertEquals(-8.7, config.planCalcScore().getModes().get("unicycle").getMarginalUtilityOfTraveling(), 1e-7); + Assert.assertEquals(-5.6, config.scoring().getModes().get("car").getMarginalUtilityOfTraveling(), 1e-7); + Assert.assertEquals(-8.7, config.scoring().getModes().get("unicycle").getMarginalUtilityOfTraveling(), 1e-7); } } diff --git a/matsim/src/test/java/org/matsim/core/config/consistency/ConfigConsistencyCheckerImplTest.java b/matsim/src/test/java/org/matsim/core/config/consistency/ConfigConsistencyCheckerImplTest.java index 34b8461e6d7..737607dae7d 100644 --- a/matsim/src/test/java/org/matsim/core/config/consistency/ConfigConsistencyCheckerImplTest.java +++ b/matsim/src/test/java/org/matsim/core/config/consistency/ConfigConsistencyCheckerImplTest.java @@ -58,7 +58,7 @@ public void testCheckPlanCalcScore_Traveling() { Config config = new Config(); config.addCoreModules(); - config.planCalcScore().getModes().get(TransportMode.car).setMarginalUtilityOfTraveling(3.0); + config.scoring().getModes().get(TransportMode.car).setMarginalUtilityOfTraveling(3.0); LogCounter logger = new LogCounter(Level.WARN); try { @@ -76,7 +76,7 @@ public void testCheckPlanCalcScore_TravelingPt() { Config config = new Config(); config.addCoreModules(); - config.planCalcScore().getModes().get(TransportMode.pt).setMarginalUtilityOfTraveling(3.0); + config.scoring().getModes().get(TransportMode.pt).setMarginalUtilityOfTraveling(3.0); LogCounter logger = new LogCounter(Level.WARN); try { @@ -94,7 +94,7 @@ public void testCheckPlanCalcScore_TravelingBike() { Config config = new Config(); config.addCoreModules(); - config.planCalcScore().getModes().get(TransportMode.bike).setMarginalUtilityOfTraveling(3.0); + config.scoring().getModes().get(TransportMode.bike).setMarginalUtilityOfTraveling(3.0); LogCounter logger = new LogCounter(Level.WARN); try { @@ -112,7 +112,7 @@ public void testCheckPlanCalcScore_TravelingWalk() { Config config = new Config(); config.addCoreModules(); - config.planCalcScore().getModes().get(TransportMode.walk).setMarginalUtilityOfTraveling(3.0); + config.scoring().getModes().get(TransportMode.walk).setMarginalUtilityOfTraveling(3.0); LogCounter logger = new LogCounter(Level.WARN); try { @@ -132,7 +132,7 @@ public void testCheckPlanCalcScore_PtInteractionActivity() { ActivityParams transitActivityParams = new ActivityParams(PtConstants.TRANSIT_ACTIVITY_TYPE); transitActivityParams.setClosingTime(1.) ; - config.planCalcScore().addActivityParams(transitActivityParams); + config.scoring().addActivityParams(transitActivityParams); try { ConfigConsistencyCheckerImpl.checkPlanCalcScore(config); @@ -165,9 +165,9 @@ public void checkConsistencyBetweenRouterAndTravelTimeCalculatorTest(){ Assert.assertFalse( problem ); } { - Set modes = new LinkedHashSet<>( config.plansCalcRoute().getNetworkModes() ); + Set modes = new LinkedHashSet<>( config.routing().getNetworkModes() ); modes.add( TransportMode.bike ); - config.plansCalcRoute().setNetworkModes( modes ); + config.routing().setNetworkModes( modes ); boolean problem = ConfigConsistencyCheckerImpl.checkConsistencyBetweenRouterAndTravelTimeCalculator( config ); Assert.assertFalse( problem ); @@ -199,9 +199,9 @@ public void checkConsistencyBetweenRouterAndTravelTimeCalculatorTest(){ ConfigConsistencyCheckerImpl.checkConsistencyBetweenRouterAndTravelTimeCalculator( config ); { - Set modes = new LinkedHashSet<>( config.plansCalcRoute().getNetworkModes() ); + Set modes = new LinkedHashSet<>( config.routing().getNetworkModes() ); modes.add( TransportMode.bike ); - config.plansCalcRoute().setNetworkModes( modes ); + config.routing().setNetworkModes( modes ); boolean problem = ConfigConsistencyCheckerImpl.checkConsistencyBetweenRouterAndTravelTimeCalculator( config ); // see comments inside that static function. kai, jul'19 diff --git a/matsim/src/test/java/org/matsim/core/config/groups/ReplanningConfigGroupTest.java b/matsim/src/test/java/org/matsim/core/config/groups/ReplanningConfigGroupTest.java index bbc2fab6a94..17409e3ec33 100644 --- a/matsim/src/test/java/org/matsim/core/config/groups/ReplanningConfigGroupTest.java +++ b/matsim/src/test/java/org/matsim/core/config/groups/ReplanningConfigGroupTest.java @@ -160,7 +160,7 @@ public void testIOWithFormatChange() { final Config configV1In = ConfigUtils.createConfig(); new ConfigReader( configV1In ).readFile( v1path ); - assertIdentical("re-read v1", initialGroup, configV1In.strategy()); + assertIdentical("re-read v1", initialGroup, configV1In.replanning()); final String v2path = utils.getOutputDirectory() + "/configv2_out.xml"; @@ -169,7 +169,7 @@ public void testIOWithFormatChange() { final Config configV2 = ConfigUtils.createConfig(); new ConfigReader( configV2 ).readFile( v2path ); - assertIdentical("re-read v2", initialGroup, configV2.strategy()); + assertIdentical("re-read v2", initialGroup, configV2.replanning()); } private void assertIdentical( diff --git a/matsim/src/test/java/org/matsim/core/config/groups/RoutingConfigGroupTest.java b/matsim/src/test/java/org/matsim/core/config/groups/RoutingConfigGroupTest.java index 813154b79f3..7b765cd84bb 100644 --- a/matsim/src/test/java/org/matsim/core/config/groups/RoutingConfigGroupTest.java +++ b/matsim/src/test/java/org/matsim/core/config/groups/RoutingConfigGroupTest.java @@ -49,7 +49,7 @@ public void testAddModeParamsTwice() { final String filename = outdir + "config.xml"; { Config config = ConfigUtils.createConfig(); - RoutingConfigGroup group = config.plansCalcRoute(); + RoutingConfigGroup group = config.routing(); Assert.assertEquals( N_MODE_ROUTING_PARAMS_DEFAULT, group.getModeRoutingParams().size() ); group.clearModeRoutingParams(); // group.setTeleportedModeSpeed( TransportMode.bike, 1. ); @@ -63,7 +63,7 @@ public void testAddModeParamsTwice() { } { Config config = ConfigUtils.loadConfig( filename ) ; - RoutingConfigGroup group = config.plansCalcRoute(); + RoutingConfigGroup group = config.routing(); Assert.assertEquals( 0, group.getModeRoutingParams().size() ); } } @@ -73,7 +73,7 @@ public void testClearParamsWriteRead() { final String filename = outdir + "config.xml"; { Config config = ConfigUtils.createConfig(); - RoutingConfigGroup group = config.plansCalcRoute(); + RoutingConfigGroup group = config.routing(); Assert.assertEquals( N_MODE_ROUTING_PARAMS_DEFAULT, group.getModeRoutingParams().size() ); group.clearModeRoutingParams(); group.setTeleportedModeSpeed( TransportMode.bike, 1. ); @@ -87,7 +87,7 @@ public void testClearParamsWriteRead() { } { Config config = ConfigUtils.loadConfig( filename ) ; - RoutingConfigGroup group = config.plansCalcRoute(); + RoutingConfigGroup group = config.routing(); Assert.assertEquals( 0, group.getModeRoutingParams().size() ); } } @@ -97,7 +97,7 @@ public void testRemoveParamsWriteRead() { final String filename = outdir + "config.xml"; { Config config = ConfigUtils.createConfig(); - RoutingConfigGroup group = config.plansCalcRoute(); + RoutingConfigGroup group = config.routing(); Assert.assertEquals( N_MODE_ROUTING_PARAMS_DEFAULT, group.getModeRoutingParams().size() ); group.setTeleportedModeSpeed( TransportMode.bike, 1. ); Assert.assertEquals( 1, group.getModeRoutingParams().size() ); @@ -112,14 +112,14 @@ public void testRemoveParamsWriteRead() { } { Config config = ConfigUtils.loadConfig( filename ) ; - RoutingConfigGroup group = config.plansCalcRoute(); + RoutingConfigGroup group = config.routing(); Assert.assertEquals( 0, group.getModeRoutingParams().size() ); } } @Test public void testClearDefaults() { Config config = ConfigUtils.createConfig( ) ; - RoutingConfigGroup group = config.plansCalcRoute() ; + RoutingConfigGroup group = config.routing() ; Assert.assertEquals( N_MODE_ROUTING_PARAMS_DEFAULT, group.getModeRoutingParams().size() ); group.setTeleportedModeSpeed( "def", 1. ); Assert.assertEquals( 1, group.getModeRoutingParams().size() ); @@ -131,7 +131,7 @@ public void testClearDefaults() { @Test public void test3() { Config config = ConfigUtils.createConfig( ) ; - RoutingConfigGroup group = config.plansCalcRoute() ; + RoutingConfigGroup group = config.routing() ; group.clearModeRoutingParams(); group.setClearingDefaultModeRoutingParams( true ); // should be ok } @@ -197,7 +197,7 @@ public void testIODifferentVersions() log.info("... done reading file into new config.") ; log.info( "asserting ..."); - assertIdentical("re-read v1", initialGroup, configV1In.plansCalcRoute()); + assertIdentical("re-read v1", initialGroup, configV1In.routing()); log.info( "... done asserting.") ; final String v2path = utils.getOutputDirectory() + "/configv2_out.xml"; @@ -207,7 +207,7 @@ public void testIODifferentVersions() final Config configV2 = ConfigUtils.createConfig(); new ConfigReader( configV2 ).readFile( v2path ); - assertIdentical("re-read v2", initialGroup, configV2.plansCalcRoute()); + assertIdentical("re-read v2", initialGroup, configV2.routing()); } @Test( expected=RuntimeException.class ) @@ -215,7 +215,7 @@ public void testConsistencyCheckIfNoTeleportedSpeed() { final Config config = ConfigUtils.createConfig(); final TeleportedModeParams params = new TeleportedModeParams( "skateboard" ); - config.plansCalcRoute().addModeRoutingParams( params ); + config.routing().addModeRoutingParams( params ); // (one needs to set one of the teleported speed settings) config.checkConsistency(); diff --git a/matsim/src/test/java/org/matsim/core/config/groups/ScoringConfigGroupTest.java b/matsim/src/test/java/org/matsim/core/config/groups/ScoringConfigGroupTest.java index d214f679a40..16e7f336a44 100644 --- a/matsim/src/test/java/org/matsim/core/config/groups/ScoringConfigGroupTest.java +++ b/matsim/src/test/java/org/matsim/core/config/groups/ScoringConfigGroupTest.java @@ -49,7 +49,7 @@ public class ScoringConfigGroupTest { public final MatsimTestUtils utils = new MatsimTestUtils(); private void testResultsBeforeCheckConsistency( Config config, boolean fullyHierarchical ) { - ScoringConfigGroup scoringConfig = config.planCalcScore() ; + ScoringConfigGroup scoringConfig = config.scoring() ; if ( ! fullyHierarchical ){ // mode params are there for default modes: @@ -70,10 +70,10 @@ private void testResultsBeforeCheckConsistency( Config config, boolean fullyHier // } } private void testResultsAfterCheckConsistency( Config config ) { - ScoringConfigGroup scoringConfig = config.planCalcScore() ; + ScoringConfigGroup scoringConfig = config.scoring() ; // default stage/interaction params for modes routed on the network are now there: - for( String networkMode : config.plansCalcRoute().getNetworkModes() ){ + for( String networkMode : config.routing().getNetworkModes() ){ Assert.assertNotNull( scoringConfig.getActivityParams( createStageActivityType( networkMode ) ) ); } } @@ -81,7 +81,7 @@ private void testResultsAfterCheckConsistency( Config config ) { @Test public void testFullyHierarchicalVersion() { Config config = ConfigUtils.loadConfig( utils.getClassInputDirectory() + "config_v2_w_scoringparams.xml" ) ; - ScoringConfigGroup scoringConfig = config.planCalcScore() ; + ScoringConfigGroup scoringConfig = config.scoring() ; testResultsBeforeCheckConsistency( config, true ) ; log.warn( "" ); for( ModeParams modeParams : scoringConfig.getModes().values() ){ @@ -93,7 +93,7 @@ public void testFullyHierarchicalVersion() { } log.warn( "" ); log.warn( "checking consistency ..." ); - config.plansCalcRoute().setAccessEgressType(RoutingConfigGroup.AccessEgressType.accessEgressModeToLink); + config.routing().setAccessEgressType(RoutingConfigGroup.AccessEgressType.accessEgressModeToLink); scoringConfig.checkConsistency( config ); testResultsAfterCheckConsistency( config ); log.warn( "" ); @@ -109,7 +109,7 @@ public void testFullyHierarchicalVersion() { @Test public void testVersionWoScoringparams() { Config config = ConfigUtils.loadConfig( utils.getClassInputDirectory() + "config_v2_wo_scoringparams.xml" ) ; - ScoringConfigGroup scoringConfig = config.planCalcScore() ; + ScoringConfigGroup scoringConfig = config.scoring() ; testResultsBeforeCheckConsistency( config, false ) ; log.warn( "" ); for( ModeParams modeParams : scoringConfig.getModes().values() ){ @@ -121,7 +121,7 @@ public void testVersionWoScoringparams() { } log.warn( "" ); log.warn( "checking consistency ..." ); - config.plansCalcRoute().setAccessEgressType( RoutingConfigGroup.AccessEgressType.accessEgressModeToLink); + config.routing().setAccessEgressType( RoutingConfigGroup.AccessEgressType.accessEgressModeToLink); scoringConfig.checkConsistency( config ); testResultsAfterCheckConsistency( config ); log.warn( "" ); @@ -161,7 +161,7 @@ public void testIODifferentVersions() { final Config configV1In = ConfigUtils.createConfig(); new ConfigReader( configV1In ).readFile( v1path ); - assertIdentical("re-read v1", initialGroup, configV1In.planCalcScore()); + assertIdentical("re-read v1", initialGroup, configV1In.scoring()); final String v2path = utils.getOutputDirectory() + "/configv2_out.xml"; @@ -170,7 +170,7 @@ public void testIODifferentVersions() { final Config configV2 = ConfigUtils.createConfig(); new ConfigReader( configV2 ).readFile( v2path ); - assertIdentical("re-read v2", initialGroup, configV2.planCalcScore()); + assertIdentical("re-read v2", initialGroup, configV2.scoring()); } private void assertIdentical( diff --git a/matsim/src/test/java/org/matsim/core/controler/AbstractModuleTest.java b/matsim/src/test/java/org/matsim/core/controler/AbstractModuleTest.java index 98f682623db..ae3c97c0a8e 100644 --- a/matsim/src/test/java/org/matsim/core/controler/AbstractModuleTest.java +++ b/matsim/src/test/java/org/matsim/core/controler/AbstractModuleTest.java @@ -28,7 +28,7 @@ public class AbstractModuleTest{ public void test1() { Config config = ConfigUtils.createConfig() ; - config.controler().setOutputDirectory( utils.getOutputDirectory() ); + config.controller().setOutputDirectory( utils.getOutputDirectory() ); Scenario scenario = ScenarioUtils.loadScenario( config ) ; diff --git a/matsim/src/test/java/org/matsim/core/controler/ControlerEventsTest.java b/matsim/src/test/java/org/matsim/core/controler/ControlerEventsTest.java index 4dae7008bee..4a696e4e606 100644 --- a/matsim/src/test/java/org/matsim/core/controler/ControlerEventsTest.java +++ b/matsim/src/test/java/org/matsim/core/controler/ControlerEventsTest.java @@ -107,7 +107,7 @@ private static class TestController extends AbstractController { public TestController(Config config) { this.config = config; - super.setupOutputDirectory(new OutputDirectoryHierarchy(config.controler())); + super.setupOutputDirectory(new OutputDirectoryHierarchy(config.controller())); } @Override @@ -131,12 +131,12 @@ protected void prepareForMobsim() { @Override protected boolean mayTerminateAfterIteration(int iteration) { - return iteration >= config.controler().getLastIteration(); + return iteration >= config.controller().getLastIteration(); } @Override protected boolean shouldTerminate(int iteration) { - return iteration >= config.controler().getLastIteration(); + return iteration >= config.controller().getLastIteration(); } } diff --git a/matsim/src/test/java/org/matsim/core/controler/ControlerIT.java b/matsim/src/test/java/org/matsim/core/controler/ControlerIT.java index c5589cfef3b..f572f9ecacc 100644 --- a/matsim/src/test/java/org/matsim/core/controler/ControlerIT.java +++ b/matsim/src/test/java/org/matsim/core/controler/ControlerIT.java @@ -100,8 +100,8 @@ public void testScenarioLoading() { Controler controler = new Controler( config ); // need to run the controler to get Scenario initilized - controler.getConfig().controler().setLastIteration( 0 ); - controler.getConfig().controler().setCleanItersAtEnd(ControllerConfigGroup.CleanIterations.keep); + controler.getConfig().controller().setLastIteration( 0 ); + controler.getConfig().controller().setCleanItersAtEnd(ControllerConfigGroup.CleanIterations.keep); controler.run(); assertNotNull(controler.getScenario().getNetwork()); // is required, e.g. for changing the factories @@ -115,7 +115,7 @@ public void testScenarioLoading() { @Test public void testTerminationCriterion() { final Config config = utils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("equil"), "config.xml")); - config.controler().setOutputDirectory(utils.getOutputDirectory()); + config.controller().setOutputDirectory(utils.getOutputDirectory()); Controler controler = new Controler(config); controler.setTerminationCriterion(new TerminationCriterion() { @Override @@ -199,17 +199,17 @@ public void testTravelTimeCalculation() { double avgTravelTimeLink2 = 150.5; // Complete the configuration for our test case - config.controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles); - config.controler().setCreateGraphs(false); - config.controler().setWriteEventsInterval(0); - config.controler().setDumpDataAtEnd(false); + config.controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles); + config.controller().setCreateGraphs(false); + config.controller().setWriteEventsInterval(0); + config.controller().setDumpDataAtEnd(false); // - set scoring parameters ActivityParams actParams = new ActivityParams("h"); actParams.setTypicalDuration(8*3600); actParams.setPriority(1.0); - config.planCalcScore().addActivityParams(actParams); + config.scoring().addActivityParams(actParams); // - define iterations - config.controler().setLastIteration(0); + config.controller().setLastIteration(0); // - make sure we don't use threads, as they are not deterministic config.global().setNumberOfThreads(0); @@ -225,13 +225,13 @@ public void testTravelTimeCalculation() { controler.getLinkTravelTimes().getLinkTravelTime(f.link2, 7 * 3600, null, null), MatsimTestUtils.EPSILON); // now test that the ReRoute-Strategy also knows about these travel times... - config.controler().setLastIteration(1); - config.strategy().setMaxAgentPlanMemorySize(4); + config.controller().setLastIteration(1); + config.replanning().setMaxAgentPlanMemorySize(4); // add ReRoute strategy StrategySettings strat = new StrategySettings(); strat.setStrategyName(DefaultStrategy.ReRoute.toString()); strat.setWeight(1.); - config.strategy().addStrategySettings(strat); + config.replanning().addStrategySettings(strat); // Run the simulation again controler = new Controler(f.scenario); controler.run(); @@ -251,7 +251,7 @@ public void testTravelTimeCalculation() { @Test public void testSetScoringFunctionFactory() { final Config config = this.utils.loadConfig((String) null); - config.controler().setLastIteration(0); + config.controller().setLastIteration(0); config.qsim().setUsingFastCapacityUpdate( this.isUsingFastCapacityUpdate ); @@ -269,8 +269,8 @@ public void testSetScoringFunctionFactory() { link.setNumberOfLanes(1); final Controler controler = new Controler(scenario); - controler.getConfig().controler().setCreateGraphs(false); - controler.getConfig().controler().setWriteEventsInterval(0); + controler.getConfig().controller().setCreateGraphs(false); + controler.getConfig().controller().setWriteEventsInterval(0); controler.setScoringFunctionFactory(new DummyScoringFunctionFactory()); controler.addOverridingModule(new AbstractModule() { @@ -284,7 +284,7 @@ public Mobsim get() { }); } }); - controler.getConfig().controler().setDumpDataAtEnd(false); + controler.getConfig().controller().setDumpDataAtEnd(false); controler.run(); assertTrue("Custom ScoringFunctionFactory was not set.", @@ -337,9 +337,9 @@ public void testCalcMissingRoutes() { ActivityParams actParams = new ActivityParams("h"); actParams.setTypicalDuration(8*3600); actParams.setPriority(1.0); - config.planCalcScore().addActivityParams(actParams); + config.scoring().addActivityParams(actParams); // - define iterations - config.controler().setLastIteration(0); + config.controller().setLastIteration(0); // - make sure we don't use threads, as they are not deterministic config.global().setNumberOfThreads(1); @@ -347,8 +347,8 @@ public void testCalcMissingRoutes() { // Now run the simulation Controler controler = new Controler(f.scenario); - controler.getConfig().controler().setCreateGraphs(false); - controler.getConfig().controler().setWriteEventsInterval(0); + controler.getConfig().controller().setCreateGraphs(false); + controler.getConfig().controller().setWriteEventsInterval(0); controler.addOverridingModule(new AbstractModule() { @Override public void install() { @@ -360,7 +360,7 @@ public Mobsim get() { }); } }); - controler.getConfig().controler().setDumpDataAtEnd(false); + controler.getConfig().controller().setDumpDataAtEnd(false); controler.run(); /* if something goes wrong, there will be an exception we don't catch and the test fails, * otherwise, everything is fine. */ @@ -435,9 +435,9 @@ public void testCalcMissingActLinks() { ActivityParams actParams = new ActivityParams("h"); actParams.setTypicalDuration(8*3600); actParams.setPriority(1.0); - config.planCalcScore().addActivityParams(actParams); + config.scoring().addActivityParams(actParams); // - define iterations - config.controler().setLastIteration(0); + config.controller().setLastIteration(0); // - make sure we don't use threads, as they are not deterministic config.global().setNumberOfThreads(1); @@ -445,8 +445,8 @@ public void testCalcMissingActLinks() { // Now run the simulation Controler controler = new Controler(f.scenario); - controler.getConfig().controler().setCreateGraphs(false); - controler.getConfig().controler().setWriteEventsInterval(0); + controler.getConfig().controller().setCreateGraphs(false); + controler.getConfig().controller().setWriteEventsInterval(0); controler.addOverridingModule(new AbstractModule() { @Override public void install() { @@ -458,7 +458,7 @@ public Mobsim get() { }); } }); - controler.getConfig().controler().setDumpDataAtEnd(false); + controler.getConfig().controller().setDumpDataAtEnd(false); controler.run(); /* if something goes wrong, there will be an exception we don't catch and the test fails, * otherwise, everything is fine. */ @@ -470,7 +470,7 @@ public Mobsim get() { assertEquals(f.link3.getId(), act2b.getLinkId()); int expectedPlanLength = 3 ; - if ( !f.scenario.getConfig().plansCalcRoute().getAccessEgressType().equals(RoutingConfigGroup.AccessEgressType.none) ) { + if ( !f.scenario.getConfig().routing().getAccessEgressType().equals(RoutingConfigGroup.AccessEgressType.none) ) { // now 7 instead of earlier 3: h-wlk-iact-car-iact-walk-h expectedPlanLength = 7 ; } @@ -487,7 +487,7 @@ public Mobsim get() { assertNotNull( "null route in plan "+plan.getPlanElements(), ((Leg) plan.getPlanElements().get( 1 )).getRoute()); - if ( !f.scenario.getConfig().plansCalcRoute().getAccessEgressType().equals(RoutingConfigGroup.AccessEgressType.none) ) { + if ( !f.scenario.getConfig().routing().getAccessEgressType().equals(RoutingConfigGroup.AccessEgressType.none) ) { assertNotNull( "null route in plan "+plan.getPlanElements(), ((Leg) plan.getPlanElements().get( 3 )).getRoute()); @@ -501,13 +501,13 @@ public Mobsim get() { @Test public void testCompressionType() { final Config config = utils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("equil"), "config_plans1.xml")); - config.controler().setLastIteration(0); - config.controler().setCompressionType( CompressionType.zst ); - config.controler().setCleanItersAtEnd(ControllerConfigGroup.CleanIterations.keep); + config.controller().setLastIteration(0); + config.controller().setCompressionType( CompressionType.zst ); + config.controller().setCleanItersAtEnd(ControllerConfigGroup.CleanIterations.keep); final Controler controler = new Controler(config); - controler.getConfig().controler().setCreateGraphs(false); + controler.getConfig().controller().setCreateGraphs(false); controler.addOverridingModule(new AbstractModule() { @Override public void install() { @@ -540,17 +540,17 @@ public Mobsim get() { @Test public void testSetWriteEventsInterval() { final Config config = utils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("equil"), "config_plans1.xml")); - config.controler().setLastIteration(10); - config.controler().setWritePlansInterval(0); + config.controller().setLastIteration(10); + config.controller().setWritePlansInterval(0); final Controler controler = new Controler(config); assertFalse("Default for Controler.writeEventsInterval should be different from the interval we plan to use, otherwise it's hard to decide if it works correctly.", - 3 == controler.getConfig().controler().getWriteEventsInterval()); + 3 == controler.getConfig().controller().getWriteEventsInterval()); - controler.getConfig().controler().setWriteEventsInterval(3); - assertEquals(3, controler.getConfig().controler().getWriteEventsInterval()); + controler.getConfig().controller().setWriteEventsInterval(3); + assertEquals(3, controler.getConfig().controller().getWriteEventsInterval()); - controler.getConfig().controler().setCreateGraphs(false); + controler.getConfig().controller().setCreateGraphs(false); controler.addOverridingModule(new AbstractModule() { @Override public void install() { @@ -562,7 +562,7 @@ public Mobsim get() { }); } }); - controler.getConfig().controler().setDumpDataAtEnd(false); + controler.getConfig().controller().setDumpDataAtEnd(false); controler.run(); assertTrue(new File(controler.getControlerIO().getIterationFilename(0, Controler.DefaultFiles.events)).exists()); @@ -575,7 +575,7 @@ public Mobsim get() { assertFalse(new File(controler.getControlerIO().getIterationFilename(7, Controler.DefaultFiles.events)).exists()); assertFalse(new File(controler.getControlerIO().getIterationFilename(8, Controler.DefaultFiles.events)).exists()); assertTrue(new File(controler.getControlerIO().getIterationFilename(9, Controler.DefaultFiles.events)).exists()); - assertTrue(new File(controler.getControlerIO().getIterationFilename(controler.getConfig().controler().getLastIteration(), Controler.DefaultFiles.events)).exists()); + assertTrue(new File(controler.getControlerIO().getIterationFilename(controler.getConfig().controller().getLastIteration(), Controler.DefaultFiles.events)).exists()); } /** @@ -584,13 +584,13 @@ public Mobsim get() { @Test public void testSetWriteEventsIntervalConfig() { final Config config = utils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("equil"), "config_plans1.xml")); - config.controler().setLastIteration(10); - config.controler().setWritePlansInterval(0); + config.controller().setLastIteration(10); + config.controller().setWritePlansInterval(0); final Controler controler = new Controler(config); assertFalse("Default for Controler.writeEventsInterval should be different from the interval we plan to use, otherwise it's hard to decide if it works correctly.", - 3 == controler.getConfig().controler().getWriteEventsInterval()); - controler.getConfig().controler().setCreateGraphs(false); + 3 == controler.getConfig().controller().getWriteEventsInterval()); + controler.getConfig().controller().setCreateGraphs(false); controler.addOverridingModule(new AbstractModule() { @Override public void install() { @@ -602,9 +602,9 @@ public Mobsim get() { }); } }); - controler.getConfig().controler().setDumpDataAtEnd(false); + controler.getConfig().controller().setDumpDataAtEnd(false); controler.run(); - assertEquals(4, controler.getConfig().controler().getWriteEventsInterval()); + assertEquals(4, controler.getConfig().controller().getWriteEventsInterval()); assertTrue(new File(controler.getControlerIO().getIterationFilename(0, Controler.DefaultFiles.events)).exists()); assertFalse(new File(controler.getControlerIO().getIterationFilename(1, Controler.DefaultFiles.events)).exists()); @@ -616,7 +616,7 @@ public Mobsim get() { assertFalse(new File(controler.getControlerIO().getIterationFilename(7, Controler.DefaultFiles.events)).exists()); assertTrue(new File(controler.getControlerIO().getIterationFilename(8, Controler.DefaultFiles.events)).exists()); assertFalse(new File(controler.getControlerIO().getIterationFilename(9, Controler.DefaultFiles.events)).exists()); - assertTrue(new File(controler.getControlerIO().getIterationFilename(controler.getConfig().controler().getLastIteration(), Controler.DefaultFiles.events)).exists()); + assertTrue(new File(controler.getControlerIO().getIterationFilename(controler.getConfig().controller().getLastIteration(), Controler.DefaultFiles.events)).exists()); } /** @@ -625,15 +625,15 @@ public Mobsim get() { @Test public void testSetWriteEventsNever() { final Config config = utils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("equil"), "config_plans1.xml")); - config.controler().setLastIteration(1); - config.controler().setWritePlansInterval(0); + config.controller().setLastIteration(1); + config.controller().setWritePlansInterval(0); final Controler controler = new Controler(config); assertFalse("Default for Controler.writeEventsInterval should be different from the interval we plan to use, otherwise it's hard to decide if it works correctly.", - 0 == controler.getConfig().controler().getWriteEventsInterval()); - controler.getConfig().controler().setWriteEventsInterval(0); - assertEquals(0, controler.getConfig().controler().getWriteEventsInterval()); - controler.getConfig().controler().setCreateGraphs(false); + 0 == controler.getConfig().controller().getWriteEventsInterval()); + controler.getConfig().controller().setWriteEventsInterval(0); + assertEquals(0, controler.getConfig().controller().getWriteEventsInterval()); + controler.getConfig().controller().setCreateGraphs(false); controler.addOverridingModule(new AbstractModule() { @Override public void install() { @@ -645,7 +645,7 @@ public Mobsim get() { }); } }); - controler.getConfig().controler().setDumpDataAtEnd(false); + controler.getConfig().controller().setDumpDataAtEnd(false); controler.run(); assertFalse(new File(controler.getControlerIO().getIterationFilename(0, Controler.DefaultFiles.events)).exists()); @@ -658,13 +658,13 @@ public Mobsim get() { @Test public void testSetWriteEventsAlways() { final Config config = utils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("equil"), "config_plans1.xml")); - config.controler().setLastIteration(1); - config.controler().setWritePlansInterval(0); + config.controller().setLastIteration(1); + config.controller().setWritePlansInterval(0); final Controler controler = new Controler(config); - controler.getConfig().controler().setWriteEventsInterval(1); - assertEquals(1, controler.getConfig().controler().getWriteEventsInterval()); - controler.getConfig().controler().setCreateGraphs(false); + controler.getConfig().controller().setWriteEventsInterval(1); + assertEquals(1, controler.getConfig().controller().getWriteEventsInterval()); + controler.getConfig().controller().setCreateGraphs(false); controler.addOverridingModule(new AbstractModule() { @Override public void install() { @@ -676,7 +676,7 @@ public Mobsim get() { }); } }); - controler.getConfig().controler().setDumpDataAtEnd(false); + controler.getConfig().controller().setDumpDataAtEnd(false); controler.run(); assertTrue(new File(controler.getControlerIO().getIterationFilename(0, Controler.DefaultFiles.events)).exists()); @@ -689,14 +689,14 @@ public Mobsim get() { @Test public void testSetWriteEventsXml() { final Config config = utils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("equil"), "config_plans1.xml")); - config.controler().setLastIteration(0); - config.controler().setWritePlansInterval(0); - config.controler().setEventsFileFormats(EnumSet.of(EventsFileFormat.xml)); + config.controller().setLastIteration(0); + config.controller().setWritePlansInterval(0); + config.controller().setEventsFileFormats(EnumSet.of(EventsFileFormat.xml)); final Controler controler = new Controler(config); - controler.getConfig().controler().setWriteEventsInterval(1); - assertEquals(1, controler.getConfig().controler().getWriteEventsInterval()); - controler.getConfig().controler().setCreateGraphs(false); + controler.getConfig().controller().setWriteEventsInterval(1); + assertEquals(1, controler.getConfig().controller().getWriteEventsInterval()); + controler.getConfig().controller().setCreateGraphs(false); controler.addOverridingModule(new AbstractModule() { @Override public void install() { @@ -708,7 +708,7 @@ public Mobsim get() { }); } }); - controler.getConfig().controler().setDumpDataAtEnd(false); + controler.getConfig().controller().setDumpDataAtEnd(false); controler.run(); assertTrue(new File(controler.getControlerIO().getIterationFilename(0, Controler.DefaultFiles.events)).exists()); @@ -720,12 +720,12 @@ public Mobsim get() { @Test public void testSetDumpDataAtEnd_true() { final Config config = utils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("equil"), "config_plans1.xml")); - config.controler().setLastIteration(0); - config.controler().setWritePlansInterval(0); + config.controller().setLastIteration(0); + config.controller().setWritePlansInterval(0); final Controler controler = new Controler(config); - controler.getConfig().controler().setWriteEventsInterval(0); - controler.getConfig().controler().setCreateGraphs(false); + controler.getConfig().controller().setWriteEventsInterval(0); + controler.getConfig().controller().setCreateGraphs(false); controler.addOverridingModule(new AbstractModule() { @Override public void install() { @@ -738,7 +738,7 @@ public Mobsim get() { } }); - controler.getConfig().controler().setDumpDataAtEnd(true); + controler.getConfig().controller().setDumpDataAtEnd(true); controler.run(); assertTrue(new File(controler.getControlerIO().getOutputFilename(Controler.DefaultFiles.population)).exists()); @@ -750,12 +750,12 @@ public Mobsim get() { @Test public void testSetDumpDataAtEnd_false() { final Config config = utils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("equil"), "config_plans1.xml")); - config.controler().setLastIteration(0); - config.controler().setWritePlansInterval(0); + config.controller().setLastIteration(0); + config.controller().setWritePlansInterval(0); final Controler controler = new Controler(config); - controler.getConfig().controler().setWriteEventsInterval(0); - controler.getConfig().controler().setCreateGraphs(false); + controler.getConfig().controller().setWriteEventsInterval(0); + controler.getConfig().controller().setCreateGraphs(false); controler.addOverridingModule(new AbstractModule() { @Override public void install() { @@ -768,7 +768,7 @@ public Mobsim get() { } }); - controler.getConfig().controler().setDumpDataAtEnd(false); + controler.getConfig().controller().setDumpDataAtEnd(false); controler.run(); @@ -778,7 +778,7 @@ public Mobsim get() { @Test(expected = RuntimeException.class) public void testShutdown_UncaughtException() { final Config config = utils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("equil"), "config_plans1.xml")); - config.controler().setLastIteration(1); + config.controller().setLastIteration(1); Controler controler = new Controler(config); controler.addOverridingModule(new AbstractModule() { @@ -787,17 +787,17 @@ public void install() { bindMobsim().to(CrashingMobsim.class); } }); - controler.getConfig().controler().setCreateGraphs(false); - controler.getConfig().controler().setDumpDataAtEnd(false); + controler.getConfig().controller().setCreateGraphs(false); + controler.getConfig().controller().setDumpDataAtEnd(false); controler.run(); } @Test public void test_ExceptionOnMissingPopulationFile() { final Config config = utils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("equil"), "config_plans1.xml")); - config.controler().setLastIteration(0); - config.controler().setWriteEventsInterval(0); - config.controler().setWritePlansInterval(0); + config.controller().setLastIteration(0); + config.controller().setWriteEventsInterval(0); + config.controller().setWritePlansInterval(0); config.plans().setInputFile("dummy/non-existing/population.xml"); try { @@ -813,8 +813,8 @@ public Mobsim get() { }); } }); - controler.getConfig().controler().setCreateGraphs(false); - controler.getConfig().controler().setDumpDataAtEnd(false); + controler.getConfig().controller().setCreateGraphs(false); + controler.getConfig().controller().setDumpDataAtEnd(false); controler.run(); Assert.fail("expected exception, got none."); @@ -831,9 +831,9 @@ public Mobsim get() { public void test_ExceptionOnMissingNetworkFile() { try { final Config config = utils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("equil"), "config_plans1.xml")); - config.controler().setLastIteration(0); - config.controler().setWriteEventsInterval(0); - config.controler().setWritePlansInterval(0); + config.controller().setLastIteration(0); + config.controller().setWriteEventsInterval(0); + config.controller().setWritePlansInterval(0); config.network().setInputFile("dummy/non-existing/network.xml"); final Controler controler = new Controler(config); @@ -848,8 +848,8 @@ public Mobsim get() { }); } }); - controler.getConfig().controler().setCreateGraphs(false); - controler.getConfig().controler().setDumpDataAtEnd(false); + controler.getConfig().controller().setCreateGraphs(false); + controler.getConfig().controller().setDumpDataAtEnd(false); controler.run(); Assert.fail("expected exception, got none."); @@ -866,9 +866,9 @@ public Mobsim get() { public void test_ExceptionOnMissingFacilitiesFile() { try { final Config config = utils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("equil"), "config_plans1.xml")); - config.controler().setLastIteration(0); - config.controler().setWriteEventsInterval(0); - config.controler().setWritePlansInterval(0); + config.controller().setLastIteration(0); + config.controller().setWriteEventsInterval(0); + config.controller().setWritePlansInterval(0); config.facilities().setInputFile("dummy/non-existing/network.xml"); final Controler controler = new Controler(config); @@ -883,8 +883,8 @@ public Mobsim get() { }); } }); - controler.getConfig().controler().setCreateGraphs(false); - controler.getConfig().controler().setDumpDataAtEnd(false); + controler.getConfig().controller().setCreateGraphs(false); + controler.getConfig().controller().setDumpDataAtEnd(false); controler.run(); Assert.fail("expected exception, got none."); @@ -900,15 +900,15 @@ public Mobsim get() { @Test public void testOneSnapshotWriterInConfig() { final Config config = utils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("equil"), "config_plans1.xml")); - config.controler().setLastIteration(0); - config.controler().setWriteEventsInterval(0); - config.controler().setWritePlansInterval(0); + config.controller().setLastIteration(0); + config.controller().setWriteEventsInterval(0); + config.controller().setWritePlansInterval(0); config.qsim().setSnapshotPeriod(10); config.qsim().setSnapshotStyle(SnapshotStyle.equiDist) ;; final Controler controler = new Controler(config); - controler.getConfig().controler().setCreateGraphs(false); - controler.getConfig().controler().setDumpDataAtEnd(false); + controler.getConfig().controller().setCreateGraphs(false); + controler.getConfig().controller().setDumpDataAtEnd(false); controler.run(); assertTrue(new File(controler.getControlerIO().getIterationFilename(0, "T.veh.gz")).exists()); @@ -917,18 +917,18 @@ public void testOneSnapshotWriterInConfig() { @Test public void testTransimsSnapshotWriterOnQSim() { final Config config = utils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("equil"), "config_plans1.xml")); - config.controler().setLastIteration(2); - config.controler().setWriteEventsInterval(0); - config.controler().setWritePlansInterval(0); - config.controler().setMobsim("qsim"); - config.controler().setSnapshotFormat( Collections.singletonList( SnapshotFormat.transims ) ); - config.controler().setOutputDirectory( utils.getOutputDirectory() ); + config.controller().setLastIteration(2); + config.controller().setWriteEventsInterval(0); + config.controller().setWritePlansInterval(0); + config.controller().setMobsim("qsim"); + config.controller().setSnapshotFormat( Collections.singletonList( SnapshotFormat.transims ) ); + config.controller().setOutputDirectory( utils.getOutputDirectory() ); config.qsim().setSnapshotPeriod(600); config.qsim().setSnapshotStyle( SnapshotStyle.equiDist ) ;; final Controler controler = new Controler(config); - controler.getConfig().controler().setCreateGraphs(false); - controler.getConfig().controler().setDumpDataAtEnd(false); + controler.getConfig().controller().setCreateGraphs(false); + controler.getConfig().controller().setDumpDataAtEnd(false); controler.run(); assertTrue(new File(controler.getControlerIO().getIterationFilename(0, "T.veh.gz")).exists()); @@ -947,7 +947,7 @@ public void testTransimsSnapshotWriterOnQSim() { @Test( expected = RuntimeException.class ) public void testGuiceModulesCannotAddModules() { final Config config = utils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("equil"), "config_plans1.xml")); - config.controler().setLastIteration( 0 ); + config.controller().setLastIteration( 0 ); final Controler controler = new Controler( config ); final Scenario replacementScenario = ScenarioUtils.createScenario( config ); diff --git a/matsim/src/test/java/org/matsim/core/controler/ControlerMobsimIntegrationTest.java b/matsim/src/test/java/org/matsim/core/controler/ControlerMobsimIntegrationTest.java index 56a843a749b..a66fc10c46c 100644 --- a/matsim/src/test/java/org/matsim/core/controler/ControlerMobsimIntegrationTest.java +++ b/matsim/src/test/java/org/matsim/core/controler/ControlerMobsimIntegrationTest.java @@ -45,15 +45,15 @@ public class ControlerMobsimIntegrationTest { @Test public void testRunMobsim_customMobsim() { Config cfg = this.utils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("equil"), "config_plans1.xml")); - cfg.controler().setLastIteration(0); - cfg.controler().setMobsim("counting"); - cfg.controler().setWritePlansInterval(0); + cfg.controller().setLastIteration(0); + cfg.controller().setMobsim("counting"); + cfg.controller().setWritePlansInterval(0); final Controler c = new Controler(cfg); final CountingMobsimFactory mf = new CountingMobsimFactory(); c.addOverridingModule(new AbstractModule() { @Override public void install() { - if (getConfig().controler().getMobsim().equals("counting")) { + if (getConfig().controller().getMobsim().equals("counting")) { bind(Mobsim.class).toProvider(new Provider() { @Override public Mobsim get() { @@ -63,9 +63,9 @@ public Mobsim get() { } } }); - c.getConfig().controler().setCreateGraphs(false); - c.getConfig().controler().setDumpDataAtEnd(false); - c.getConfig().controler().setWriteEventsInterval(0); + c.getConfig().controller().setCreateGraphs(false); + c.getConfig().controller().setDumpDataAtEnd(false); + c.getConfig().controller().setWriteEventsInterval(0); c.run(); Assert.assertEquals(1, mf.callCount); } @@ -73,13 +73,13 @@ public Mobsim get() { @Test(expected = RuntimeException.class) public void testRunMobsim_missingMobsimFactory() { Config cfg = this.utils.loadConfig("test/scenarios/equil/config_plans1.xml"); - cfg.controler().setLastIteration(0); - cfg.controler().setMobsim("counting"); - cfg.controler().setWritePlansInterval(0); + cfg.controller().setLastIteration(0); + cfg.controller().setMobsim("counting"); + cfg.controller().setWritePlansInterval(0); Controler c = new Controler(cfg); - c.getConfig().controler().setCreateGraphs(false); - c.getConfig().controler().setDumpDataAtEnd(false); - c.getConfig().controler().setWriteEventsInterval(0); + c.getConfig().controller().setCreateGraphs(false); + c.getConfig().controller().setDumpDataAtEnd(false); + c.getConfig().controller().setWriteEventsInterval(0); c.run(); } diff --git a/matsim/src/test/java/org/matsim/core/controler/MatsimServicesImplTest.java b/matsim/src/test/java/org/matsim/core/controler/MatsimServicesImplTest.java index 0712fa96c72..b4ad53a30d1 100644 --- a/matsim/src/test/java/org/matsim/core/controler/MatsimServicesImplTest.java +++ b/matsim/src/test/java/org/matsim/core/controler/MatsimServicesImplTest.java @@ -32,20 +32,20 @@ import org.matsim.testcases.MatsimTestUtils; public class MatsimServicesImplTest { - + @Rule public MatsimTestUtils utils = new MatsimTestUtils(); - + @Ignore @Test public void testIterationInServicesEqualsIterationInEvent() { - + Config config = ConfigUtils.createConfig(); - config.controler().setLastIteration(1); - config.controler().setOutputDirectory(utils.getOutputDirectory()); - + config.controller().setLastIteration(1); + config.controller().setOutputDirectory(utils.getOutputDirectory()); + Controler controler = new Controler( config ); - + controler.addOverridingModule(new AbstractModule() { @Override public void install() { @@ -54,15 +54,15 @@ public void install() { @Override public void notifyIterationStarts(IterationStartsEvent event) { Assert.assertSame(event.getIteration(), event.getServices().getIterationNumber()); - + } - + }); } }); - + controler.run(); - + } } diff --git a/matsim/src/test/java/org/matsim/core/controler/MobsimListenerTest.java b/matsim/src/test/java/org/matsim/core/controler/MobsimListenerTest.java index 29d47a29ff6..099e07ca091 100644 --- a/matsim/src/test/java/org/matsim/core/controler/MobsimListenerTest.java +++ b/matsim/src/test/java/org/matsim/core/controler/MobsimListenerTest.java @@ -39,8 +39,8 @@ public class MobsimListenerTest { @Test public void testRunMobsim_listenerTransient() { Config cfg = this.utils.loadConfig("test/scenarios/equil/config_plans1.xml"); - cfg.controler().setLastIteration(1); - cfg.controler().setWritePlansInterval(0); + cfg.controller().setLastIteration(1); + cfg.controller().setWritePlansInterval(0); final Controler c = new Controler(cfg); c.addOverridingModule(new AbstractModule() { @Override @@ -48,17 +48,17 @@ public void install() { addMobsimListenerBinding().to(CountingMobsimListener.class); } }); - c.getConfig().controler().setCreateGraphs(false); - c.getConfig().controler().setDumpDataAtEnd(false); - c.getConfig().controler().setWriteEventsInterval(0); + c.getConfig().controller().setCreateGraphs(false); + c.getConfig().controller().setDumpDataAtEnd(false); + c.getConfig().controller().setWriteEventsInterval(0); c.run(); } @Test(expected = RuntimeException.class) public void testRunMobsim_listenerSingleton() { Config cfg = this.utils.loadConfig("test/scenarios/equil/config_plans1.xml"); - cfg.controler().setLastIteration(1); - cfg.controler().setWritePlansInterval(0); + cfg.controller().setLastIteration(1); + cfg.controller().setWritePlansInterval(0); final Controler c = new Controler(cfg); c.addOverridingModule(new AbstractModule() { @Override @@ -66,9 +66,9 @@ public void install() { addMobsimListenerBinding().to(SingletonCountingMobsimListener.class); } }); - c.getConfig().controler().setCreateGraphs(false); - c.getConfig().controler().setDumpDataAtEnd(false); - c.getConfig().controler().setWriteEventsInterval(0); + c.getConfig().controller().setCreateGraphs(false); + c.getConfig().controller().setDumpDataAtEnd(false); + c.getConfig().controller().setWriteEventsInterval(0); c.run(); } diff --git a/matsim/src/test/java/org/matsim/core/controler/NewControlerTest.java b/matsim/src/test/java/org/matsim/core/controler/NewControlerTest.java index e292987d787..cbb1eabbe43 100644 --- a/matsim/src/test/java/org/matsim/core/controler/NewControlerTest.java +++ b/matsim/src/test/java/org/matsim/core/controler/NewControlerTest.java @@ -46,8 +46,8 @@ public void testInjectionBeforeControler() { // facility file is provided in config and facilitySource is 'fromFile', the facilitySource must be changed. Amit Jan'18 config.facilities().setFacilitiesSource(FacilitiesConfigGroup.FacilitiesSource.none); - config.controler().setLastIteration(1); - config.controler().setOutputDirectory(testUtils.getOutputDirectory()); + config.controller().setLastIteration(1); + config.controller().setOutputDirectory(testUtils.getOutputDirectory()); final Scenario scenario = ScenarioUtils.createScenario(config); com.google.inject.Injector injector = Injector.createInjector(config, new AbstractModule() { @Override diff --git a/matsim/src/test/java/org/matsim/core/controler/OverrideCarTraveltimeTest.java b/matsim/src/test/java/org/matsim/core/controler/OverrideCarTraveltimeTest.java index fb2d4ec1475..ff00e8c4fac 100644 --- a/matsim/src/test/java/org/matsim/core/controler/OverrideCarTraveltimeTest.java +++ b/matsim/src/test/java/org/matsim/core/controler/OverrideCarTraveltimeTest.java @@ -22,7 +22,6 @@ package org.matsim.core.controler; -import com.google.inject.Provider; import org.junit.Assert; import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; @@ -31,7 +30,6 @@ import org.matsim.core.config.ConfigUtils; import org.matsim.core.controler.events.ReplanningEvent; import org.matsim.core.controler.listener.ReplanningListener; -import org.matsim.core.replanning.ReplanningContext; import org.matsim.core.router.costcalculators.TravelDisutilityFactory; import org.matsim.core.router.util.TravelDisutility; import org.matsim.core.router.util.TravelTime; @@ -45,8 +43,8 @@ public class OverrideCarTraveltimeTest { public static void main(String[] args) { final Config config = ConfigUtils.createConfig(); - config.controler().setLastIteration(1); - config.controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles); + config.controller().setLastIteration(1); + config.controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles); Controler controler = new Controler(ScenarioUtils.createScenario(config)); controler.addOverridingModule(new AbstractModule() { @Override diff --git a/matsim/src/test/java/org/matsim/core/controler/PrepareForSimImplTest.java b/matsim/src/test/java/org/matsim/core/controler/PrepareForSimImplTest.java index e841aac308e..b01bd15d4b7 100644 --- a/matsim/src/test/java/org/matsim/core/controler/PrepareForSimImplTest.java +++ b/matsim/src/test/java/org/matsim/core/controler/PrepareForSimImplTest.java @@ -53,19 +53,18 @@ import org.matsim.core.router.TripStructureUtils; import org.matsim.core.scenario.ScenarioUtils; import org.matsim.core.utils.timing.TimeInterpretation; -import org.matsim.facilities.Facility; import com.google.inject.Provider; /** * Mostly tests adaptation of old plans to routing mode and the related replacement of helper modes for access and egress * to pt/drt and the related replacement of fallback modes for pt/drt (if no route could be found). - * + * * Does not test the combination of already a routing mode and outdated helper / fallback modes, because those never existed * in the code at the same time. - * + * * TODO: add tests for other methods of {@link PrepareForSimImpl}. - * + * * @author vsp-gleich */ public class PrepareForSimImplTest { @@ -73,7 +72,7 @@ public class PrepareForSimImplTest { @Test public void testSingleLegTripRoutingMode() { Config config = ConfigUtils.createConfig(); - config.controler().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); + config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); Scenario scenario = ScenarioUtils.createScenario(config); createAndAddNetwork(scenario); Population pop = scenario.getPopulation(); @@ -95,16 +94,16 @@ public void testSingleLegTripRoutingMode() { person.addPlan(plan); pop.addPerson(person); - final PrepareForSimImpl prepareForSimImpl = new PrepareForSimImpl(config.global(), scenario, scenario.getNetwork(), - pop, scenario.getActivityFacilities(), new DummyTripRouterProvider(), config.qsim(), config.facilities(), + final PrepareForSimImpl prepareForSimImpl = new PrepareForSimImpl(config.global(), scenario, scenario.getNetwork(), + pop, scenario.getActivityFacilities(), new DummyTripRouterProvider(), config.qsim(), config.facilities(), config.plans(), new MainModeIdentifierImpl(), TimeInterpretation.create(config)); - + prepareForSimImpl.run(); Assert.assertEquals("wrong routing mode!", TransportMode.pt, TripStructureUtils.getRoutingMode(leg)); } - + // test routing mode set, such as after TripsToLegsAlgorithm + replanning strategy { PopulationFactory pf = pop.getFactory(); @@ -122,21 +121,21 @@ public void testSingleLegTripRoutingMode() { person.addPlan(plan); pop.addPerson(person); - final PrepareForSimImpl prepareForSimImpl = new PrepareForSimImpl(config.global(), scenario, scenario.getNetwork(), - pop, scenario.getActivityFacilities(), new DummyTripRouterProvider(), config.qsim(), config.facilities(), + final PrepareForSimImpl prepareForSimImpl = new PrepareForSimImpl(config.global(), scenario, scenario.getNetwork(), + pop, scenario.getActivityFacilities(), new DummyTripRouterProvider(), config.qsim(), config.facilities(), config.plans(), new MainModeIdentifierImpl(), TimeInterpretation.create(config)); - + prepareForSimImpl.run(); Assert.assertEquals("wrong routing mode!", TransportMode.pt, TripStructureUtils.getRoutingMode(leg)); } } - + @Test public void testSingleFallbackModeLegTrip() { Config config = ConfigUtils.createConfig(); - config.controler().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); + config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); Scenario scenario = ScenarioUtils.createScenario(config); createAndAddNetwork(scenario); Population pop = scenario.getPopulation(); @@ -158,17 +157,17 @@ public void testSingleFallbackModeLegTrip() { person.addPlan(plan); pop.addPerson(person); - final PrepareForSimImpl prepareForSimImpl = new PrepareForSimImpl(config.global(), scenario, scenario.getNetwork(), - pop, scenario.getActivityFacilities(), new DummyTripRouterProvider(), config.qsim(), config.facilities(), + final PrepareForSimImpl prepareForSimImpl = new PrepareForSimImpl(config.global(), scenario, scenario.getNetwork(), + pop, scenario.getActivityFacilities(), new DummyTripRouterProvider(), config.qsim(), config.facilities(), config.plans(), new MainModeIdentifierImpl(), TimeInterpretation.create(config)); - + prepareForSimImpl.run(); Assert.assertEquals("wrong leg mode replacement!", TransportMode.walk, leg.getMode()); Assert.assertEquals("wrong routing mode!", TransportMode.pt, TripStructureUtils.getRoutingMode(leg)); } - + // test outdated fallback mode single leg trip (arbitrary drt mode) { PopulationFactory pf = pop.getFactory(); @@ -186,10 +185,10 @@ public void testSingleFallbackModeLegTrip() { person.addPlan(plan); pop.addPerson(person); - final PrepareForSimImpl prepareForSimImpl = new PrepareForSimImpl(config.global(), scenario, scenario.getNetwork(), - pop, scenario.getActivityFacilities(), new DummyTripRouterProvider(), config.qsim(), config.facilities(), + final PrepareForSimImpl prepareForSimImpl = new PrepareForSimImpl(config.global(), scenario, scenario.getNetwork(), + pop, scenario.getActivityFacilities(), new DummyTripRouterProvider(), config.qsim(), config.facilities(), config.plans(), new MainModeIdentifierImpl(), TimeInterpretation.create(config)); - + prepareForSimImpl.run(); Assert.assertEquals("wrong leg mode replacement", TransportMode.walk, leg.getMode()); @@ -197,15 +196,15 @@ public void testSingleFallbackModeLegTrip() { TripStructureUtils.getRoutingMode(leg)); } } - + @Test public void testCorrectTripsRemainUnchanged() { Config config = ConfigUtils.createConfig(); - config.controler().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); + config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); Scenario scenario = ScenarioUtils.createScenario(config); createAndAddNetwork(scenario); Population pop = scenario.getPopulation(); - + // test car trip with access/egress walk legs { PopulationFactory pf = pop.getFactory(); @@ -233,24 +232,24 @@ public void testCorrectTripsRemainUnchanged() { plan.addActivity(activity4); person.addPlan(plan); pop.addPerson(person); - - final PrepareForSimImpl prepareForSimImpl = new PrepareForSimImpl(config.global(), scenario, scenario.getNetwork(), - pop, scenario.getActivityFacilities(), new DummyTripRouterProvider(), config.qsim(), config.facilities(), + + final PrepareForSimImpl prepareForSimImpl = new PrepareForSimImpl(config.global(), scenario, scenario.getNetwork(), + pop, scenario.getActivityFacilities(), new DummyTripRouterProvider(), config.qsim(), config.facilities(), config.plans(), new MainModeIdentifierImpl(), TimeInterpretation.create(config)); - + prepareForSimImpl.run(); - + // Check leg modes remain unchanged Assert.assertEquals("wrong leg mode!", TransportMode.walk, leg1.getMode()); Assert.assertEquals("wrong routing mode!", TransportMode.car, leg2.getMode()); Assert.assertEquals("wrong leg mode!", TransportMode.walk, leg3.getMode()); - + // Check routing mode: Assert.assertEquals("wrong routing mode!", TransportMode.car, TripStructureUtils.getRoutingMode(leg1)); Assert.assertEquals("wrong routing mode!", TransportMode.car, TripStructureUtils.getRoutingMode(leg2)); Assert.assertEquals("wrong routing mode!", TransportMode.car, TripStructureUtils.getRoutingMode(leg3)); } - + // test complicated intermodal trip with consistent routing modes passes unchanged { PopulationFactory pf = pop.getFactory(); @@ -326,15 +325,15 @@ public void testCorrectTripsRemainUnchanged() { plan.addActivity(activity12); person.addPlan(plan); pop.addPerson(person); - - final PrepareForSimImpl prepareForSimImpl = new PrepareForSimImpl(config.global(), scenario, scenario.getNetwork(), - pop, scenario.getActivityFacilities(), new DummyTripRouterProvider(), config.qsim(), config.facilities(), + + final PrepareForSimImpl prepareForSimImpl = new PrepareForSimImpl(config.global(), scenario, scenario.getNetwork(), + pop, scenario.getActivityFacilities(), new DummyTripRouterProvider(), config.qsim(), config.facilities(), config.plans(), new MainModeIdentifierImpl(), TimeInterpretation.create(config)); - + prepareForSimImpl.run(); - + // Check leg modes remain unchanged - + // TODO: Currently all TransportMode.non_network_walk legs are replaced by TransportMode.walk, so we cannot check // the correct handling of them right now. // Assert.assertEquals("wrong routing mode!", TransportMode.non_network_walk, leg1.getMode()); @@ -348,7 +347,7 @@ public void testCorrectTripsRemainUnchanged() { // Assert.assertEquals("wrong routing mode!", TransportMode.non_network_walk, leg9.getMode()); Assert.assertEquals("wrong leg mode!", TransportMode.walk, leg10.getMode()); // Assert.assertEquals("wrong routing mode!", TransportMode.non_network_walk, leg11.getMode()); - + // Check routing mode remains unchanged Assert.assertEquals("wrong routing mode!", "intermodal pt", TripStructureUtils.getRoutingMode(leg1)); Assert.assertEquals("wrong routing mode!", "intermodal pt", TripStructureUtils.getRoutingMode(leg2)); @@ -363,15 +362,15 @@ public void testCorrectTripsRemainUnchanged() { Assert.assertEquals("wrong routing mode!", "intermodal pt", TripStructureUtils.getRoutingMode(leg11)); } } - + @Test public void testRoutingModeConsistency() { Config config = ConfigUtils.createConfig(); - config.controler().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); + config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); Scenario scenario = ScenarioUtils.createScenario(config); createAndAddNetwork(scenario); Population pop = scenario.getPopulation(); - + // test trip with inconsistent routing modes causes exception { PopulationFactory pf = pop.getFactory(); @@ -398,17 +397,17 @@ public void testRoutingModeConsistency() { plan.addActivity(activity4); person.addPlan(plan); pop.addPerson(person); - + try { - final PrepareForSimImpl prepareForSimImpl = new PrepareForSimImpl(config.global(), scenario, scenario.getNetwork(), - pop, scenario.getActivityFacilities(), new DummyTripRouterProvider(), config.qsim(), config.facilities(), + final PrepareForSimImpl prepareForSimImpl = new PrepareForSimImpl(config.global(), scenario, scenario.getNetwork(), + pop, scenario.getActivityFacilities(), new DummyTripRouterProvider(), config.qsim(), config.facilities(), config.plans(), new MainModeIdentifierImpl(), TimeInterpretation.create(config)); - + prepareForSimImpl.run(); Assert.fail("expected Exception, got none."); } catch (RuntimeException expected) {} } - + // test trip with legs with and others without routing modes causes exception { PopulationFactory pf = pop.getFactory(); @@ -435,27 +434,27 @@ public void testRoutingModeConsistency() { plan.addActivity(activity4); person.addPlan(plan); pop.addPerson(person); - + try { - final PrepareForSimImpl prepareForSimImpl = new PrepareForSimImpl(config.global(), scenario, scenario.getNetwork(), - pop, scenario.getActivityFacilities(), new DummyTripRouterProvider(), config.qsim(), config.facilities(), + final PrepareForSimImpl prepareForSimImpl = new PrepareForSimImpl(config.global(), scenario, scenario.getNetwork(), + pop, scenario.getActivityFacilities(), new DummyTripRouterProvider(), config.qsim(), config.facilities(), config.plans(), new MainModeIdentifierImpl(), TimeInterpretation.create(config)); - + prepareForSimImpl.run(); Assert.fail("expected Exception, got none."); } catch (RuntimeException expected) {} } } - + @Test public void testOutdatedHelperModesReplacement() { Config config = ConfigUtils.createConfig(); - config.controler().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); + config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); config.plans().setHandlingOfPlansWithoutRoutingMode(HandlingOfPlansWithoutRoutingMode.reject); Scenario scenario = ScenarioUtils.createScenario(config); createAndAddNetwork(scenario); Population pop = scenario.getPopulation(); - + // test car trip with outdated access/egress walk modes { PopulationFactory pf = pop.getFactory(); @@ -483,36 +482,36 @@ public void testOutdatedHelperModesReplacement() { plan.addActivity(activity4); person.addPlan(plan); pop.addPerson(person); - + // Should give an exception with default: config.plans().setHandlingOfPlansWithoutRoutingMode(HandlingOfPlansWithoutRoutingMode.reject); try { - final PrepareForSimImpl prepareForSimImpl = new PrepareForSimImpl(config.global(), scenario, scenario.getNetwork(), - pop, scenario.getActivityFacilities(), new DummyTripRouterProvider(), config.qsim(), config.facilities(), + final PrepareForSimImpl prepareForSimImpl = new PrepareForSimImpl(config.global(), scenario, scenario.getNetwork(), + pop, scenario.getActivityFacilities(), new DummyTripRouterProvider(), config.qsim(), config.facilities(), config.plans(), new MainModeIdentifierImpl(), TimeInterpretation.create(config)); - + prepareForSimImpl.run(); Assert.fail("expected Exception, got none."); } catch (RuntimeException expected) {} - + // Should work with config.plans().setHandlingOfPlansWithoutRoutingMode(HandlingOfPlansWithoutRoutingMode.useMainModeIdentifier); config.plans().setHandlingOfPlansWithoutRoutingMode(HandlingOfPlansWithoutRoutingMode.useMainModeIdentifier); - final PrepareForSimImpl prepareForSimImpl = new PrepareForSimImpl(config.global(), scenario, scenario.getNetwork(), - pop, scenario.getActivityFacilities(), new DummyTripRouterProvider(), config.qsim(), config.facilities(), + final PrepareForSimImpl prepareForSimImpl = new PrepareForSimImpl(config.global(), scenario, scenario.getNetwork(), + pop, scenario.getActivityFacilities(), new DummyTripRouterProvider(), config.qsim(), config.facilities(), config.plans(), new MainModeIdentifierImpl(), TimeInterpretation.create(config)); - + prepareForSimImpl.run(); - + // Check replacement of outdated helper modes. Assert.assertEquals("wrong leg mode!", TransportMode.walk, leg1.getMode()); Assert.assertEquals("wrong leg mode!", TransportMode.car, leg2.getMode()); Assert.assertEquals("wrong leg mode!", TransportMode.walk, leg3.getMode()); - + // Check routing mode: Assert.assertEquals("wrong routing mode!", TransportMode.car, TripStructureUtils.getRoutingMode(leg1)); Assert.assertEquals("wrong routing mode!", TransportMode.car, TripStructureUtils.getRoutingMode(leg2)); Assert.assertEquals("wrong routing mode!", TransportMode.car, TripStructureUtils.getRoutingMode(leg3)); } - + // test car trip with outdated access/egress walk modes { PopulationFactory pf = pop.getFactory(); @@ -540,37 +539,37 @@ public void testOutdatedHelperModesReplacement() { plan.addActivity(activity4); person.addPlan(plan); pop.addPerson(person); - + config.plans().setHandlingOfPlansWithoutRoutingMode(HandlingOfPlansWithoutRoutingMode.reject); // Should give an exception with default: config.plans().setHandlingOfPlansWithoutRoutingMode(HandlingOfPlansWithoutRoutingMode.reject); try { - final PrepareForSimImpl prepareForSimImpl = new PrepareForSimImpl(config.global(), scenario, scenario.getNetwork(), - pop, scenario.getActivityFacilities(), new DummyTripRouterProvider(), config.qsim(), config.facilities(), + final PrepareForSimImpl prepareForSimImpl = new PrepareForSimImpl(config.global(), scenario, scenario.getNetwork(), + pop, scenario.getActivityFacilities(), new DummyTripRouterProvider(), config.qsim(), config.facilities(), config.plans(), new MainModeIdentifierImpl(), TimeInterpretation.create(config)); - + prepareForSimImpl.run(); Assert.fail("expected Exception, got none."); } catch (RuntimeException expected) {} - + // Should work with config.plans().setHandlingOfPlansWithoutRoutingMode(HandlingOfPlansWithoutRoutingMode.useMainModeIdentifier); config.plans().setHandlingOfPlansWithoutRoutingMode(HandlingOfPlansWithoutRoutingMode.useMainModeIdentifier); - final PrepareForSimImpl prepareForSimImpl = new PrepareForSimImpl(config.global(), scenario, scenario.getNetwork(), - pop, scenario.getActivityFacilities(), new DummyTripRouterProvider(), config.qsim(), config.facilities(), + final PrepareForSimImpl prepareForSimImpl = new PrepareForSimImpl(config.global(), scenario, scenario.getNetwork(), + pop, scenario.getActivityFacilities(), new DummyTripRouterProvider(), config.qsim(), config.facilities(), config.plans(), new MainModeIdentifierImpl(), TimeInterpretation.create(config)); - + prepareForSimImpl.run(); - + // Check replacement of outdated helper modes. Assert.assertEquals("wrong leg mode replacement!", TransportMode.walk, leg1.getMode()); Assert.assertEquals("wrong leg mode!", TransportMode.car, leg2.getMode()); Assert.assertEquals("wrong leg mode replacement!", TransportMode.walk, leg3.getMode()); - + // Check routing mode: Assert.assertEquals("wrong routing mode!", TransportMode.car, TripStructureUtils.getRoutingMode(leg1)); Assert.assertEquals("wrong routing mode!", TransportMode.car, TripStructureUtils.getRoutingMode(leg2)); Assert.assertEquals("wrong routing mode!", TransportMode.car, TripStructureUtils.getRoutingMode(leg3)); } - + // test complicated intermodal drt+pt trip with outdated access/egress walk modes { PopulationFactory pf = pop.getFactory(); @@ -622,26 +621,26 @@ public void testOutdatedHelperModesReplacement() { plan.addActivity(activity8); person.addPlan(plan); pop.addPerson(person); - + config.plans().setHandlingOfPlansWithoutRoutingMode(HandlingOfPlansWithoutRoutingMode.reject); // Should give an exception with default: config.plans().setHandlingOfPlansWithoutRoutingMode(HandlingOfPlansWithoutRoutingMode.reject); try { - final PrepareForSimImpl prepareForSimImpl = new PrepareForSimImpl(config.global(), scenario, scenario.getNetwork(), - pop, scenario.getActivityFacilities(), new DummyTripRouterProvider(), config.qsim(), config.facilities(), + final PrepareForSimImpl prepareForSimImpl = new PrepareForSimImpl(config.global(), scenario, scenario.getNetwork(), + pop, scenario.getActivityFacilities(), new DummyTripRouterProvider(), config.qsim(), config.facilities(), config.plans(), new MainModeIdentifierImpl(), TimeInterpretation.create(config)); - + prepareForSimImpl.run(); Assert.fail("expected Exception, got none."); } catch (RuntimeException expected) {} - + // Should work with config.plans().setHandlingOfPlansWithoutRoutingMode(HandlingOfPlansWithoutRoutingMode.useMainModeIdentifier); config.plans().setHandlingOfPlansWithoutRoutingMode(HandlingOfPlansWithoutRoutingMode.useMainModeIdentifier); - final PrepareForSimImpl prepareForSimImpl = new PrepareForSimImpl(config.global(), scenario, scenario.getNetwork(), - pop, scenario.getActivityFacilities(), new DummyTripRouterProvider(), config.qsim(), config.facilities(), + final PrepareForSimImpl prepareForSimImpl = new PrepareForSimImpl(config.global(), scenario, scenario.getNetwork(), + pop, scenario.getActivityFacilities(), new DummyTripRouterProvider(), config.qsim(), config.facilities(), config.plans(), new MainModeIdentifierImpl(), TimeInterpretation.create(config)); - + prepareForSimImpl.run(); - + // Check replacement of outdated helper modes. Assert.assertEquals("wrong leg mode replacement!", TransportMode.walk, leg1.getMode()); Assert.assertEquals("wrong leg mode!", TransportMode.drt, leg2.getMode()); @@ -650,15 +649,15 @@ public void testOutdatedHelperModesReplacement() { Assert.assertEquals("wrong leg mode replacement!", TransportMode.walk, leg5.getMode()); Assert.assertEquals("wrong leg mode!", TransportMode.pt, leg6.getMode()); Assert.assertEquals("wrong leg mode replacement!", TransportMode.walk, leg7.getMode()); - + /* * Check routing mode: * TransportMode.drt is what the default MainModeIdentifierImpl returns. To handle intermodal trips "right" * in the old setup, we would probably have to overwrite the MainModeIdentifier with a custom * MainModeIdentifier able to understand intermodal trips. - * + * * For the scope of this test it is sufficient, that the MainModeIdentifier is run, returns a main mode - * and that this main mode is assigned as routingMode to all legs. + * and that this main mode is assigned as routingMode to all legs. */ Assert.assertEquals("wrong routing mode!", TransportMode.drt, TripStructureUtils.getRoutingMode(leg1)); Assert.assertEquals("wrong routing mode!", TransportMode.drt, TripStructureUtils.getRoutingMode(leg2)); @@ -669,16 +668,16 @@ public void testOutdatedHelperModesReplacement() { Assert.assertEquals("wrong routing mode!", TransportMode.drt, TripStructureUtils.getRoutingMode(leg7)); } } - + @Test public void testOutdatedFallbackAndHelperModesReplacement() { Config config = ConfigUtils.createConfig(); - config.controler().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); + config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); config.plans().setHandlingOfPlansWithoutRoutingMode(HandlingOfPlansWithoutRoutingMode.reject); Scenario scenario = ScenarioUtils.createScenario(config); createAndAddNetwork(scenario); Population pop = scenario.getPopulation(); - + // test complicated intermodal trip with consistent routing modes passes unchanged { PopulationFactory pf = pop.getFactory(); @@ -718,40 +717,40 @@ public void testOutdatedFallbackAndHelperModesReplacement() { plan.addActivity(activity6); person.addPlan(plan); pop.addPerson(person); - + // Should give an exception with default: config.plans().setHandlingOfPlansWithoutRoutingMode(HandlingOfPlansWithoutRoutingMode.reject); try { - final PrepareForSimImpl prepareForSimImpl = new PrepareForSimImpl(config.global(), scenario, scenario.getNetwork(), - pop, scenario.getActivityFacilities(), new DummyTripRouterProvider(), config.qsim(), config.facilities(), + final PrepareForSimImpl prepareForSimImpl = new PrepareForSimImpl(config.global(), scenario, scenario.getNetwork(), + pop, scenario.getActivityFacilities(), new DummyTripRouterProvider(), config.qsim(), config.facilities(), config.plans(), new MainModeIdentifierImpl(), TimeInterpretation.create(config)); - + prepareForSimImpl.run(); Assert.fail("expected Exception, got none."); } catch (RuntimeException expected) {} - + // Should work with config.plans().setHandlingOfPlansWithoutRoutingMode(HandlingOfPlansWithoutRoutingMode.useMainModeIdentifier); config.plans().setHandlingOfPlansWithoutRoutingMode(HandlingOfPlansWithoutRoutingMode.useMainModeIdentifier); - final PrepareForSimImpl prepareForSimImpl = new PrepareForSimImpl(config.global(), scenario, scenario.getNetwork(), - pop, scenario.getActivityFacilities(), new DummyTripRouterProvider(), config.qsim(), config.facilities(), + final PrepareForSimImpl prepareForSimImpl = new PrepareForSimImpl(config.global(), scenario, scenario.getNetwork(), + pop, scenario.getActivityFacilities(), new DummyTripRouterProvider(), config.qsim(), config.facilities(), config.plans(), new MainModeIdentifierImpl(), TimeInterpretation.create(config)); - + prepareForSimImpl.run(); - + // Check replacement of outdated helper modes. Assert.assertEquals("wrong leg mode replacement!", TransportMode.walk, leg1.getMode()); Assert.assertEquals("wrong leg mode!", TransportMode.drt, leg2.getMode()); Assert.assertEquals("wrong leg mode replacement!", TransportMode.walk, leg3.getMode()); Assert.assertEquals("wrong leg mode replacement!", TransportMode.walk, leg4.getMode()); Assert.assertEquals("wrong leg mode replacement!", TransportMode.walk, leg5.getMode()); - + /* * Check routing mode: * TransportMode.drt is what the default MainModeIdentifierImpl returns. To handle intermodal trips "right" * in the old setup, we would probably have to overwrite the MainModeIdentifier with a custom * MainModeIdentifier able to understand intermodal trips. - * + * * For the scope of thios test it is sufficient, that the MainModeIdentifier is run, returns a main mode - * and that this main mode is assigned as routingMode to all legs. + * and that this main mode is assigned as routingMode to all legs. */ Assert.assertEquals("wrong routing mode!", TransportMode.drt, TripStructureUtils.getRoutingMode(leg1)); Assert.assertEquals("wrong routing mode!", TransportMode.drt, TripStructureUtils.getRoutingMode(leg2)); @@ -760,7 +759,7 @@ public void testOutdatedFallbackAndHelperModesReplacement() { Assert.assertEquals("wrong routing mode!", TransportMode.drt, TripStructureUtils.getRoutingMode(leg5)); } } - + private class DummyTripRouterProvider implements Provider { @Override public TripRouter get() { @@ -774,7 +773,7 @@ public TripRouter get() { .build(); } } - + private class DummyRoutingModule implements RoutingModule { @Override public List calcRoute(RoutingRequest request) { diff --git a/matsim/src/test/java/org/matsim/core/controler/TerminationTest.java b/matsim/src/test/java/org/matsim/core/controler/TerminationTest.java index f15544055a8..65de1dea5b9 100644 --- a/matsim/src/test/java/org/matsim/core/controler/TerminationTest.java +++ b/matsim/src/test/java/org/matsim/core/controler/TerminationTest.java @@ -81,11 +81,11 @@ public void testSimulationEndDeleteIters() { private Controler prepareExperiment(int interval, int criterion, ControllerConfigGroup.CleanIterations iters) { Config config = utils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("equil"), "config.xml")); - config.controler().setOutputDirectory(utils.getOutputDirectory()); - config.controler().setCleanItersAtEnd(iters); + config.controller().setOutputDirectory(utils.getOutputDirectory()); + config.controller().setCleanItersAtEnd(iters); - config.controler().setWriteEventsInterval(interval); - config.controler().setLastIteration(criterion); + config.controller().setWriteEventsInterval(interval); + config.controller().setLastIteration(criterion); return new Controler(config); } @@ -132,8 +132,8 @@ public void testCustomConverenceCriterion() { */ Config config = utils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("equil"), "config.xml")); - config.controler().setOutputDirectory(utils.getOutputDirectory()); - config.controler().setCleanItersAtEnd(ControllerConfigGroup.CleanIterations.keep); + config.controller().setOutputDirectory(utils.getOutputDirectory()); + config.controller().setCleanItersAtEnd(ControllerConfigGroup.CleanIterations.keep); { // Set up mode choice config.changeMode().setModes(new String[] { "car", "walk" }); @@ -141,7 +141,7 @@ public void testCustomConverenceCriterion() { StrategySettings modeStrategy = new StrategySettings(); modeStrategy.setStrategyName(DefaultStrategy.ChangeTripMode); modeStrategy.setWeight(0.1); - config.strategy().addStrategySettings(modeStrategy); + config.replanning().addStrategySettings(modeStrategy); } Scenario scenario = ScenarioUtils.loadScenario(config); diff --git a/matsim/src/test/java/org/matsim/core/controler/TransitControlerIntegrationTest.java b/matsim/src/test/java/org/matsim/core/controler/TransitControlerIntegrationTest.java index 2e800250e8a..3d2999caa20 100644 --- a/matsim/src/test/java/org/matsim/core/controler/TransitControlerIntegrationTest.java +++ b/matsim/src/test/java/org/matsim/core/controler/TransitControlerIntegrationTest.java @@ -137,25 +137,25 @@ public class TransitControlerIntegrationTest { population.addPerson(person1); // prepare config - config.controler().setFirstIteration(0); - config.controler().setLastIteration(1); + config.controller().setFirstIteration(0); + config.controller().setLastIteration(1); ActivityParams params = new ActivityParams("h"); params.setTypicalDuration(16.0*3600); - config.planCalcScore().addActivityParams(params); + config.scoring().addActivityParams(params); params = new ActivityParams("w"); params.setTypicalDuration(8.0*3600); - config.planCalcScore().addActivityParams(params); + config.scoring().addActivityParams(params); StrategySettings tam = new StrategySettings(Id.create(1, StrategySettings.class)); tam.setStrategyName("TimeAllocationMutator"); tam.setWeight(1.0); - config.strategy().addStrategySettings(tam); + config.replanning().addStrategySettings(tam); // run Controler controler = new Controler(scenario); - controler.getConfig().controler().setWriteEventsInterval(0); - controler.getConfig().controler().setCreateGraphs(false); + controler.getConfig().controller().setWriteEventsInterval(0); + controler.getConfig().controller().setCreateGraphs(false); controler.run(); // checks diff --git a/matsim/src/test/java/org/matsim/core/controler/corelisteners/ListenersInjectionTest.java b/matsim/src/test/java/org/matsim/core/controler/corelisteners/ListenersInjectionTest.java index 29b92632a2b..ca53da64631 100644 --- a/matsim/src/test/java/org/matsim/core/controler/corelisteners/ListenersInjectionTest.java +++ b/matsim/src/test/java/org/matsim/core/controler/corelisteners/ListenersInjectionTest.java @@ -73,7 +73,7 @@ public void testPlansScoringIsSingleton() { private void testIsSingleton( final Class klass ) { final Config config = ConfigUtils.createConfig(); final String outputDir = utils.getOutputDirectory(); - config.controler().setOutputDirectory( outputDir ); + config.controller().setOutputDirectory( outputDir ); final com.google.inject.Injector injector = Injector.createInjector( config, @@ -86,7 +86,7 @@ public void install() { bind(ControlerListenerManager.class).to(ControlerListenerManagerImpl.class); bind(OutputDirectoryHierarchy.class).toInstance(new OutputDirectoryHierarchy(outputDir, OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists, - config.controler().getCompressionType())); + config.controller().getCompressionType())); bind(IterationStopWatch.class).toInstance(new IterationStopWatch()); bind(IterationCounter.class).toInstance(() -> 0); install(new ScenarioByInstanceModule(ScenarioUtils.createScenario(config))); diff --git a/matsim/src/test/java/org/matsim/core/controler/corelisteners/PlansDumpingIT.java b/matsim/src/test/java/org/matsim/core/controler/corelisteners/PlansDumpingIT.java index 6bb6709fced..ee429308a3a 100644 --- a/matsim/src/test/java/org/matsim/core/controler/corelisteners/PlansDumpingIT.java +++ b/matsim/src/test/java/org/matsim/core/controler/corelisteners/PlansDumpingIT.java @@ -40,11 +40,11 @@ public class PlansDumpingIT { @Test public void testPlansDump_Interval() { Config config = this.util.loadConfig("test/scenarios/equil/config_plans1.xml"); - config.controler().setLastIteration(10); - config.controler().setWritePlansInterval(3); + config.controller().setLastIteration(10); + config.controller().setWritePlansInterval(3); Controler c = new Controler(config); - c.getConfig().controler().setWriteEventsInterval(0); - c.getConfig().controler().setCreateGraphs(false); + c.getConfig().controller().setWriteEventsInterval(0); + c.getConfig().controller().setCreateGraphs(false); c.run(); @@ -64,11 +64,11 @@ public void testPlansDump_Interval() { @Test public void testPlansDump_Never() { Config config = this.util.loadConfig("test/scenarios/equil/config_plans1.xml"); - config.controler().setLastIteration(10); - config.controler().setWritePlansInterval(0); + config.controller().setLastIteration(10); + config.controller().setWritePlansInterval(0); Controler c = new Controler(config); - c.getConfig().controler().setWriteEventsInterval(0); - c.getConfig().controler().setCreateGraphs(false); + c.getConfig().controller().setWriteEventsInterval(0); + c.getConfig().controller().setCreateGraphs(false); c.run(); @@ -88,11 +88,11 @@ public void testPlansDump_Never() { @Test public void testPlansDump_Always() { Config config = this.util.loadConfig("test/scenarios/equil/config_plans1.xml"); - config.controler().setLastIteration(10); - config.controler().setWritePlansInterval(1); + config.controller().setLastIteration(10); + config.controller().setWritePlansInterval(1); Controler c = new Controler(config); - c.getConfig().controler().setWriteEventsInterval(0); - c.getConfig().controler().setCreateGraphs(false); + c.getConfig().controller().setWriteEventsInterval(0); + c.getConfig().controller().setCreateGraphs(false); c.run(); diff --git a/matsim/src/test/java/org/matsim/core/mobsim/hermes/HermesRoundaboutTest.java b/matsim/src/test/java/org/matsim/core/mobsim/hermes/HermesRoundaboutTest.java index 295e049cea0..ff2e28c9e31 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/hermes/HermesRoundaboutTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/hermes/HermesRoundaboutTest.java @@ -68,8 +68,8 @@ public class HermesRoundaboutTest { public void testRoundaboutBehavior(){ ScenarioImporter.flush(); final Config config = createConfig(); - config.controler().setMobsim("hermes"); - config.parallelEventHandling().setOneThreadPerHandler(true); + config.controller().setMobsim("hermes"); + config.eventsManager().setOneThreadPerHandler(true); Scenario scenario = ScenarioUtils.createScenario(config); buildRoundaboutNetwork(scenario); buildPopulation(scenario); @@ -87,26 +87,26 @@ public void testRoundaboutBehavior(){ private Config createConfig() { Config config = ConfigUtils.createConfig(); - config.controler().setOutputDirectory(utils.getOutputDirectory()); + config.controller().setOutputDirectory(utils.getOutputDirectory()); config.qsim().setUsePersonIdForMissingVehicleId(true); - config.controler().setFirstIteration(0); - config.controler().setLastIteration(2); - config.controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles); - config.plansCalcRoute().setAccessEgressType(RoutingConfigGroup.AccessEgressType.accessEgressModeToLink); //standard accessEgressMode is walk + config.controller().setFirstIteration(0); + config.controller().setLastIteration(2); + config.controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles); + config.routing().setAccessEgressType(RoutingConfigGroup.AccessEgressType.accessEgressModeToLink); //standard accessEgressMode is walk final ScoringConfigGroup.ActivityParams homeParams = new ScoringConfigGroup.ActivityParams("home"); homeParams.setTypicalDuration(1); - config.planCalcScore().addActivityParams(homeParams); + config.scoring().addActivityParams(homeParams); final ScoringConfigGroup.ActivityParams workParams = new ScoringConfigGroup.ActivityParams("work"); workParams.setTypicalDuration(1); - config.planCalcScore().addActivityParams(workParams); + config.scoring().addActivityParams(workParams); ReplanningConfigGroup.StrategySettings replanning = new ReplanningConfigGroup.StrategySettings(); replanning.setStrategyName("ReRoute"); replanning.setWeight(1.0); - config.strategy().addStrategySettings(replanning); + config.replanning().addStrategySettings(replanning); return config; } diff --git a/matsim/src/test/java/org/matsim/core/mobsim/hermes/StorageCapacityTest.java b/matsim/src/test/java/org/matsim/core/mobsim/hermes/StorageCapacityTest.java index c0488b7d76a..bd3289bc276 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/hermes/StorageCapacityTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/hermes/StorageCapacityTest.java @@ -234,7 +234,7 @@ public void testStorageCapacityWithDifferentPCUs() { public void testStorageCapacityWithVaryingPCUs() { ScenarioImporter.flush(); Config config = ConfigUtils.createConfig(); - config.plansCalcRoute().setNetworkModes(Set.of(TransportMode.car, TransportMode.truck)); + config.routing().setNetworkModes(Set.of(TransportMode.car, TransportMode.truck)); config.hermes().setStuckTime(Integer.MAX_VALUE); config.hermes().setMainModes(Set.of(TransportMode.car, TransportMode.truck)); Scenario scenario = ScenarioUtils.createScenario(config); diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/AbstractQSimModuleTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/AbstractQSimModuleTest.java index 9dfedb7daba..02166c720bb 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/AbstractQSimModuleTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/AbstractQSimModuleTest.java @@ -47,7 +47,7 @@ import com.google.inject.Inject; import com.google.inject.Injector; -public class AbstractQSimModuleTest { +public class AbstractQSimModuleTest { @Test public void testOverrides() { AbstractQSimModule moduleA = new AbstractQSimModule() { @@ -83,8 +83,8 @@ protected void configureQSim() { @Test public void testOverrideAgentFactory() { Config config = ConfigUtils.createConfig(); - config.controler().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); - config.controler().setLastIteration(0); + config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); + config.controller().setLastIteration(0); Scenario scenario = ScenarioUtils.loadScenario(config); @@ -103,12 +103,12 @@ public void testOverrideAgentFactory() { Assert.assertTrue(value.get() > 0); } - + @Test public void testOverrideAgentFactoryTwice() { Config config = ConfigUtils.createConfig(); - config.controler().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); - config.controler().setLastIteration(0); + config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); + config.controller().setLastIteration(0); Scenario scenario = ScenarioUtils.loadScenario(config); @@ -165,8 +165,8 @@ public MobsimAgent createMobsimAgentFromPerson(Person p) { @Test public void testAddEngine() { Config config = ConfigUtils.createConfig(); - config.controler().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); - config.controler().setLastIteration(0); + config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); + config.controller().setLastIteration(0); Scenario scenario = ScenarioUtils.loadScenario(config); diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/AgentNotificationTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/AgentNotificationTest.java index 75ace02794a..55a02dfcfd6 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/AgentNotificationTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/AgentNotificationTest.java @@ -309,7 +309,7 @@ private static Scenario createSimpleScenario() { RoutingConfigGroup.TeleportedModeParams params = new RoutingConfigGroup.TeleportedModeParams( TransportMode.walk ) ; params.setBeelineDistanceFactor(1.3); params.setTeleportedModeSpeed(1.); - config.plansCalcRoute().addModeRoutingParams( params ); + config.routing().addModeRoutingParams( params ); Scenario scenario = ScenarioUtils.createScenario(config); diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/NetsimRoutingConsistencyTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/NetsimRoutingConsistencyTest.java index aaf4f99f1ee..c93509f82c9 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/NetsimRoutingConsistencyTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/NetsimRoutingConsistencyTest.java @@ -214,12 +214,12 @@ public void testRoutingVsSimulation() { public void testRoutingVsSimulationFullStack() { Config config = ConfigUtils.createConfig(); - config.controler().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); - config.controler().setLastIteration(0); + config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); + config.controller().setLastIteration(0); ActivityParams activityParams = new ActivityParams("A"); activityParams.setTypicalDuration(100.0); - config.planCalcScore().addActivityParams(activityParams); + config.scoring().addActivityParams(activityParams); Scenario scenario = ScenarioUtils.createScenario(config); Network network = scenario.getNetwork(); diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/NodeTransitionTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/NodeTransitionTest.java index 6fb3401ac8b..954f61a3eda 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/NodeTransitionTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/NodeTransitionTest.java @@ -640,13 +640,13 @@ private static final class Fixture { static Scenario createMergeScenario() { MatsimRandom.reset(); Config config = ConfigUtils.createConfig(); - config.controler().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); - config.controler().setLastIteration(0); + config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); + config.controller().setLastIteration(0); config.qsim().setStuckTime(24*3600); config.qsim().setRemoveStuckVehicles(false); ScoringConfigGroup.ActivityParams dummyAct = new ScoringConfigGroup.ActivityParams("dummy"); dummyAct.setTypicalDuration(12 * 3600); - config.planCalcScore().addActivityParams(dummyAct); + config.scoring().addActivityParams(dummyAct); Scenario scenario = ScenarioUtils.createScenario(config); @@ -681,13 +681,13 @@ static Scenario createMergeScenario() { static Scenario createBlockedNodeScenario() { MatsimRandom.reset(); Config config = ConfigUtils.createConfig(); - config.controler().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); - config.controler().setLastIteration(0); + config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); + config.controller().setLastIteration(0); config.qsim().setStuckTime(24*3600); config.qsim().setRemoveStuckVehicles(false); ScoringConfigGroup.ActivityParams dummyAct = new ScoringConfigGroup.ActivityParams("dummy"); dummyAct.setTypicalDuration(12 * 3600); - config.planCalcScore().addActivityParams(dummyAct); + config.scoring().addActivityParams(dummyAct); Scenario scenario = ScenarioUtils.createScenario(config); diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/QSimEventsIntegrationTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/QSimEventsIntegrationTest.java index 20d617bca25..09c873c3f2c 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/QSimEventsIntegrationTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/QSimEventsIntegrationTest.java @@ -62,8 +62,8 @@ public void netsimEngineHandlesExceptionCorrectly() { @Test public void controlerHandlesExceptionCorrectly_syncOnSimSteps() { Config config = utils.loadConfig("test/scenarios/equil/config_plans1.xml"); - config.parallelEventHandling().setNumberOfThreads(1); - config.parallelEventHandling().setSynchronizeOnSimSteps(true); + config.eventsManager().setNumberOfThreads(1); + config.eventsManager().setSynchronizeOnSimSteps(true); Controler controler = new Controler(config); controler.getEvents().addHandler((LinkLeaveEventHandler)event -> { @@ -77,8 +77,8 @@ public void controlerHandlesExceptionCorrectly_syncOnSimSteps() { @Test public void controlerHandlesExceptionCorrectly_noSyncOnSimSteps() { Config config = utils.loadConfig("test/scenarios/equil/config_plans1.xml"); - config.parallelEventHandling().setNumberOfThreads(1); - config.parallelEventHandling().setSynchronizeOnSimSteps(false); + config.eventsManager().setNumberOfThreads(1); + config.eventsManager().setSynchronizeOnSimSteps(false); Controler controler = new Controler(config); controler.getEvents().addHandler((LinkLeaveEventHandler)event -> { diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/TeleportationEngineWDistanceCheckTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/TeleportationEngineWDistanceCheckTest.java index 4c6434b2295..9e722b5eaa6 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/TeleportationEngineWDistanceCheckTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/TeleportationEngineWDistanceCheckTest.java @@ -61,18 +61,18 @@ public class TeleportationEngineWDistanceCheckTest { @Test public final void test() { Config config = ConfigUtils.createConfig(); - config.controler().setOutputDirectory( utils.getOutputDirectory() ); - config.controler().setOverwriteFileSetting( OverwriteFileSetting.deleteDirectoryIfExists ); - config.controler().setLastIteration(0); + config.controller().setOutputDirectory( utils.getOutputDirectory() ); + config.controller().setOverwriteFileSetting( OverwriteFileSetting.deleteDirectoryIfExists ); + config.controller().setLastIteration(0); ActivityParams params = new ActivityParams("dummy" ) ; - config.planCalcScore().addActivityParams(params); + config.scoring().addActivityParams(params); params.setScoringThisActivityAtAll(false); StrategySettings stratSets = new StrategySettings() ; stratSets.setStrategyName( DefaultSelector.ChangeExpBeta.toString() ); stratSets.setWeight(1.); - config.strategy().addStrategySettings( stratSets ); + config.replanning().addStrategySettings( stratSets ); Scenario scenario = ScenarioUtils.createScenario( config ) ; diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/VehicleSourceTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/VehicleSourceTest.java index 5dc91c9df76..069f22b616b 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/VehicleSourceTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/VehicleSourceTest.java @@ -124,17 +124,17 @@ public void main() { config.qsim().setVehiclesSource(this.vehiclesSource ); config.qsim().setUsePersonIdForMissingVehicleId(this.usingPersonIdForMissingVehicleId ); - config.controler().setOutputDirectory(helper.getOutputDirectory()); - config.controler().setLastIteration(0); - config.controler().setWriteEventsInterval(1); - config.controler().setCreateGraphs(false); - config.controler().setDumpDataAtEnd(false); + config.controller().setOutputDirectory(helper.getOutputDirectory()); + config.controller().setLastIteration(0); + config.controller().setWriteEventsInterval(1); + config.controller().setCreateGraphs(false); + config.controller().setDumpDataAtEnd(false); - config.planCalcScore().addActivityParams( new ActivityParams("h").setTypicalDuration(1. * 3600. ) ); - config.planCalcScore().addActivityParams( new ActivityParams("w").setTypicalDuration(1. * 3600. ) ); + config.scoring().addActivityParams( new ActivityParams("h").setTypicalDuration(1. * 3600. ) ); + config.scoring().addActivityParams( new ActivityParams("w").setTypicalDuration(1. * 3600. ) ); final Controler cont = new Controler(scenario); - cont.getConfig().controler().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); + cont.getConfig().controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); Map, Map, Double>> vehicleLinkTravelTimes = new HashMap<>(); final VehicleLinkTravelTimeEventHandler handler = new VehicleLinkTravelTimeEventHandler(vehicleLinkTravelTimes); diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/DeparturesOnSameLinkSameTimeTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/DeparturesOnSameLinkSameTimeTest.java index 0315b827d69..f6af0e77d91 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/DeparturesOnSameLinkSameTimeTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/DeparturesOnSameLinkSameTimeTest.java @@ -59,32 +59,32 @@ public class DeparturesOnSameLinkSameTimeTest { *

      Since, the flow capacity of link l_1 is 1 PCU per sec, both motorbike should be able to leave the link l_1 at the same time * whereas cars should leave at a gap of one second. */ - @Test + @Test public void test4LinkEnterTimeOfCarAndBike () { - + Id firstAgent = Id.createVehicleId(1); Id secondAgent = Id.createVehicleId(2); - + Id departureLink = Id.createLinkId(1); - + Map,Map, Double>> motorbikeLinkLeaveTime = getLinkEnterTime("motorbike",3600); Map,Map, Double>> carLinkLeaveTime = getLinkEnterTime(TransportMode.car,3600); - + double diff_carAgents_departureLink_LeaveTimes = carLinkLeaveTime.get(secondAgent).get(departureLink) - carLinkLeaveTime.get(firstAgent).get(departureLink); Assert.assertEquals("Both car agents should leave at the gap of 1 sec.", 1., Math.abs(diff_carAgents_departureLink_LeaveTimes), MatsimTestUtils.EPSILON ); - + double diff_motorbikeAgents_departureLink_LeaveTimes = motorbikeLinkLeaveTime.get(secondAgent).get(departureLink) - motorbikeLinkLeaveTime.get(firstAgent).get(departureLink); Assert.assertEquals("Both motorbike agents should leave at the same time.", 0., diff_motorbikeAgents_departureLink_LeaveTimes, MatsimTestUtils.EPSILON ); - + // for flow cap more than 3600, both cars also should leave link l_1 at the same time. carLinkLeaveTime = getLinkEnterTime(TransportMode.car,3601); - + diff_carAgents_departureLink_LeaveTimes = carLinkLeaveTime.get(secondAgent).get(departureLink) - carLinkLeaveTime.get(firstAgent).get(departureLink); Assert.assertEquals("Both car agents should leave at the same time", 0., diff_carAgents_departureLink_LeaveTimes, MatsimTestUtils.EPSILON ); } private Map,Map, Double>> getLinkEnterTime (String travelMode, double departureLinkCapacity){ - + PseudoInputs inputs = new PseudoInputs(travelMode); inputs.createNetwork(departureLinkCapacity); inputs.createPopulation(); @@ -101,19 +101,19 @@ public void reset(int iteration) { @Override public void handleEvent(LinkLeaveEvent event) { - + if(linkLeaveTimes.containsKey(event.getVehicleId())){ - + Map, Double> times = linkLeaveTimes.get(event.getVehicleId()); times.put(event.getLinkId(), event.getTime()); linkLeaveTimes.put(event.getVehicleId(), times); - + } else { - + Map, Double> times = new HashMap, Double>(); times.put(event.getLinkId(), event.getTime()); linkLeaveTimes.put(event.getVehicleId(), times); - + } } }); @@ -150,10 +150,10 @@ public PseudoInputs(String travelMode) { //following is necessary for mixed traffic, providing a route was obstructing // the requirement of these which might be all right in some cases. Amit Jan'18 - config.plansCalcRoute().setNetworkModes(Arrays.asList(travelMode)); + config.routing().setNetworkModes(Arrays.asList(travelMode)); config.travelTimeCalculator().setAnalyzedModesAsString(travelMode ); config.travelTimeCalculator().setSeparateModes(true); - config.planCalcScore().getOrCreateModeParams(travelMode); + config.scoring().getOrCreateModeParams(travelMode); network = this.scenario.getNetwork(); population = this.scenario.getPopulation(); @@ -177,7 +177,7 @@ private void createNetwork(double departureLinkCapacity){ private void createPopulation(){ - // Vehicles info + // Vehicles info // scenario.getConfig().qsim().setUseDefaultVehicles(false); scenario.getConfig().qsim().setVehiclesSource( VehiclesSource.fromVehiclesData ) ; scenario.getConfig().qsim().setUsingFastCapacityUpdate(true); diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/FlowEfficiencyCalculatorTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/FlowEfficiencyCalculatorTest.java index 1a51f5b5df0..c343ec924ae 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/FlowEfficiencyCalculatorTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/FlowEfficiencyCalculatorTest.java @@ -130,13 +130,13 @@ public void handleEvent(PersonArrivalEvent event) { private Scenario createScenario() { Config config = ConfigUtils.createConfig(); - config.controler().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); - config.controler().setLastIteration(0); + config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); + config.controller().setLastIteration(0); ActivityParams genericParams = new ActivityParams("generic"); genericParams.setTypicalDuration(1.0); - config.planCalcScore().addActivityParams(genericParams); + config.scoring().addActivityParams(genericParams); Scenario scenario = ScenarioUtils.createScenario(config); diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/LinkSpeedCalculatorIntegrationTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/LinkSpeedCalculatorIntegrationTest.java index e66ca94331a..a73e82a5b3e 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/LinkSpeedCalculatorIntegrationTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/LinkSpeedCalculatorIntegrationTest.java @@ -147,7 +147,7 @@ public void testIntegration_Fast() { final Scenario scenario = f.scenario ; final Config config = scenario.getConfig() ; - config.controler().setOverwriteFileSetting( OverwriteFileSetting.deleteDirectoryIfExists ); + config.controller().setOverwriteFileSetting( OverwriteFileSetting.deleteDirectoryIfExists ); // Collection defaultsModules = new ArrayList<>() ; // defaultsModules.add( new ScenarioByInstanceModule( scenario ) ) ; diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/QSimComponentsTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/QSimComponentsTest.java index 2baccef0720..8915e730af2 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/QSimComponentsTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/QSimComponentsTest.java @@ -40,9 +40,9 @@ public void testRemoveNetsimEngine() { // be teleported if netsim engine is missing. Thus, the RuntimeException confirms that removing the module worked. Config config = ConfigUtils.loadConfig( IOUtils.extendUrl( ExamplesUtils.getTestScenarioURL( "equil" ), "config.xml" ) ); - config.controler().setOverwriteFileSetting( OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists ); - config.controler().setLastIteration( 0 ); - config.controler().setOutputDirectory(utils.getOutputDirectory()); + config.controller().setOverwriteFileSetting( OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists ); + config.controller().setLastIteration( 0 ); + config.controller().setOutputDirectory(utils.getOutputDirectory()); // remove the module: (There is also syntax at some intermediate level for this, but I prefer the syntax at config level. kai, oct'22) QSimComponentsConfigGroup componentsConfig = ConfigUtils.addOrGetModule( config, QSimComponentsConfigGroup.class ); @@ -62,9 +62,9 @@ public void testReplaceQNetworkFactory() { // here we try to replace the QNetworkFactory. Complains that QNetworkFactory is bound multiple times. Config config = ConfigUtils.loadConfig( IOUtils.extendUrl( ExamplesUtils.getTestScenarioURL( "equil" ), "config.xml" ) ); - config.controler().setOverwriteFileSetting( OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists ); - config.controler().setLastIteration( 0 ); - config.controler().setOutputDirectory(utils.getOutputDirectory()); + config.controller().setOverwriteFileSetting( OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists ); + config.controller().setLastIteration( 0 ); + config.controller().setOutputDirectory(utils.getOutputDirectory()); Scenario scenario = ScenarioUtils.loadScenario( config ); @@ -88,9 +88,9 @@ public void testReplaceQNetworkFactory2() { // here we try to replace the QNetworkFactory at AbstractQSimModule. This works. Config config = ConfigUtils.loadConfig( IOUtils.extendUrl( ExamplesUtils.getTestScenarioURL( "equil" ), "config.xml" ) ); - config.controler().setOverwriteFileSetting( OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists ); - config.controler().setLastIteration( 0 ); - config.controler().setOutputDirectory(utils.getOutputDirectory()); + config.controller().setOverwriteFileSetting( OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists ); + config.controller().setLastIteration( 0 ); + config.controller().setOutputDirectory(utils.getOutputDirectory()); Scenario scenario = ScenarioUtils.loadScenario( config ); @@ -110,9 +110,9 @@ public void testOverridingQSimModule() { // use the newly implemented install _overriding_ qsim module. With this, replacing the QNetworkFactory now works as part of AbstractModule. Config config = ConfigUtils.loadConfig( IOUtils.extendUrl( ExamplesUtils.getTestScenarioURL( "equil" ), "config.xml" ) ); - config.controler().setOverwriteFileSetting( OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists ); - config.controler().setLastIteration( 0 ); - config.controler().setOutputDirectory(utils.getOutputDirectory()); + config.controller().setOverwriteFileSetting( OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists ); + config.controller().setLastIteration( 0 ); + config.controller().setOutputDirectory(utils.getOutputDirectory()); Scenario scenario = ScenarioUtils.loadScenario( config ); diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/RunConfigurableQNetworkFactoryExampleTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/RunConfigurableQNetworkFactoryExampleTest.java index 36556c44b3f..958ba50b9ea 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/RunConfigurableQNetworkFactoryExampleTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/RunConfigurableQNetworkFactoryExampleTest.java @@ -37,14 +37,14 @@ public class RunConfigurableQNetworkFactoryExampleTest { public final void testMain() { try { Config config = ConfigUtils.createConfig() ; - config.controler().setOverwriteFileSetting( OverwriteFileSetting.deleteDirectoryIfExists ); - config.controler().setLastIteration(5); + config.controller().setOverwriteFileSetting( OverwriteFileSetting.deleteDirectoryIfExists ); + config.controller().setLastIteration(5); RunConfigurableQNetworkFactoryExample.run(config); } catch ( Exception ee ) { throw new RuntimeException("something went wrong", ee); } - - + + } } diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/SimulatedLaneFlowCapacityTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/SimulatedLaneFlowCapacityTest.java index 4f76e86fd33..62966d8493f 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/SimulatedLaneFlowCapacityTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/SimulatedLaneFlowCapacityTest.java @@ -211,7 +211,7 @@ private static void initPopulation(Population population) { Config config = ConfigUtils.createConfig(); ActivityParams dummyAct = new ActivityParams("dummy"); dummyAct.setTypicalDuration(12 * 3600); - config.planCalcScore().addActivityParams(dummyAct); + config.scoring().addActivityParams(dummyAct); MutableScenario scenario = (MutableScenario) ScenarioUtils.createScenario(config); initNetwork(scenario.getNetwork()); @@ -238,7 +238,7 @@ private static void initPopulation(Population population) { Config config = ConfigUtils.createConfig(); ActivityParams dummyAct = new ActivityParams("dummy"); dummyAct.setTypicalDuration(12 * 3600); - config.planCalcScore().addActivityParams(dummyAct); + config.scoring().addActivityParams(dummyAct); MutableScenario scenario = (MutableScenario) ScenarioUtils.createScenario(config); initNetwork(scenario.getNetwork()); @@ -269,7 +269,7 @@ private static void initPopulation(Population population) { Config config = ConfigUtils.createConfig(); ActivityParams dummyAct = new ActivityParams("dummy"); dummyAct.setTypicalDuration(12 * 3600); - config.planCalcScore().addActivityParams(dummyAct); + config.scoring().addActivityParams(dummyAct); MutableScenario scenario = (MutableScenario) ScenarioUtils.createScenario(config); initNetwork(scenario.getNetwork()); @@ -301,7 +301,7 @@ private static void initPopulation(Population population) { Config config = ConfigUtils.createConfig(); ActivityParams dummyAct = new ActivityParams("dummy"); dummyAct.setTypicalDuration(12 * 3600); - config.planCalcScore().addActivityParams(dummyAct); + config.scoring().addActivityParams(dummyAct); MutableScenario scenario = (MutableScenario) ScenarioUtils.createScenario(config); initNetwork(scenario.getNetwork()); diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/SpeedCalculatorTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/SpeedCalculatorTest.java index 1e1068185fc..cea3d9d7d25 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/SpeedCalculatorTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/SpeedCalculatorTest.java @@ -92,7 +92,7 @@ public class SpeedCalculatorTest{ // (dto) } private double getSpeedOnLink( Link link, QVehicle vehicle ){ - config.controler().setOutputDirectory( utils.getOutputDirectory() ); + config.controller().setOutputDirectory( utils.getOutputDirectory() ); Scenario scenario = ScenarioUtils.createScenario( config ); AbstractQSimModule module = new AbstractQSimModule(){ @Override public void configureQSim(){ diff --git a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/VehicleHandlerTest.java b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/VehicleHandlerTest.java index 1d6b9db0cb9..48bf9fbc37a 100644 --- a/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/VehicleHandlerTest.java +++ b/matsim/src/test/java/org/matsim/core/mobsim/qsim/qnetsimengine/VehicleHandlerTest.java @@ -185,14 +185,14 @@ public void handleEvent(PersonArrivalEvent event) { private Scenario createScenario() { Config config = ConfigUtils.createConfig(); - config.controler().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); - config.controler().setLastIteration(0); - config.controler().setOutputDirectory(utils.getOutputDirectory()); + config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); + config.controller().setLastIteration(0); + config.controller().setOutputDirectory(utils.getOutputDirectory()); ActivityParams genericParams = new ActivityParams("generic"); genericParams.setTypicalDuration(1.0); - config.planCalcScore().addActivityParams(genericParams); + config.scoring().addActivityParams(genericParams); Scenario scenario = ScenarioUtils.createScenario(config); diff --git a/matsim/src/test/java/org/matsim/core/network/io/NetworkReprojectionIOTest.java b/matsim/src/test/java/org/matsim/core/network/io/NetworkReprojectionIOTest.java index c23569a6922..3fe86ebe824 100644 --- a/matsim/src/test/java/org/matsim/core/network/io/NetworkReprojectionIOTest.java +++ b/matsim/src/test/java/org/matsim/core/network/io/NetworkReprojectionIOTest.java @@ -143,9 +143,9 @@ public void testWithControlerAndAttributes() { TARGET_CRS, ProjectionUtils.getCRS(scenario.getNetwork())); - config.controler().setLastIteration( 0 ); + config.controller().setLastIteration( 0 ); final String outputDirectory = utils.getOutputDirectory()+"/output/"; - config.controler().setOutputDirectory( outputDirectory ); + config.controller().setOutputDirectory( outputDirectory ); final Controler controler = new Controler( scenario ); controler.run(); @@ -197,9 +197,9 @@ public void testWithControlerAndConfigParameters() { MatsimTestUtils.EPSILON ); } - config.controler().setLastIteration( 0 ); + config.controller().setLastIteration( 0 ); final String outputDirectory = utils.getOutputDirectory()+"/output/"; - config.controler().setOutputDirectory( outputDirectory ); + config.controller().setOutputDirectory( outputDirectory ); final Controler controler = new Controler( scenario ); controler.run(); diff --git a/matsim/src/test/java/org/matsim/core/population/io/PopulationReprojectionIOIT.java b/matsim/src/test/java/org/matsim/core/population/io/PopulationReprojectionIOIT.java index 6746f3dd945..853af4157eb 100644 --- a/matsim/src/test/java/org/matsim/core/population/io/PopulationReprojectionIOIT.java +++ b/matsim/src/test/java/org/matsim/core/population/io/PopulationReprojectionIOIT.java @@ -215,9 +215,9 @@ public void testWithControlerAndAttributes() { ProjectionUtils.getCRS(scenario.getPopulation())); // do not perform ANY mobsim run - config.controler().setLastIteration( -1 ); + config.controller().setLastIteration( -1 ); final String outputDirectory = utils.getOutputDirectory()+"/output/"; - config.controler().setOutputDirectory( outputDirectory ); + config.controller().setOutputDirectory( outputDirectory ); final Controler controler = new Controler( scenario ); controler.run(); @@ -319,9 +319,9 @@ public void testWithControlerAndConfigParameters() { } // do not perform ANY mobsim run - config.controler().setLastIteration( -1 ); + config.controller().setLastIteration( -1 ); final String outputDirectory = utils.getOutputDirectory()+"/output/"; - config.controler().setOutputDirectory( outputDirectory ); + config.controller().setOutputDirectory( outputDirectory ); final Controler controler = new Controler( scenario ); controler.run(); diff --git a/matsim/src/test/java/org/matsim/core/population/routes/RouteFactoryIntegrationTest.java b/matsim/src/test/java/org/matsim/core/population/routes/RouteFactoryIntegrationTest.java index 4c9895183a2..bcecf3f052a 100644 --- a/matsim/src/test/java/org/matsim/core/population/routes/RouteFactoryIntegrationTest.java +++ b/matsim/src/test/java/org/matsim/core/population/routes/RouteFactoryIntegrationTest.java @@ -53,7 +53,7 @@ public class RouteFactoryIntegrationTest { public void testRouteFactoryIntegration() { Config config = utils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("equil"), "config.xml")); config.plans().setInputFile("plans2.xml"); - Collection settings = config.strategy().getStrategySettings(); + Collection settings = config.replanning().getStrategySettings(); for (StrategySettings setting: settings) { if ("ReRoute".equals(setting.getStrategyName())) { setting.setWeight(1.0); @@ -61,13 +61,13 @@ public void testRouteFactoryIntegration() { setting.setWeight(0.0); } } - config.controler().setLastIteration(1); + config.controller().setLastIteration(1); // test the default - config.controler().setOutputDirectory(utils.getOutputDirectory() + "/default"); + config.controller().setOutputDirectory(utils.getOutputDirectory() + "/default"); Controler controler = new Controler(config); - controler.getConfig().controler().setCreateGraphs(false); - controler.getConfig().controler().setWriteEventsInterval(0); + controler.getConfig().controller().setCreateGraphs(false); + controler.getConfig().controller().setWriteEventsInterval(0); controler.run(); Population population = controler.getScenario().getPopulation(); @@ -86,14 +86,14 @@ public void testRouteFactoryIntegration() { } // test another setting - config.controler().setOutputDirectory(utils.getOutputDirectory() + "/variant1"); + config.controller().setOutputDirectory(utils.getOutputDirectory() + "/variant1"); MutableScenario scenario = (MutableScenario) ScenarioUtils.createScenario(config); scenario.getPopulation().getFactory().getRouteFactories().setRouteFactory(NetworkRoute.class, new HeavyCompressedNetworkRouteFactory(scenario.getNetwork(), TransportMode.car)); ScenarioUtils.loadScenario(scenario); Controler controler2 = new Controler(scenario); - controler2.getConfig().controler().setCreateGraphs(false); - controler2.getConfig().controler().setWriteEventsInterval(0); + controler2.getConfig().controller().setCreateGraphs(false); + controler2.getConfig().controller().setWriteEventsInterval(0); controler2.run(); Population population2 = controler2.getScenario().getPopulation(); diff --git a/matsim/src/test/java/org/matsim/core/replanning/annealing/ReplanningAnnealerTest.java b/matsim/src/test/java/org/matsim/core/replanning/annealing/ReplanningAnnealerTest.java index 246bc407f50..1a04ffdf6cb 100644 --- a/matsim/src/test/java/org/matsim/core/replanning/annealing/ReplanningAnnealerTest.java +++ b/matsim/src/test/java/org/matsim/core/replanning/annealing/ReplanningAnnealerTest.java @@ -170,23 +170,23 @@ public void setup() { ReplanningConfigGroup.StrategySettings s1 = new ReplanningConfigGroup.StrategySettings(); s1.setStrategyName("ReRoute"); s1.setWeight(0.2); - this.config.strategy().addStrategySettings(s1); + this.config.replanning().addStrategySettings(s1); ReplanningConfigGroup.StrategySettings s2 = new ReplanningConfigGroup.StrategySettings(); s2.setStrategyName("SubtourModeChoice"); s2.setWeight(0.2); - this.config.strategy().addStrategySettings(s2); + this.config.replanning().addStrategySettings(s2); ReplanningConfigGroup.StrategySettings s3 = new ReplanningConfigGroup.StrategySettings(); s3.setStrategyName("ChangeExpBeta"); // shouldn't be affected s3.setWeight(0.5); - this.config.strategy().addStrategySettings(s3); + this.config.replanning().addStrategySettings(s3); - this.config.controler().setCreateGraphs(false); - this.config.controler().setDumpDataAtEnd(false); - this.config.controler().setWriteEventsInterval(0); - this.config.controler().setWritePlansInterval(0); - this.config.controler().setWriteSnapshotsInterval(0); - this.config.controler().setLastIteration(10); - this.config.controler().setOutputDirectory(this.utils.getOutputDirectory() + "annealOutput"); + this.config.controller().setCreateGraphs(false); + this.config.controller().setDumpDataAtEnd(false); + this.config.controller().setWriteEventsInterval(0); + this.config.controller().setWritePlansInterval(0); + this.config.controller().setWriteSnapshotsInterval(0); + this.config.controller().setLastIteration(10); + this.config.controller().setOutputDirectory(this.utils.getOutputDirectory() + "annealOutput"); this.scenario = ScenarioUtils.createScenario(this.config); } @@ -288,7 +288,7 @@ public void testParameterAnneal() throws IOException { controler.run(); Assert.assertEquals(expectedParameterAnneal, readResult(controler.getControlerIO().getOutputFilename(FILENAME_ANNEAL))); - Assert.assertEquals(0.0, controler.getConfig().planCalcScore().getBrainExpBeta(), 1e-4); + Assert.assertEquals(0.0, controler.getConfig().scoring().getBrainExpBeta(), 1e-4); } @Test @@ -308,7 +308,7 @@ public void testTwoParameterAnneal() throws IOException { controler.run(); Assert.assertEquals(expectedTwoParameterAnneal, readResult(controler.getControlerIO().getOutputFilename(FILENAME_ANNEAL))); - Assert.assertEquals(0.0, controler.getConfig().planCalcScore().getBrainExpBeta(), 1e-4); + Assert.assertEquals(0.0, controler.getConfig().scoring().getBrainExpBeta(), 1e-4); StrategyManager sm = controler.getInjector().getInstance(StrategyManager.class); List weights = sm.getWeights(null); @@ -318,7 +318,7 @@ public void testTwoParameterAnneal() throws IOException { @Test public void testInnovationSwitchoffAnneal() throws IOException { - this.config.strategy().setFractionOfIterationsToDisableInnovation(0.5); + this.config.replanning().setFractionOfIterationsToDisableInnovation(0.5); this.saConfigVar.setAnnealType("msa"); this.saConfigVar.setShapeFactor(1.0); this.saConfigVar.setStartValue(0.5); @@ -359,12 +359,12 @@ public void testSubpopulationAnneal() throws IOException { this.saConfigVar.setEndValue(0.0); this.saConfigVar.setStartValue(0.5); this.saConfigVar.setDefaultSubpopulation(targetSubpop); - this.config.strategy().getStrategySettings().forEach(s -> s.setSubpopulation(targetSubpop)); + this.config.replanning().getStrategySettings().forEach(s -> s.setSubpopulation(targetSubpop)); ReplanningConfigGroup.StrategySettings s = new ReplanningConfigGroup.StrategySettings(); s.setStrategyName("TimeAllocationMutator"); s.setWeight(0.25); s.setSubpopulation("noAnneal"); - this.config.strategy().addStrategySettings(s); + this.config.replanning().addStrategySettings(s); Controler controler = new Controler(this.scenario); controler.run(); diff --git a/matsim/src/test/java/org/matsim/core/replanning/modules/ExternalModuleTest.java b/matsim/src/test/java/org/matsim/core/replanning/modules/ExternalModuleTest.java index a68ffca463a..d7a8f260215 100644 --- a/matsim/src/test/java/org/matsim/core/replanning/modules/ExternalModuleTest.java +++ b/matsim/src/test/java/org/matsim/core/replanning/modules/ExternalModuleTest.java @@ -33,11 +33,9 @@ import org.matsim.api.core.v01.replanning.PlanStrategyModule; import org.matsim.core.config.ConfigUtils; import org.matsim.core.controler.*; -import org.matsim.core.controler.corelisteners.ControlerDefaultCoreListenersModule; import org.matsim.core.population.PopulationUtils; import org.matsim.core.population.io.PopulationReader; import org.matsim.core.replanning.ReplanningContext; -import org.matsim.core.scenario.ScenarioByInstanceModule; import org.matsim.core.scenario.ScenarioUtils; import org.matsim.testcases.MatsimTestUtils; @@ -56,8 +54,8 @@ public void setUp() { originalScenario = ScenarioUtils.loadScenario(utils.loadConfig("test/scenarios/equil/config.xml")); final String outputDirectory = utils.getOutputDirectory(); outputDirectoryHierarchy = new OutputDirectoryHierarchy( - outputDirectory, OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists, this.scenario.getConfig().controler().getCompressionType()); - scenario.getConfig().controler().setOutputDirectory( outputDirectory ); + outputDirectory, OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists, this.scenario.getConfig().controller().getCompressionType()); + scenario.getConfig().controller().setOutputDirectory( outputDirectory ); // scenario.getConfig().controler().setOverwriteFileSetting( OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles ); // // the following includes all retrofittings that were added later: diff --git a/matsim/src/test/java/org/matsim/core/replanning/selectors/ExpBetaPlanSelectorTest.java b/matsim/src/test/java/org/matsim/core/replanning/selectors/ExpBetaPlanSelectorTest.java index 6633c641ce4..5de64cd172d 100644 --- a/matsim/src/test/java/org/matsim/core/replanning/selectors/ExpBetaPlanSelectorTest.java +++ b/matsim/src/test/java/org/matsim/core/replanning/selectors/ExpBetaPlanSelectorTest.java @@ -54,14 +54,14 @@ public class ExpBetaPlanSelectorTest extends AbstractPlanSelectorTest { @Override protected ExpBetaPlanSelector getPlanSelector() { - return new ExpBetaPlanSelector(this.config.planCalcScore()); + return new ExpBetaPlanSelector(this.config.scoring()); } /** * Test that plans are selected depending on their weight, use beta = 2.0. */ @Test public void testExpBeta2() { - this.config.planCalcScore().setBrainExpBeta(2.0); + this.config.scoring().setBrainExpBeta(2.0); Person person = PopulationUtils.getFactory().createPerson(Id.create(1, Person.class)); // weight = Math.exp(this.beta * (plan.getScore() - maxScore)); Plan plan1 = PersonUtils.createAndAddPlan(person, false); // weight: 0.0003.35462627902512 @@ -75,7 +75,7 @@ protected ExpBetaPlanSelector getPlanSelector() { Plan plan5 = PersonUtils.createAndAddPlan(person, false);// weight: 1 plan5.setScore(100.0); - ExpBetaPlanSelector selector = new ExpBetaPlanSelector(this.config.planCalcScore()); + ExpBetaPlanSelector selector = new ExpBetaPlanSelector(this.config.scoring()); int cnt1 = 0; int cnt2 = 0; int cnt3 = 0; @@ -113,7 +113,7 @@ protected ExpBetaPlanSelector getPlanSelector() { * Test that plans are selected depending on their weight, use beta = 2.0. */ @Test public void testExpBeta1() { - this.config.planCalcScore().setBrainExpBeta(1.0); + this.config.scoring().setBrainExpBeta(1.0); Person person = PopulationUtils.getFactory().createPerson(Id.create(1, Person.class)); // weight = Math.exp(this.beta * (plan.getScore() - maxScore)); // weight: 0.018315638888734186 @@ -134,7 +134,7 @@ protected ExpBetaPlanSelector getPlanSelector() { - ExpBetaPlanSelector selector = new ExpBetaPlanSelector(this.config.planCalcScore()); + ExpBetaPlanSelector selector = new ExpBetaPlanSelector(this.config.scoring()); int cnt1 = 0; int cnt2 = 0; int cnt3 = 0; @@ -175,7 +175,7 @@ protected ExpBetaPlanSelector getPlanSelector() { */ final double EPSILON_R = 1e-7; - this.config.planCalcScore().setBrainExpBeta(2.0); + this.config.scoring().setBrainExpBeta(2.0); Person person = PopulationUtils.getFactory().createPerson(Id.create(1, Person.class)); Plan plan1 = PersonUtils.createAndAddPlan(person, false); plan1.setScore(180.0); @@ -186,7 +186,7 @@ protected ExpBetaPlanSelector getPlanSelector() { Plan plan4 = PersonUtils.createAndAddPlan(person, false); plan4.setScore(169.9); - ExpBetaPlanSelector testee = new ExpBetaPlanSelector(this.config.planCalcScore()); + ExpBetaPlanSelector testee = new ExpBetaPlanSelector(this.config.scoring()); assertEquals(0.2024421, ExpBetaPlanSelector.getSelectionProbability(testee, person, plan1), EPSILON_R); assertEquals(0.2472634, ExpBetaPlanSelector.getSelectionProbability(testee, person, plan2), EPSILON_R); diff --git a/matsim/src/test/java/org/matsim/core/replanning/selectors/PathSizeLogitSelectorTest.java b/matsim/src/test/java/org/matsim/core/replanning/selectors/PathSizeLogitSelectorTest.java index 56025703943..f21680b1ea9 100644 --- a/matsim/src/test/java/org/matsim/core/replanning/selectors/PathSizeLogitSelectorTest.java +++ b/matsim/src/test/java/org/matsim/core/replanning/selectors/PathSizeLogitSelectorTest.java @@ -60,8 +60,8 @@ public class PathSizeLogitSelectorTest extends AbstractPlanSelectorTest { @Before public void setUp() { this.config = utils.loadConfig((String)null); // required for planCalcScore.beta to be defined - config.planCalcScore().setBrainExpBeta(2.0); - config.planCalcScore().setPathSizeLogitBeta(2.0); + config.scoring().setBrainExpBeta(2.0); + config.scoring().setPathSizeLogitBeta(2.0); this.network = null; } @@ -72,7 +72,7 @@ public class PathSizeLogitSelectorTest extends AbstractPlanSelectorTest { @Override protected PlanSelector getPlanSelector() { - return new PathSizeLogitSelector(config.planCalcScore(), createNetwork()); + return new PathSizeLogitSelector(config.scoring(), createNetwork()); } @Override @@ -287,7 +287,7 @@ protected PlanSelector getPlanSelector() { p3.setScore(-10.0); person.addPlan(p3); - PathSizeLogitSelector selector = new PathSizeLogitSelector(this.config.planCalcScore(), network); + PathSizeLogitSelector selector = new PathSizeLogitSelector(this.config.scoring(), network); int cnt1 = 0; int cnt2 = 0; int cnt3 = 0; diff --git a/matsim/src/test/java/org/matsim/core/replanning/strategies/DeterministicMultithreadedReplanningIT.java b/matsim/src/test/java/org/matsim/core/replanning/strategies/DeterministicMultithreadedReplanningIT.java index 809249f84d7..be3a2df553f 100644 --- a/matsim/src/test/java/org/matsim/core/replanning/strategies/DeterministicMultithreadedReplanningIT.java +++ b/matsim/src/test/java/org/matsim/core/replanning/strategies/DeterministicMultithreadedReplanningIT.java @@ -69,13 +69,13 @@ public class DeterministicMultithreadedReplanningIT { public void testTimeAllocationMutator() { int lastIteration = 5; Config config = testUtils.loadConfig("test/scenarios/equil/config.xml"); - config.controler().setLastIteration(lastIteration); + config.controller().setLastIteration(lastIteration); config.global().setNumberOfThreads(4); // just use any number > 1 { StrategyManager strategyManager = new StrategyManager(); - config.controler().setOutputDirectory(testUtils.getOutputDirectory() + "/run1/"); + config.controller().setOutputDirectory(testUtils.getOutputDirectory() + "/run1/"); TestControler controler = new TestControler(config, strategyManager); PlanStrategyImpl strategy = new PlanStrategyImpl(new RandomPlanSelector()); strategy.addStrategyModule(new TimeAllocationMutatorModule(TripRouterFactoryBuilderWithDefaults.createDefaultTripRouterFactoryImpl(controler.getScenario() ), config.plans(), config.timeAllocationMutator(), config.global()) ); @@ -85,7 +85,7 @@ public void testTimeAllocationMutator() { { StrategyManager strategyManager = new StrategyManager(); - config.controler().setOutputDirectory(testUtils.getOutputDirectory() + "/run2/"); + config.controller().setOutputDirectory(testUtils.getOutputDirectory() + "/run2/"); TestControler controler = new TestControler(config, strategyManager); PlanStrategyImpl strategy = new PlanStrategyImpl(new RandomPlanSelector()); strategy.addStrategyModule(new TimeAllocationMutatorModule(TripRouterFactoryBuilderWithDefaults.createDefaultTripRouterFactoryImpl(controler.getScenario() ), config.plans(), config.timeAllocationMutator(), config.global()) ); @@ -116,7 +116,7 @@ public void testTimeAllocationMutator() { public void testReRouteTimeAllocationMutator() { int lastIteration = 5; Config config = testUtils.loadConfig("test/scenarios/equil/config.xml"); - config.controler().setLastIteration(lastIteration); + config.controller().setLastIteration(lastIteration); config.global().setNumberOfThreads(4); // just use any number > 1 { @@ -126,7 +126,7 @@ public void testReRouteTimeAllocationMutator() { PlanStrategyImpl strategy = new PlanStrategyImpl(new RandomPlanSelector()); strategyManager.addStrategy( strategy, null, 1.0 ); - config.controler().setOutputDirectory(testUtils.getOutputDirectory() + "/run1/"); + config.controller().setOutputDirectory(testUtils.getOutputDirectory() + "/run1/"); TestControler controler = new TestControler(config, strategyManager); strategy.addStrategyModule(new ReRoute(controler.getScenario(), TripRouterFactoryBuilderWithDefaults.createDefaultTripRouterFactoryImpl(controler.getScenario()), TimeInterpretation.create(config))); // finish strategy configuration strategy.addStrategyModule(new TimeAllocationMutatorModule(TripRouterFactoryBuilderWithDefaults.createDefaultTripRouterFactoryImpl(controler.getScenario() ), config.plans(), config.timeAllocationMutator(), config.global()) ); @@ -139,7 +139,7 @@ public void testReRouteTimeAllocationMutator() { PlanStrategyImpl strategy2 = new PlanStrategyImpl(new RandomPlanSelector()); strategyManager2.addStrategy( strategy2, null, 1.0 ); - config.controler().setOutputDirectory(testUtils.getOutputDirectory() + "/run2/"); + config.controller().setOutputDirectory(testUtils.getOutputDirectory() + "/run2/"); TestControler controler2 = new TestControler(config, strategyManager2); strategy2.addStrategyModule(new ReRoute(controler2.getScenario(), TripRouterFactoryBuilderWithDefaults.createDefaultTripRouterFactoryImpl(controler2.getScenario()), TimeInterpretation.create(config))); // finish strategy configuration strategy2.addStrategyModule(new TimeAllocationMutatorModule(TripRouterFactoryBuilderWithDefaults.createDefaultTripRouterFactoryImpl(controler2.getScenario() ), config.plans(), config.timeAllocationMutator(), config.global()) ); @@ -172,7 +172,7 @@ public void testReRouteOneAgent() { Config config = testUtils.loadConfig("test/scenarios/equil/config.xml"); // yy this seems to be taking the input from the matsim-examples module. No idea by what automagic it ends up there. kai, feb'19 - config.controler().setLastIteration(lastIteration); + config.controller().setLastIteration(lastIteration); config.global().setNumberOfThreads(4); // just use any number > 1 config.plans().setInputFile(IOUtils.extendUrl(testUtils.classInputResourcePath(), "plans1.xml").toString()); { @@ -181,7 +181,7 @@ public void testReRouteOneAgent() { StrategyManager strategyManager = new StrategyManager(); strategyManager.addStrategy( strategy, null, 1.0 ); - config.controler().setOutputDirectory(testUtils.getOutputDirectory() + "/run1/"); + config.controller().setOutputDirectory(testUtils.getOutputDirectory() + "/run1/"); TestControler controler = new TestControler(config, strategyManager); strategy.addStrategyModule(new ReRoute(controler.getScenario(), TripRouterFactoryBuilderWithDefaults.createDefaultTripRouterFactoryImpl(controler.getScenario()), TimeInterpretation.create(config))); controler.run(); @@ -193,7 +193,7 @@ public void testReRouteOneAgent() { StrategyManager strategyManager2 = new StrategyManager(); strategyManager2.addStrategy( strategy2, null, 1.0 ); - config.controler().setOutputDirectory(testUtils.getOutputDirectory() + "/run2/"); + config.controller().setOutputDirectory(testUtils.getOutputDirectory() + "/run2/"); TestControler controler2 = new TestControler(config, strategyManager2); strategy2.addStrategyModule(new ReRoute(controler2.getScenario(), TripRouterFactoryBuilderWithDefaults.createDefaultTripRouterFactoryImpl(controler2.getScenario()), TimeInterpretation.create(config))); @@ -224,7 +224,7 @@ public void testReRouteOneAgent() { public void testReRoute() { int lastIteration = 5; Config config = testUtils.loadConfig("test/scenarios/equil/config.xml"); - config.controler().setLastIteration(lastIteration); + config.controller().setLastIteration(lastIteration); config.global().setNumberOfThreads(4); // just use any number > 1 { @@ -233,7 +233,7 @@ public void testReRoute() { StrategyManager strategyManager = new StrategyManager(); strategyManager.addStrategy( strategy, null, 1.0 ); - config.controler().setOutputDirectory(testUtils.getOutputDirectory() + "/run1/"); + config.controller().setOutputDirectory(testUtils.getOutputDirectory() + "/run1/"); TestControler controler = new TestControler(config, strategyManager); strategy.addStrategyModule(new ReRoute(controler.getScenario(), TripRouterFactoryBuilderWithDefaults.createDefaultTripRouterFactoryImpl(controler.getScenario()), TimeInterpretation.create(config))); controler.run(); @@ -246,7 +246,7 @@ public void testReRoute() { StrategyManager strategyManager2 = new StrategyManager(); strategyManager2.addStrategy( strategy2, null, 1.0 ); - config.controler().setOutputDirectory(testUtils.getOutputDirectory() + "/run2/"); + config.controller().setOutputDirectory(testUtils.getOutputDirectory() + "/run2/"); TestControler controler2 = new TestControler(config, strategyManager2); strategy2.addStrategyModule(new ReRoute(controler2.getScenario(), TripRouterFactoryBuilderWithDefaults.createDefaultTripRouterFactoryImpl(controler2.getScenario()), TimeInterpretation.create(config))); controler2.run(); @@ -283,9 +283,9 @@ public TestControler(final Config config, final StrategyManager manager) { public TestControler(final Scenario scenario, final StrategyManager manager) { controler = new Controler( scenario ) ; - controler.getConfig().controler().setCreateGraphs(false); - controler.getConfig().controler().setWriteEventsInterval(1); - controler.getConfig().controler().setDumpDataAtEnd(false); + controler.getConfig().controller().setCreateGraphs(false); + controler.getConfig().controller().setWriteEventsInterval(1); + controler.getConfig().controller().setDumpDataAtEnd(false); this.manager = manager ; controler.addOverridingModule(new AbstractModule() { @Override diff --git a/matsim/src/test/java/org/matsim/core/replanning/strategies/InnovationSwitchOffTest.java b/matsim/src/test/java/org/matsim/core/replanning/strategies/InnovationSwitchOffTest.java index 2990671c8f6..9c81aee55f2 100644 --- a/matsim/src/test/java/org/matsim/core/replanning/strategies/InnovationSwitchOffTest.java +++ b/matsim/src/test/java/org/matsim/core/replanning/strategies/InnovationSwitchOffTest.java @@ -64,7 +64,7 @@ public class InnovationSwitchOffTest { @Test public void testInnovationSwitchOff() { Config config = ConfigUtils.createConfig(ExamplesUtils.getTestScenarioURL("equil")); - config.controler().setOutputDirectory(this.utils.getOutputDirectory()); + config.controller().setOutputDirectory(this.utils.getOutputDirectory()); config.network().setInputFile("network.xml"); config.plans().setInputFile("plans2.xml"); @@ -73,44 +73,44 @@ public void testInnovationSwitchOff() { StrategySettings settings = new StrategySettings(Id.create(1, StrategySettings.class)); settings.setStrategyName(DefaultPlanStrategiesModule.DefaultSelector.BestScore.toString()); settings.setWeight(0.5); - config.strategy().addStrategySettings(settings); + config.replanning().addStrategySettings(settings); } { StrategySettings settings = new StrategySettings(Id.create(2, StrategySettings.class)); settings.setStrategyName(DefaultPlanStrategiesModule.DefaultSelector.ChangeExpBeta.toString()); settings.setWeight(0.5); - config.strategy().addStrategySettings(settings); + config.replanning().addStrategySettings(settings); } { StrategySettings settings = new StrategySettings(Id.create(3, StrategySettings.class)); settings.setStrategyName(DefaultPlanStrategiesModule.DefaultStrategy.TimeAllocationMutator.toString()); settings.setWeight(0.1); - config.strategy().addStrategySettings(settings); + config.replanning().addStrategySettings(settings); } { StrategySettings settings = new StrategySettings(Id.create(4, StrategySettings.class)); settings.setStrategyName(DefaultPlanStrategiesModule.DefaultStrategy.ReRoute.toString()); settings.setWeight(0.1); settings.setDisableAfter(11); - config.strategy().addStrategySettings(settings); + config.replanning().addStrategySettings(settings); } - config.strategy().setFractionOfIterationsToDisableInnovation(0.66); + config.replanning().setFractionOfIterationsToDisableInnovation(0.66); - config.controler().setFirstIteration(10); - config.controler().setLastIteration(16); + config.controller().setFirstIteration(10); + config.controller().setLastIteration(16); { ActivityParams params = new ActivityParams("h"); params.setTypicalDuration(12. * 3600.); - config.planCalcScore().addActivityParams(params); + config.scoring().addActivityParams(params); } { ActivityParams params = new ActivityParams("w"); params.setTypicalDuration(8. * 3600.); - config.planCalcScore().addActivityParams(params); + config.scoring().addActivityParams(params); } - config.controler().setCreateGraphs(false); + config.controller().setCreateGraphs(false); com.google.inject.Injector injector = Injector.createInjector(config, new AbstractModule() { diff --git a/matsim/src/test/java/org/matsim/core/router/FallbackRoutingModuleTest.java b/matsim/src/test/java/org/matsim/core/router/FallbackRoutingModuleTest.java index c0e333894a7..2357da20138 100644 --- a/matsim/src/test/java/org/matsim/core/router/FallbackRoutingModuleTest.java +++ b/matsim/src/test/java/org/matsim/core/router/FallbackRoutingModuleTest.java @@ -33,13 +33,13 @@ public class FallbackRoutingModuleTest{ public void calcRoute(){ Config config = ConfigUtils.createConfig(); - config.controler().setOutputDirectory( utils.getOutputDirectory() ); - config.controler().setLastIteration( 1 ); + config.controller().setOutputDirectory( utils.getOutputDirectory() ); + config.controller().setLastIteration( 1 ); ReplanningConfigGroup.StrategySettings sets = new ReplanningConfigGroup.StrategySettings(); sets.setStrategyName( DefaultPlanStrategiesModule.DefaultStrategy.ReRoute ); sets.setWeight( 1. ); - config.strategy().addStrategySettings( sets ); + config.replanning().addStrategySettings( sets ); Scenario scenario = ScenarioUtils.createScenario( config ); diff --git a/matsim/src/test/java/org/matsim/core/router/NetworkRoutingInclAccessEgressModuleTest.java b/matsim/src/test/java/org/matsim/core/router/NetworkRoutingInclAccessEgressModuleTest.java index 690cb4fed27..6f53a8f7363 100644 --- a/matsim/src/test/java/org/matsim/core/router/NetworkRoutingInclAccessEgressModuleTest.java +++ b/matsim/src/test/java/org/matsim/core/router/NetworkRoutingInclAccessEgressModuleTest.java @@ -103,24 +103,24 @@ private Config createConfig() { Config config = ConfigUtils.createConfig(); config.qsim().setUsePersonIdForMissingVehicleId(true); - config.controler().setFirstIteration(0); - config.controler().setLastIteration(0); - config.controler().setOutputDirectory(utils.getOutputDirectory()); - config.controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles); - config.plansCalcRoute().setAccessEgressType(RoutingConfigGroup.AccessEgressType.accessEgressModeToLink); + config.controller().setFirstIteration(0); + config.controller().setLastIteration(0); + config.controller().setOutputDirectory(utils.getOutputDirectory()); + config.controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles); + config.routing().setAccessEgressType(RoutingConfigGroup.AccessEgressType.accessEgressModeToLink); final ScoringConfigGroup.ActivityParams homeParams = new ScoringConfigGroup.ActivityParams("home"); homeParams.setTypicalDuration(1); - config.planCalcScore().addActivityParams(homeParams); + config.scoring().addActivityParams(homeParams); final ScoringConfigGroup.ActivityParams workParams = new ScoringConfigGroup.ActivityParams("work"); workParams.setTypicalDuration(1); - config.planCalcScore().addActivityParams(workParams); + config.scoring().addActivityParams(workParams); ReplanningConfigGroup.StrategySettings replanning = new ReplanningConfigGroup.StrategySettings(); replanning.setStrategyName("ReRoute"); replanning.setWeight(1.0); - config.strategy().addStrategySettings(replanning); + config.replanning().addStrategySettings(replanning); return config; } @@ -187,8 +187,8 @@ public void calcRoute_modeVehiclesFromVehiclesData_differentTypesTakeDifferentRo config.qsim().setVehiclesSource(QSimConfigGroup.VehiclesSource.modeVehicleTypesFromVehiclesData); config.qsim().setMainModes(modes); - config.plansCalcRoute().setNetworkModes(modes); - ScoringConfigGroup scoring = config.planCalcScore(); + config.routing().setNetworkModes(modes); + ScoringConfigGroup scoring = config.scoring(); ScoringConfigGroup.ModeParams slowParams = new ScoringConfigGroup.ModeParams(SLOW_MODE); slowParams.setMarginalUtilityOfTraveling(-1); @@ -263,7 +263,7 @@ public void useAccessEgressTimeFromLinkAttributes() { Config config = createConfig(); config.qsim().setVehiclesSource(QSimConfigGroup.VehiclesSource.defaultVehicle); - config.plansCalcRoute().setAccessEgressType(RoutingConfigGroup.AccessEgressType.walkConstantTimeToLink); + config.routing().setAccessEgressType(RoutingConfigGroup.AccessEgressType.walkConstantTimeToLink); Scenario scenario = createScenario(config); NetworkUtils.setLinkAccessTime(scenario.getNetwork().getLinks().get(Id.createLinkId(START_LINK)),TransportMode.car,75); NetworkUtils.setLinkEgressTime(scenario.getNetwork().getLinks().get(Id.createLinkId(END_LINK)),TransportMode.car,180); @@ -284,7 +284,7 @@ public void useAccessEgressTimeFromConstantAndWalkTime() { Config config = createConfig(); config.qsim().setVehiclesSource(QSimConfigGroup.VehiclesSource.defaultVehicle); - config.plansCalcRoute().setAccessEgressType(RoutingConfigGroup.AccessEgressType.accessEgressModeToLinkPlusTimeConstant); + config.routing().setAccessEgressType(RoutingConfigGroup.AccessEgressType.accessEgressModeToLinkPlusTimeConstant); Scenario scenario = createScenario(config); NetworkUtils.setLinkAccessTime(scenario.getNetwork().getLinks().get(Id.createLinkId(START_LINK)),TransportMode.car,75); NetworkUtils.setLinkEgressTime(scenario.getNetwork().getLinks().get(Id.createLinkId(END_LINK)),TransportMode.car,180); @@ -307,7 +307,7 @@ public void routingModeInEvents() { Config config = createConfig(); config.qsim().setVehiclesSource(QSimConfigGroup.VehiclesSource.defaultVehicle); - config.plansCalcRoute().setAccessEgressType(RoutingConfigGroup.AccessEgressType.accessEgressModeToLinkPlusTimeConstant); + config.routing().setAccessEgressType(RoutingConfigGroup.AccessEgressType.accessEgressModeToLinkPlusTimeConstant); Scenario scenario = createScenario(config); NetworkUtils.setLinkAccessTime(scenario.getNetwork().getLinks().get(Id.createLinkId(START_LINK)),TransportMode.car,75); NetworkUtils.setLinkEgressTime(scenario.getNetwork().getLinks().get(Id.createLinkId(END_LINK)),TransportMode.car,180); @@ -349,7 +349,7 @@ public void failifNoAccessTimeSet() { Config config = createConfig(); config.qsim().setVehiclesSource(QSimConfigGroup.VehiclesSource.defaultVehicle); - config.plansCalcRoute().setAccessEgressType(RoutingConfigGroup.AccessEgressType.walkConstantTimeToLink); + config.routing().setAccessEgressType(RoutingConfigGroup.AccessEgressType.walkConstantTimeToLink); Scenario scenario = createScenario(config); NetworkUtils.setLinkAccessTime(scenario.getNetwork().getLinks().get(Id.createLinkId(START_LINK)),TransportMode.car,75); Person person = createPerson("slow-person", TransportMode.car, scenario.getPopulation().getFactory()); @@ -364,7 +364,7 @@ public void failifNoEgressTimeSet() { Config config = createConfig(); config.qsim().setVehiclesSource(QSimConfigGroup.VehiclesSource.defaultVehicle); - config.plansCalcRoute().setAccessEgressType(AccessEgressType.walkConstantTimeToLink); + config.routing().setAccessEgressType(AccessEgressType.walkConstantTimeToLink); Scenario scenario = createScenario(config); NetworkUtils.setLinkEgressTime(scenario.getNetwork().getLinks().get(Id.createLinkId(END_LINK)),TransportMode.car,180); Person person = createPerson("slow-person", TransportMode.car, scenario.getPopulation().getFactory()); @@ -378,7 +378,7 @@ public void calcAccessTimeFromDistanceToLink() { Config config = createConfig(); config.qsim().setVehiclesSource(QSimConfigGroup.VehiclesSource.defaultVehicle); - config.plansCalcRoute().setAccessEgressType(RoutingConfigGroup.AccessEgressType.accessEgressModeToLink); + config.routing().setAccessEgressType(RoutingConfigGroup.AccessEgressType.accessEgressModeToLink); Scenario scenario = createScenario(config); NetworkUtils.setLinkAccessTime(scenario.getNetwork().getLinks().get(Id.createLinkId(START_LINK)),TransportMode.car,75); NetworkUtils.setLinkAccessTime(scenario.getNetwork().getLinks().get(Id.createLinkId(END_LINK)),TransportMode.car,180); @@ -403,7 +403,7 @@ public void noBushwackingLegs() { Config config = createConfig(); config.qsim().setVehiclesSource(QSimConfigGroup.VehiclesSource.defaultVehicle); - config.plansCalcRoute().setAccessEgressType(AccessEgressType.none); + config.routing().setAccessEgressType(AccessEgressType.none); Scenario scenario = createScenario(config); NetworkUtils.setLinkAccessTime(scenario.getNetwork().getLinks().get(Id.createLinkId(START_LINK)),TransportMode.car,75); NetworkUtils.setLinkAccessTime(scenario.getNetwork().getLinks().get(Id.createLinkId(END_LINK)),TransportMode.car,180); diff --git a/matsim/src/test/java/org/matsim/core/router/NetworkRoutingModuleTest.java b/matsim/src/test/java/org/matsim/core/router/NetworkRoutingModuleTest.java index 465af0ffb00..ac63754fd20 100644 --- a/matsim/src/test/java/org/matsim/core/router/NetworkRoutingModuleTest.java +++ b/matsim/src/test/java/org/matsim/core/router/NetworkRoutingModuleTest.java @@ -85,7 +85,7 @@ public void testRouteLegWithDistance() { fromAct.setLinkId(Id.create("1", Link.class)); Activity toAct = PopulationUtils.createActivityFromCoord("h", new Coord(0, 3000)); toAct.setLinkId(Id.create("3", Link.class)); - + TravelTime timeObject = TravelTimeCalculator.create(f.s.getNetwork(), f.s.getConfig().travelTimeCalculator()).getLinkTravelTimes() ; { @@ -113,10 +113,10 @@ public void testRouteLegWithDistance() { Assert.assertEquals(0.3333333333, route.getTravelCost(), 1e-8 ) ; } // and now with a monetary distance rate different from zero: - + { double monetaryDistanceRateCar = -1.; - f.s.getConfig().planCalcScore().getModes().get(TransportMode.car).setMonetaryDistanceRate(monetaryDistanceRateCar); + f.s.getConfig().scoring().getModes().get(TransportMode.car).setMonetaryDistanceRate(monetaryDistanceRateCar); TravelDisutility costObject = new RandomizingTimeDistanceTravelDisutilityFactory( TransportMode.car, f.s.getConfig() ).createTravelDisutility(timeObject ); @@ -132,8 +132,8 @@ public void testRouteLegWithDistance() { List result = router.calcRoute( DefaultRoutingRequest.withoutAttributes( FacilitiesUtils.toFacility(fromAct, f.s.getActivityFacilities() ), FacilitiesUtils.toFacility(toAct, f.s.getActivityFacilities() ), 7.*3600, person ) ) ; - - Assert.assertEquals( 1, result.size() ) ; + + Assert.assertEquals( 1, result.size() ) ; Leg leg = (Leg) result.get(0) ; Assert.assertEquals(100.0, leg.getTravelTime().seconds(), 1e-8); @@ -148,7 +148,7 @@ private static class Fixture { public final Scenario s = ScenarioUtils.createScenario(ConfigUtils.createConfig()); Fixture() { - s.getConfig().plansCalcRoute().setRoutingRandomness( 0. ); + s.getConfig().routing().setRoutingRandomness( 0. ); Network net = this.s.getNetwork(); NetworkFactory nf = net.getFactory(); diff --git a/matsim/src/test/java/org/matsim/core/router/PseudoTransitRoutingModuleTest.java b/matsim/src/test/java/org/matsim/core/router/PseudoTransitRoutingModuleTest.java index 4ebffe620d6..eeb366c2f68 100644 --- a/matsim/src/test/java/org/matsim/core/router/PseudoTransitRoutingModuleTest.java +++ b/matsim/src/test/java/org/matsim/core/router/PseudoTransitRoutingModuleTest.java @@ -103,8 +103,8 @@ public void testRouteLeg() { params.setTeleportedModeFreespeedFactor(2.); params.setBeelineDistanceFactor(1.); params.setTeleportedModeFreespeedLimit(5.); - f.s.getConfig().plansCalcRoute().addModeRoutingParams(params); - f.s.getConfig().controler().setOutputDirectory(utils.getOutputDirectory()); + f.s.getConfig().routing().addModeRoutingParams(params); + f.s.getConfig().controller().setOutputDirectory(utils.getOutputDirectory()); com.google.inject.Injector injector = Injector.createInjector(f.s.getConfig(), new AbstractModule() { @Override public void install() { @@ -134,11 +134,11 @@ private static class Fixture { public final Scenario s = ScenarioUtils.createScenario(ConfigUtils.createConfig()); public Fixture() { - s.getConfig().controler().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); + s.getConfig().controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); TeleportedModeParams walk = new TeleportedModeParams(TransportMode.walk); walk.setBeelineDistanceFactor(1.3); walk.setTeleportedModeSpeed(3.0 / 3.6); - s.getConfig().plansCalcRoute().addModeRoutingParams(walk); + s.getConfig().routing().addModeRoutingParams(walk); Network net = this.s.getNetwork(); NetworkFactory nf = net.getFactory(); diff --git a/matsim/src/test/java/org/matsim/core/router/RoutingIT.java b/matsim/src/test/java/org/matsim/core/router/RoutingIT.java index a2b33bac4bf..0d1fc62702e 100644 --- a/matsim/src/test/java/org/matsim/core/router/RoutingIT.java +++ b/matsim/src/test/java/org/matsim/core/router/RoutingIT.java @@ -173,7 +173,7 @@ private static void calcRoute( final FreespeedTravelTimeAndDisutility calculator = new FreespeedTravelTimeAndDisutility( - scenario.getConfig().planCalcScore() ); + scenario.getConfig().scoring() ); final LeastCostPathCalculatorFactory factory1 = provider.getFactory( scenario.getNetwork(), calculator, diff --git a/matsim/src/test/java/org/matsim/core/router/TripRouterFactoryImplTest.java b/matsim/src/test/java/org/matsim/core/router/TripRouterFactoryImplTest.java index 5e9d9853808..25948e78d56 100644 --- a/matsim/src/test/java/org/matsim/core/router/TripRouterFactoryImplTest.java +++ b/matsim/src/test/java/org/matsim/core/router/TripRouterFactoryImplTest.java @@ -110,7 +110,7 @@ public void install() { public void install() { install(new ScenarioByInstanceModule(scenario)); install(new TimeInterpretationModule()); - addTravelTimeBinding("car").toInstance(new FreespeedTravelTimeAndDisutility( config.planCalcScore() )); + addTravelTimeBinding("car").toInstance(new FreespeedTravelTimeAndDisutility( config.scoring() )); addTravelDisutilityFactoryBinding("car").toInstance(new OnlyTimeDependentTravelDisutilityFactory()); } })); @@ -130,7 +130,7 @@ public void install() { PopulationUtils.getFactory().createPerson(Id.create("toto", Person.class)), new AttributesImpl()); Leg l = (Leg) trip.get( 0 ); - if ( !scenario.getConfig().plansCalcRoute().getAccessEgressType().equals(RoutingConfigGroup.AccessEgressType.none) ) { + if ( !scenario.getConfig().routing().getAccessEgressType().equals(RoutingConfigGroup.AccessEgressType.none) ) { l = (Leg) trip.get(2) ; } @@ -189,7 +189,7 @@ public void install() { install(AbstractModule.override(Arrays.asList(new TripRouterModule()), new AbstractModule() { @Override public void install() { - addTravelTimeBinding("car").toInstance(new FreespeedTravelTimeAndDisutility( config.planCalcScore() )); + addTravelTimeBinding("car").toInstance(new FreespeedTravelTimeAndDisutility( config.scoring() )); addTravelDisutilityFactoryBinding("car").toInstance(new OnlyTimeDependentTravelDisutilityFactory()); } })); @@ -206,7 +206,7 @@ public void install() { PopulationUtils.getFactory().createPerson(Id.create("toto", Person.class)), new AttributesImpl()); Leg l = (Leg) trip.get( 0 ); - if ( !scenario.getConfig().plansCalcRoute().getAccessEgressType().equals(RoutingConfigGroup.AccessEgressType.none) ) { + if ( !scenario.getConfig().routing().getAccessEgressType().equals(RoutingConfigGroup.AccessEgressType.none) ) { l = (Leg) trip.get(2) ; } diff --git a/matsim/src/test/java/org/matsim/core/router/TripRouterModuleTest.java b/matsim/src/test/java/org/matsim/core/router/TripRouterModuleTest.java index f84b849fac4..4bb4c1df8ed 100644 --- a/matsim/src/test/java/org/matsim/core/router/TripRouterModuleTest.java +++ b/matsim/src/test/java/org/matsim/core/router/TripRouterModuleTest.java @@ -45,7 +45,7 @@ public class TripRouterModuleTest { public void testRouterCreation() { for (ControllerConfigGroup.RoutingAlgorithmType routingAlgorithmType : ControllerConfigGroup.RoutingAlgorithmType.values()) { Config config = ConfigUtils.createConfig(); - config.controler().setRoutingAlgorithmType(routingAlgorithmType); + config.controller().setRoutingAlgorithmType(routingAlgorithmType); Scenario scenario = ScenarioUtils.createScenario(config); LeastCostPathCalculatorFactory defaultLeastCostPathCalculatorFactory = TripRouterFactoryBuilderWithDefaults.createDefaultLeastCostPathCalculatorFactory(scenario); LeastCostPathCalculator pathCalculator = defaultLeastCostPathCalculatorFactory.createPathCalculator( diff --git a/matsim/src/test/java/org/matsim/core/router/costcalculators/RandomizingTimeDistanceTravelDisutilityTest.java b/matsim/src/test/java/org/matsim/core/router/costcalculators/RandomizingTimeDistanceTravelDisutilityTest.java index cb5e6bbfbb6..1cee2106490 100644 --- a/matsim/src/test/java/org/matsim/core/router/costcalculators/RandomizingTimeDistanceTravelDisutilityTest.java +++ b/matsim/src/test/java/org/matsim/core/router/costcalculators/RandomizingTimeDistanceTravelDisutilityTest.java @@ -84,11 +84,11 @@ public NetworkRoute computeRoute(double sigma) { Fixture f = new Fixture(); // PlanCalcScoreConfigGroup planCalcScoreCfg = new PlanCalcScoreConfigGroup(); Config config = ConfigUtils.createConfig(); - ScoringConfigGroup planCalcScoreCfg = config.planCalcScore(); + ScoringConfigGroup planCalcScoreCfg = config.scoring(); ModeParams modeParams = new ModeParams(TransportMode.car); modeParams.setMonetaryDistanceRate(-0.1); planCalcScoreCfg.addModeParams(modeParams); - config.plansCalcRoute().setRoutingRandomness( sigma ); + config.routing().setRoutingRandomness( sigma ); RandomizingTimeDistanceTravelDisutilityFactory factory = new RandomizingTimeDistanceTravelDisutilityFactory(TransportMode.car, config); TravelTimeCalculator.Builder builder = new TravelTimeCalculator.Builder(f.s.getNetwork()); diff --git a/matsim/src/test/java/org/matsim/core/router/old/PlanRouterTest.java b/matsim/src/test/java/org/matsim/core/router/old/PlanRouterTest.java index 8663820a80c..511a141c8a2 100644 --- a/matsim/src/test/java/org/matsim/core/router/old/PlanRouterTest.java +++ b/matsim/src/test/java/org/matsim/core/router/old/PlanRouterTest.java @@ -69,7 +69,7 @@ public void install() { install(new TripRouterModule()); install(new ScenarioByInstanceModule(scenario)); install(new TimeInterpretationModule()); - addTravelTimeBinding("car").toInstance(new FreespeedTravelTimeAndDisutility(config.planCalcScore())); + addTravelTimeBinding("car").toInstance(new FreespeedTravelTimeAndDisutility(config.scoring())); addTravelDisutilityFactoryBinding("car").toInstance(new OnlyTimeDependentTravelDisutilityFactory()); } }); @@ -80,7 +80,7 @@ public void install() { ((NetworkRoute) TripStructureUtils.getLegs(plan).get(0).getRoute()).setVehicleId(vehicleId); testee.run(plan); - if ( config.plansCalcRoute().getAccessEgressType().equals(RoutingConfigGroup.AccessEgressType.none) ) { + if ( config.routing().getAccessEgressType().equals(RoutingConfigGroup.AccessEgressType.none) ) { Assert.assertEquals("Vehicle Id transferred to new Plan", vehicleId, ((NetworkRoute) TripStructureUtils.getLegs(plan).get(0).getRoute()).getVehicleId()); } else { Assert.assertEquals("Vehicle Id transferred to new Plan", vehicleId, ((NetworkRoute) TripStructureUtils.getLegs(plan).get(1).getRoute()).getVehicleId()); @@ -127,7 +127,7 @@ public void install() { install(AbstractModule.override(Arrays.asList(new TripRouterModule()), new AbstractModule() { @Override public void install() { - addTravelTimeBinding("car").toInstance(new FreespeedTravelTimeAndDisutility(config.planCalcScore())); + addTravelTimeBinding("car").toInstance(new FreespeedTravelTimeAndDisutility(config.scoring())); addTravelDisutilityFactoryBinding("car").toInstance(new OnlyTimeDependentTravelDisutilityFactory()); addRoutingModuleBinding("car").toInstance( routingModule ); } @@ -138,7 +138,7 @@ public void install() { PlanRouter testee = new PlanRouter(tripRouter, TimeInterpretation.create(config)); testee.run(plan); - if ( config.plansCalcRoute().getAccessEgressType().equals(RoutingConfigGroup.AccessEgressType.none) ) { + if ( config.routing().getAccessEgressType().equals(RoutingConfigGroup.AccessEgressType.none) ) { Assert.assertEquals("Vehicle Id from TripRouter used", newVehicleId, ((NetworkRoute) TripStructureUtils.getLegs(plan).get(0).getRoute()).getVehicleId()); } else { Assert.assertEquals("Vehicle Id from TripRouter used", newVehicleId, ((NetworkRoute) TripStructureUtils.getLegs(plan).get(1).getRoute()).getVehicleId()); diff --git a/matsim/src/test/java/org/matsim/core/scoring/EventsToScoreTest.java b/matsim/src/test/java/org/matsim/core/scoring/EventsToScoreTest.java index 4cdae60bc9a..48fabecebed 100644 --- a/matsim/src/test/java/org/matsim/core/scoring/EventsToScoreTest.java +++ b/matsim/src/test/java/org/matsim/core/scoring/EventsToScoreTest.java @@ -70,12 +70,12 @@ public class EventsToScoreTest { @Test public void testMsaAveraging() { Config config = ConfigUtils.createConfig() ; - config.controler().setFirstIteration(10); - config.controler().setLastIteration(110); + config.controller().setFirstIteration(10); + config.controller().setLastIteration(110); - config.planCalcScore().setMarginalUtilityOfMoney(1.); + config.scoring().setMarginalUtilityOfMoney(1.); - config.planCalcScore().setFractionOfIterationsToStartScoreMSA(0.9); + config.scoring().setFractionOfIterationsToStartScoreMSA(0.9); Scenario scenario = ScenarioUtils.createScenario(config); Population population = scenario.getPopulation(); @@ -88,7 +88,7 @@ public class EventsToScoreTest { EventsManager events = EventsUtils.createEventsManager(); EventsToScore e2s = EventsToScore.createWithScoreUpdating(scenario, sfFactory, events); - for ( int mockIteration = config.controler().getFirstIteration() ; mockIteration <= config.controler().getLastIteration() ; mockIteration++ ) { + for (int mockIteration = config.controller().getFirstIteration(); mockIteration <= config.controller().getLastIteration() ; mockIteration++ ) { e2s.beginIteration(mockIteration, false); ; events.initProcessing(); diff --git a/matsim/src/test/java/org/matsim/core/scoring/ScoringFunctionsForPopulationStressIT.java b/matsim/src/test/java/org/matsim/core/scoring/ScoringFunctionsForPopulationStressIT.java index 5732d92827e..30f51ac024c 100644 --- a/matsim/src/test/java/org/matsim/core/scoring/ScoringFunctionsForPopulationStressIT.java +++ b/matsim/src/test/java/org/matsim/core/scoring/ScoringFunctionsForPopulationStressIT.java @@ -132,26 +132,26 @@ public void handleEvent(Event event) { @Test public void workWithNewEventsManager() { Config config = ConfigUtils.createConfig(); - config.parallelEventHandling().setOneThreadPerHandler(true); + config.eventsManager().setOneThreadPerHandler(true); work(config); } @Test public void workWithOldEventsManager() { Config config = ConfigUtils.createConfig(); - config.parallelEventHandling().setNumberOfThreads(8); + config.eventsManager().setNumberOfThreads(8); work(config); } private void work(Config config) { ScoringConfigGroup.ActivityParams work = new ScoringConfigGroup.ActivityParams("work"); work.setTypicalDuration(100.0); - config.planCalcScore().addActivityParams(work); + config.scoring().addActivityParams(work); ScoringConfigGroup.ModeParams car = new ScoringConfigGroup.ModeParams("car"); car.setMarginalUtilityOfTraveling(0.0); car.setMarginalUtilityOfDistance(0.0); car.setConstant(-1.0); - config.planCalcScore().addModeParams(car); + config.scoring().addModeParams(car); final Scenario scenario = ScenarioUtils.createScenario(config); Id personId = Id.createPersonId(1); scenario.getPopulation().addPerson(scenario.getPopulation().getFactory().createPerson(personId)); @@ -251,17 +251,17 @@ so this tests actually tests some additional (and potentially optional) behavior @Test @Ignore public void unlikelyTimingOfScoringFunctionStillWorks() { Config config = ConfigUtils.createConfig(); - config.parallelEventHandling().setNumberOfThreads(8); - config.parallelEventHandling().setOneThreadPerHandler(true); - config.parallelEventHandling().setSynchronizeOnSimSteps(false); + config.eventsManager().setNumberOfThreads(8); + config.eventsManager().setOneThreadPerHandler(true); + config.eventsManager().setSynchronizeOnSimSteps(false); ScoringConfigGroup.ActivityParams work = new ScoringConfigGroup.ActivityParams("work"); work.setTypicalDuration(100.0); - config.planCalcScore().addActivityParams(work); + config.scoring().addActivityParams(work); ScoringConfigGroup.ModeParams car = new ScoringConfigGroup.ModeParams("car"); car.setMarginalUtilityOfTraveling(0.0); car.setMarginalUtilityOfDistance(0.0); car.setConstant(-1.0); - config.planCalcScore().addModeParams(car); + config.scoring().addModeParams(car); final Scenario scenario = ScenarioUtils.createScenario(config); Id personId = Id.createPersonId(1); scenario.getPopulation().addPerson(scenario.getPopulation().getFactory().createPerson(personId)); diff --git a/matsim/src/test/java/org/matsim/core/scoring/functions/CharyparNagelScoringFunctionTest.java b/matsim/src/test/java/org/matsim/core/scoring/functions/CharyparNagelScoringFunctionTest.java index 346efae54ec..53358733184 100644 --- a/matsim/src/test/java/org/matsim/core/scoring/functions/CharyparNagelScoringFunctionTest.java +++ b/matsim/src/test/java/org/matsim/core/scoring/functions/CharyparNagelScoringFunctionTest.java @@ -190,10 +190,10 @@ public void testZero() { public void testTravelingAndConstantCar() { Fixture f = new Fixture(); final double traveling = -6.0; - f.config.planCalcScore().getModes().get(TransportMode.car).setMarginalUtilityOfTraveling(traveling); + f.config.scoring().getModes().get(TransportMode.car).setMarginalUtilityOfTraveling(traveling); assertEquals(-3.0, calcScore(f), EPSILON); double constantCar = -6.0; - f.config.planCalcScore().getModes().get(TransportMode.car).setConstant(constantCar); + f.config.scoring().getModes().get(TransportMode.car).setConstant(constantCar); assertEquals(-9.0, calcScore(f), EPSILON); } @@ -201,10 +201,10 @@ public void testTravelingAndConstantCar() { public void testTravelingPtAndConstantPt() { Fixture f = new Fixture(); final double travelingPt = -9.0; - f.config.planCalcScore().getModes().get(TransportMode.pt).setMarginalUtilityOfTraveling(travelingPt); + f.config.scoring().getModes().get(TransportMode.pt).setMarginalUtilityOfTraveling(travelingPt); assertEquals(-2.25, calcScore(f), EPSILON); double constantPt = -3.0; - f.config.planCalcScore().getModes().get(TransportMode.pt).setConstant(constantPt); + f.config.scoring().getModes().get(TransportMode.pt).setConstant(constantPt); assertEquals(-5.25, calcScore(f), EPSILON); } @@ -212,10 +212,10 @@ public void testTravelingPtAndConstantPt() { public void testTravelingWalkAndConstantWalk() { Fixture f = new Fixture(); final double travelingWalk = -18.0; - f.config.planCalcScore().getModes().get(TransportMode.walk).setMarginalUtilityOfTraveling(travelingWalk); + f.config.scoring().getModes().get(TransportMode.walk).setMarginalUtilityOfTraveling(travelingWalk); assertEquals(-9.0, calcScore(f), EPSILON ) ; double constantWalk = -1.0; - f.config.planCalcScore().getModes().get(TransportMode.walk).setConstant(constantWalk); + f.config.scoring().getModes().get(TransportMode.walk).setConstant(constantWalk); assertEquals(-10.0, calcScore(f), EPSILON); } @@ -223,10 +223,10 @@ public void testTravelingWalkAndConstantWalk() { public void testTravelingBikeAndConstantBike(){ Fixture f = new Fixture(); final double travelingBike = -6.0; - f.config.planCalcScore().getModes().get(TransportMode.bike).setMarginalUtilityOfTraveling(travelingBike); + f.config.scoring().getModes().get(TransportMode.bike).setMarginalUtilityOfTraveling(travelingBike); assertEquals(-1.5, calcScore(f), EPSILON ) ; double constantBike = -2.0; - f.config.planCalcScore().getModes().get(TransportMode.bike).setConstant(constantBike); + f.config.scoring().getModes().get(TransportMode.bike).setConstant(constantBike); assertEquals(-3.5, calcScore(f), EPSILON); } @@ -241,10 +241,10 @@ public void testPerforming() { double zeroUtilDurW = getZeroUtilDuration_hrs(3.0, 1.0); double zeroUtilDurH = getZeroUtilDuration_hrs(15.0, 1.0); - f.config.planCalcScore().setPerforming_utils_hr(perf); + f.config.scoring().setPerforming_utils_hr(perf); if(typicalDurationComputation.equals(TypicalDurationScoreComputation.uniform)){ - for(ActivityParams p : f.config.planCalcScore().getActivityParams()){ + for(ActivityParams p : f.config.scoring().getActivityParams()){ p.setTypicalDurationScoreComputation(TypicalDurationScoreComputation.uniform); } } @@ -269,10 +269,10 @@ public void testPerforming() { public void testOpeningTime() { Fixture f = new Fixture(); double perf = +6.0; - f.config.planCalcScore().setPerforming_utils_hr(perf); + f.config.scoring().setPerforming_utils_hr(perf); double initialScore = calcScore(f); - ActivityParams wParams = f.config.planCalcScore().getActivityParams("w"); + ActivityParams wParams = f.config.scoring().getActivityParams("w"); wParams.setOpeningTime(8*3600.0); // now the agent arrives 30min early to the FIRST work activity and has to wait double score = calcScore(f); @@ -287,10 +287,10 @@ public void testOpeningTime() { public void testClosingTime() { Fixture f = new Fixture(); double perf = +6.0; - f.config.planCalcScore().setPerforming_utils_hr(perf); + f.config.scoring().setPerforming_utils_hr(perf); double initialScore = calcScore(f); - ActivityParams wParams = f.config.planCalcScore().getActivityParams("w"); + ActivityParams wParams = f.config.scoring().getActivityParams("w"); wParams.setClosingTime(15*3600.0); // now the agent stays 1h too long at the LAST work activity double score = calcScore(f); @@ -305,10 +305,10 @@ public void testClosingTime() { public void testOpeningClosingTime() { Fixture f = new Fixture(); double perf_hrs = +6.0; - f.config.planCalcScore().setPerforming_utils_hr(perf_hrs); + f.config.scoring().setPerforming_utils_hr(perf_hrs); if(typicalDurationComputation.equals(TypicalDurationScoreComputation.uniform)){ - for(ActivityParams p : f.config.planCalcScore().getActivityParams()){ + for(ActivityParams p : f.config.scoring().getActivityParams()){ p.setTypicalDurationScoreComputation(TypicalDurationScoreComputation.uniform); } } @@ -317,7 +317,7 @@ public void testOpeningClosingTime() { // test1: agents has to wait before and after - ActivityParams wParams = f.config.planCalcScore().getActivityParams("w"); + ActivityParams wParams = f.config.scoring().getActivityParams("w"); wParams.setOpeningTime( 8*3600.0); // the agent arrives 30min early wParams.setClosingTime(15*3600.0); // the agent stays 1h too long double score = calcScore(f); @@ -369,9 +369,9 @@ public void testOpeningClosingTime() { public void testWaitingTime() { Fixture f = new Fixture(); double waiting = -10.0; - f.config.planCalcScore().setMarginalUtlOfWaiting_utils_hr(waiting); + f.config.scoring().setMarginalUtlOfWaiting_utils_hr(waiting); - ActivityParams wParams = f.config.planCalcScore().getActivityParams("w"); + ActivityParams wParams = f.config.scoring().getActivityParams("w"); wParams.setOpeningTime( 8*3600.0); // the agent arrives 30min early wParams.setClosingTime(15*3600.0); // the agent stays 1h too long @@ -386,9 +386,9 @@ public void testWaitingTime() { public void testEarlyDeparture() { Fixture f = new Fixture(); double disutility = -10.0; - f.config.planCalcScore().setEarlyDeparture_utils_hr(disutility); + f.config.scoring().setEarlyDeparture_utils_hr(disutility); - ActivityParams wParams = f.config.planCalcScore().getActivityParams("w"); + ActivityParams wParams = f.config.scoring().getActivityParams("w"); wParams.setEarliestEndTime(10.75 * 3600.0); // require the agent to work until 16:45 // the agent left 45mins too early @@ -402,9 +402,9 @@ public void testEarlyDeparture() { public void testMinimumDuration() { Fixture f = new Fixture(); double disutility = -10.0; - f.config.planCalcScore().setEarlyDeparture_utils_hr(disutility); + f.config.scoring().setEarlyDeparture_utils_hr(disutility); - ActivityParams wParams = f.config.planCalcScore().getActivityParams("w"); + ActivityParams wParams = f.config.scoring().getActivityParams("w"); wParams.setMinimalDuration(3 * 3600.0); // require the agent to be 3 hours at every working activity // the agent overall works 1.25h too short @@ -418,9 +418,9 @@ public void testMinimumDuration() { public void testLateArrival() { Fixture f = new Fixture(); double disutility = -10.0; - f.config.planCalcScore().setLateArrival_utils_hr(disutility); + f.config.scoring().setLateArrival_utils_hr(disutility); - ActivityParams wParams = f.config.planCalcScore().getActivityParams("w"); + ActivityParams wParams = f.config.scoring().getActivityParams("w"); wParams.setLatestStartTime(13 * 3600.0); // agent should start working latest at 13 o'clock // the agent arrived 30mins late @@ -435,9 +435,9 @@ public void testLateArrival() { public void testStuckPenalty() { Fixture f = new Fixture(); // test 1 where late arrival has the biggest impact - f.config.planCalcScore().setLateArrival_utils_hr(-18.0); + f.config.scoring().setLateArrival_utils_hr(-18.0); final double traveling1 = -6.0; - f.config.planCalcScore().getModes().get(TransportMode.car).setMarginalUtilityOfTraveling(traveling1); + f.config.scoring().getModes().get(TransportMode.car).setMarginalUtilityOfTraveling(traveling1); ScoringFunction testee = getScoringFunctionInstance(f, f.person); testee.handleActivity((Activity) f.plan.getPlanElements().get(0)); @@ -452,9 +452,9 @@ public void testStuckPenalty() { assertEquals(24 * -18.0 - 6.0 * 0.50, testee.getScore(), EPSILON); // stuck penalty + 30min traveling // test 2 where traveling has the biggest impact - f.config.planCalcScore().setLateArrival_utils_hr(-3.0); + f.config.scoring().setLateArrival_utils_hr(-3.0); final double traveling = -6.0; - f.config.planCalcScore().getModes().get(TransportMode.car).setMarginalUtilityOfTraveling(traveling); + f.config.scoring().getModes().get(TransportMode.car).setMarginalUtilityOfTraveling(traveling); testee = getScoringFunctionInstance(f, f.person); testee.handleActivity((Activity) f.plan.getPlanElements().get(0)); @@ -472,17 +472,17 @@ public void testStuckPenalty() { public void testDistanceCostScoringCar() { Fixture f = new Fixture(); // test 1 where marginalUtitityOfMoney is fixed to 1.0 - f.config.planCalcScore().setMarginalUtilityOfMoney(1.0); + f.config.scoring().setMarginalUtilityOfMoney(1.0); // this.config.charyparNagelScoring().setMarginalUtlOfDistanceCar(-0.00001); double monetaryDistanceRateCar1 = -0.00001; - f.config.planCalcScore().getModes().get(TransportMode.car).setMonetaryDistanceRate(monetaryDistanceRateCar1); + f.config.scoring().getModes().get(TransportMode.car).setMonetaryDistanceRate(monetaryDistanceRateCar1); assertEquals(-0.25, calcScore(f), EPSILON); // test 2 where MonetaryDistanceCostRate is fixed to -1.0 double monetaryDistanceRateCar = -1.0; - f.config.planCalcScore().getModes().get(TransportMode.car).setMonetaryDistanceRate(monetaryDistanceRateCar); - f.config.planCalcScore().setMarginalUtilityOfMoney(0.5); + f.config.scoring().getModes().get(TransportMode.car).setMonetaryDistanceRate(monetaryDistanceRateCar); + f.config.scoring().setMarginalUtilityOfMoney(0.5); assertEquals(-12500.0, calcScore(f), EPSILON); } @@ -491,17 +491,17 @@ public void testDistanceCostScoringCar() { public void testDistanceCostScoringPt() { Fixture f = new Fixture(); // test 1 where marginalUtitityOfMoney is fixed to 1.0 - f.config.planCalcScore().setMarginalUtilityOfMoney(1.0); + f.config.scoring().setMarginalUtilityOfMoney(1.0); // this.config.charyparNagelScoring().setMarginalUtlOfDistancePt(-0.00001); double monetaryDistanceRatePt1 = -0.00001; - f.config.planCalcScore().getModes().get(TransportMode.pt).setMonetaryDistanceRate(monetaryDistanceRatePt1); + f.config.scoring().getModes().get(TransportMode.pt).setMonetaryDistanceRate(monetaryDistanceRatePt1); assertEquals(-0.20, calcScore(f), EPSILON); // test 2 where MonetaryDistanceCostRate is fixed to -1.0 double monetaryDistanceRatePt = -1.0; - f.config.planCalcScore().getModes().get(TransportMode.pt).setMonetaryDistanceRate(monetaryDistanceRatePt); - f.config.planCalcScore().setMarginalUtilityOfMoney(0.5); + f.config.scoring().getModes().get(TransportMode.pt).setMonetaryDistanceRate(monetaryDistanceRatePt); + f.config.scoring().setMarginalUtilityOfMoney(0.5); assertEquals(-10000.0, calcScore(f), EPSILON); } @@ -518,17 +518,17 @@ public void testDifferentFirstLastAct() { ScoringConfigGroup.ActivityParams params = new ScoringConfigGroup.ActivityParams("h2"); params.setTypicalDuration(8*3600); - f.config.planCalcScore().addActivityParams(params); - f.config.planCalcScore().getActivityParams("h").setTypicalDuration(6.0 * 3600); + f.config.scoring().addActivityParams(params); + f.config.scoring().getActivityParams("h").setTypicalDuration(6.0 * 3600); if(typicalDurationComputation.equals(TypicalDurationScoreComputation.uniform)){ - for(ActivityParams p : f.config.planCalcScore().getActivityParams()){ + for(ActivityParams p : f.config.scoring().getActivityParams()){ p.setTypicalDurationScoreComputation(TypicalDurationScoreComputation.uniform); } } double perf = +6.0; - f.config.planCalcScore().setPerforming_utils_hr(perf); + f.config.scoring().setPerforming_utils_hr(perf); double zeroUtilDurW = getZeroUtilDuration_hrs(3.0, 1.0); double zeroUtilDurH = getZeroUtilDuration_hrs(6.0, 1.0); double zeroUtilDurH2 = getZeroUtilDuration_hrs(8.0, 1.0); @@ -558,11 +558,11 @@ public void testNoNightActivity() { // this would amount to a smaller-than-zero expected contribution of // the home activity at 7 hours, and smaller-than-zero contributions // are truncated, so we wouldn't test anything. :-/ - f.config.planCalcScore().getActivityParams("h").setTypicalDuration(7.0 * 3600); - f.config.planCalcScore().setPerforming_utils_hr(perf); + f.config.scoring().getActivityParams("h").setTypicalDuration(7.0 * 3600); + f.config.scoring().setPerforming_utils_hr(perf); if(typicalDurationComputation.equals(TypicalDurationScoreComputation.uniform)){ - for(ActivityParams p : f.config.planCalcScore().getActivityParams()){ + for(ActivityParams p : f.config.scoring().getActivityParams()){ p.setTypicalDurationScoreComputation(TypicalDurationScoreComputation.uniform); } } @@ -681,7 +681,7 @@ public void testUnusualMode() { exception = true ; } assertTrue( exception ) ; - f.config.planCalcScore().addParam("traveling_sackhuepfen", "-30.0"); + f.config.scoring().addParam("traveling_sackhuepfen", "-30.0"); assertEquals(-15.0, calcScore(f), EPSILON); } @@ -717,7 +717,7 @@ public Fixture() { // home 15:15 to ... this.config = ConfigUtils.createConfig(); - ScoringConfigGroup scoring = this.config.planCalcScore(); + ScoringConfigGroup scoring = this.config.scoring(); scoring.setBrainExpBeta(2.0); scoring.getModes().get(TransportMode.car).setConstant(0.0); diff --git a/matsim/src/test/java/org/matsim/core/scoring/functions/CharyparNagelWithSubpopulationsTest.java b/matsim/src/test/java/org/matsim/core/scoring/functions/CharyparNagelWithSubpopulationsTest.java index 5001fcb2bd1..80043ee95e8 100644 --- a/matsim/src/test/java/org/matsim/core/scoring/functions/CharyparNagelWithSubpopulationsTest.java +++ b/matsim/src/test/java/org/matsim/core/scoring/functions/CharyparNagelWithSubpopulationsTest.java @@ -119,7 +119,7 @@ private Scenario createTestScenario() { PopulationUtils.putPersonAttribute( person, "subpopulation", subpop ); final double util = (double) i; - final ScoringParameterSet params = config.planCalcScore().getOrCreateScoringParameters(subpop); + final ScoringParameterSet params = config.scoring().getOrCreateScoringParameters(subpop); params.setMarginalUtlOfWaitingPt_utils_hr(-util); params.setEarlyDeparture_utils_hr(-util); diff --git a/matsim/src/test/java/org/matsim/core/trafficmonitoring/TravelTimeCalculatorModuleTest.java b/matsim/src/test/java/org/matsim/core/trafficmonitoring/TravelTimeCalculatorModuleTest.java index d3e04c32937..7a1b22936cc 100644 --- a/matsim/src/test/java/org/matsim/core/trafficmonitoring/TravelTimeCalculatorModuleTest.java +++ b/matsim/src/test/java/org/matsim/core/trafficmonitoring/TravelTimeCalculatorModuleTest.java @@ -98,7 +98,7 @@ public void testOneTravelTimeCalculatorPerMode() { Config config = ConfigUtils.createConfig(); // config.travelTimeCalculator().setAnalyzedModesAsString("car,bike" ); - config.plansCalcRoute().setNetworkModes( new LinkedHashSet<>( Arrays.asList( TransportMode.car, TransportMode.bike ) ) ); + config.routing().setNetworkModes( new LinkedHashSet<>( Arrays.asList( TransportMode.car, TransportMode.bike ) ) ); // (this is now newly taken from the router network modes. kai, feb'19) config.travelTimeCalculator().setSeparateModes(true); diff --git a/matsim/src/test/java/org/matsim/core/utils/misc/ConfigUtilsTest.java b/matsim/src/test/java/org/matsim/core/utils/misc/ConfigUtilsTest.java index 86c61c5f05b..2b0e176d0bb 100644 --- a/matsim/src/test/java/org/matsim/core/utils/misc/ConfigUtilsTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/misc/ConfigUtilsTest.java @@ -91,7 +91,7 @@ public void loadConfigWithTypedArgs(){ final URL url = IOUtils.extendUrl( ExamplesUtils.getTestScenarioURL( "equil" ), "config.xml" ); final String [] typedArgs = {"--config:controler.outputDirectory=abc"} ; Config config = ConfigUtils.loadConfig( url, typedArgs ); - Assert.assertEquals("abc", config.controler().getOutputDirectory()); + Assert.assertEquals("abc", config.controller().getOutputDirectory()); } @Test public void loadConfigWithTypedArgsWithTypo(){ diff --git a/matsim/src/test/java/org/matsim/core/utils/timing/TimeInterpretationTest.java b/matsim/src/test/java/org/matsim/core/utils/timing/TimeInterpretationTest.java index 5f30bb5b933..e8ef70e3ccd 100644 --- a/matsim/src/test/java/org/matsim/core/utils/timing/TimeInterpretationTest.java +++ b/matsim/src/test/java/org/matsim/core/utils/timing/TimeInterpretationTest.java @@ -92,13 +92,13 @@ public class TimeInterpretationTest { } private Controler prepareController(Config config) { - config.controler() + config.controller() .setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles); - config.controler().setLastIteration(0); + config.controller().setLastIteration(0); ActivityParams genericParams = new ActivityParams("generic"); genericParams.setScoringThisActivityAtAll(false); - config.planCalcScore().addActivityParams(genericParams); + config.scoring().addActivityParams(genericParams); Scenario scenario = ScenarioUtils.createScenario(config); diff --git a/matsim/src/test/java/org/matsim/counts/CountsControlerListenerTest.java b/matsim/src/test/java/org/matsim/counts/CountsControlerListenerTest.java index 314a4483179..45f5d661b93 100644 --- a/matsim/src/test/java/org/matsim/counts/CountsControlerListenerTest.java +++ b/matsim/src/test/java/org/matsim/counts/CountsControlerListenerTest.java @@ -65,7 +65,7 @@ public class CountsControlerListenerTest { public void testUseVolumesOfIteration() { Config config = ConfigUtils.createConfig(); Scenario scenario = ScenarioUtils.createScenario(config); - CountsControlerListener ccl = new CountsControlerListener(config.global(), scenario.getNetwork(), config.controler(), config.counts(), null, null, null); + CountsControlerListener ccl = new CountsControlerListener(config.global(), scenario.getNetwork(), config.controller(), config.counts(), null, null, null); // test defaults Assert.assertEquals(10, config.counts().getWriteCountsInterval()); @@ -265,23 +265,23 @@ public void install() { bind(Mobsim.class).toProvider(DummyMobsimFactory.class); } }); - config.controler().setFirstIteration(0); - config.controler().setLastIteration(7); + config.controller().setFirstIteration(0); + config.controller().setLastIteration(7); - controler.getConfig().controler().setCreateGraphs(false); - controler.getConfig().controler().setDumpDataAtEnd(false); - controler.getConfig().controler().setWriteEventsInterval(0); - config.controler().setWritePlansInterval(0); + controler.getConfig().controller().setCreateGraphs(false); + controler.getConfig().controller().setDumpDataAtEnd(false); + controler.getConfig().controller().setWriteEventsInterval(0); + config.controller().setWritePlansInterval(0); controler.run(); - Assert.assertTrue(new File(config.controler().getOutputDirectory() + "ITERS/it.0/0.countscompare.txt").exists()); - Assert.assertFalse(new File(config.controler().getOutputDirectory() + "ITERS/it.1/1.countscompare.txt").exists()); - Assert.assertFalse(new File(config.controler().getOutputDirectory() + "ITERS/it.2/2.countscompare.txt").exists()); - Assert.assertTrue(new File(config.controler().getOutputDirectory() + "ITERS/it.3/3.countscompare.txt").exists()); - Assert.assertFalse(new File(config.controler().getOutputDirectory() + "ITERS/it.4/4.countscompare.txt").exists()); - Assert.assertFalse(new File(config.controler().getOutputDirectory() + "ITERS/it.5/5.countscompare.txt").exists()); - Assert.assertTrue(new File(config.controler().getOutputDirectory() + "ITERS/it.6/6.countscompare.txt").exists()); - Assert.assertFalse(new File(config.controler().getOutputDirectory() + "ITERS/it.7/7.countscompare.txt").exists()); + Assert.assertTrue(new File(config.controller().getOutputDirectory() + "ITERS/it.0/0.countscompare.txt").exists()); + Assert.assertFalse(new File(config.controller().getOutputDirectory() + "ITERS/it.1/1.countscompare.txt").exists()); + Assert.assertFalse(new File(config.controller().getOutputDirectory() + "ITERS/it.2/2.countscompare.txt").exists()); + Assert.assertTrue(new File(config.controller().getOutputDirectory() + "ITERS/it.3/3.countscompare.txt").exists()); + Assert.assertFalse(new File(config.controller().getOutputDirectory() + "ITERS/it.4/4.countscompare.txt").exists()); + Assert.assertFalse(new File(config.controller().getOutputDirectory() + "ITERS/it.5/5.countscompare.txt").exists()); + Assert.assertTrue(new File(config.controller().getOutputDirectory() + "ITERS/it.6/6.countscompare.txt").exists()); + Assert.assertFalse(new File(config.controller().getOutputDirectory() + "ITERS/it.7/7.countscompare.txt").exists()); } @Test @@ -303,26 +303,26 @@ public void install() { bind(Mobsim.class).toProvider(DummyMobsimFactory.class); } }); - config.controler().setFirstIteration(0); - config.controler().setLastIteration(7); + config.controller().setFirstIteration(0); + config.controller().setLastIteration(7); - controler.getConfig().controler().setCreateGraphs(false); - controler.getConfig().controler().setDumpDataAtEnd(false); - controler.getConfig().controler().setWriteEventsInterval(0); - config.controler().setWritePlansInterval(0); + controler.getConfig().controller().setCreateGraphs(false); + controler.getConfig().controller().setDumpDataAtEnd(false); + controler.getConfig().controller().setWriteEventsInterval(0); + config.controller().setWritePlansInterval(0); controler.run(); - Assert.assertFalse(new File(config.controler().getOutputDirectory() + "ITERS/it.0/0.countscompareAWTV.txt").exists()); - Assert.assertFalse(new File(config.controler().getOutputDirectory() + "ITERS/it.1/1.countscompareAWTV.txt").exists()); - Assert.assertFalse(new File(config.controler().getOutputDirectory() + "ITERS/it.2/2.countscompareAWTV.txt").exists()); - Assert.assertTrue(new File(config.controler().getOutputDirectory() + "ITERS/it.3/3.countscompareAWTV.txt").exists()); - Assert.assertFalse(new File(config.controler().getOutputDirectory() + "ITERS/it.4/4.countscompareAWTV.txt").exists()); - Assert.assertFalse(new File(config.controler().getOutputDirectory() + "ITERS/it.5/5.countscompareAWTV.txt").exists()); - Assert.assertTrue(new File(config.controler().getOutputDirectory() + "ITERS/it.6/6.countscompareAWTV.txt").exists()); - Assert.assertFalse(new File(config.controler().getOutputDirectory() + "ITERS/it.7/7.countscompareAWTV.txt").exists()); - - Assert.assertEquals(3.5, getVolume(config.controler().getOutputDirectory() + "ITERS/it.3/3.countscompareAWTV.txt"), 1e-8); - Assert.assertEquals(6.5, getVolume(config.controler().getOutputDirectory() + "ITERS/it.6/6.countscompareAWTV.txt"), 1e-8); + Assert.assertFalse(new File(config.controller().getOutputDirectory() + "ITERS/it.0/0.countscompareAWTV.txt").exists()); + Assert.assertFalse(new File(config.controller().getOutputDirectory() + "ITERS/it.1/1.countscompareAWTV.txt").exists()); + Assert.assertFalse(new File(config.controller().getOutputDirectory() + "ITERS/it.2/2.countscompareAWTV.txt").exists()); + Assert.assertTrue(new File(config.controller().getOutputDirectory() + "ITERS/it.3/3.countscompareAWTV.txt").exists()); + Assert.assertFalse(new File(config.controller().getOutputDirectory() + "ITERS/it.4/4.countscompareAWTV.txt").exists()); + Assert.assertFalse(new File(config.controller().getOutputDirectory() + "ITERS/it.5/5.countscompareAWTV.txt").exists()); + Assert.assertTrue(new File(config.controller().getOutputDirectory() + "ITERS/it.6/6.countscompareAWTV.txt").exists()); + Assert.assertFalse(new File(config.controller().getOutputDirectory() + "ITERS/it.7/7.countscompareAWTV.txt").exists()); + + Assert.assertEquals(3.5, getVolume(config.controller().getOutputDirectory() + "ITERS/it.3/3.countscompareAWTV.txt"), 1e-8); + Assert.assertEquals(6.5, getVolume(config.controller().getOutputDirectory() + "ITERS/it.6/6.countscompareAWTV.txt"), 1e-8); } @Test @@ -337,30 +337,30 @@ public void testFilterAnalyzedModes() throws IOException { cConfig.setOutputFormat("txt"); cConfig.setInputFile("counts.xml"); // just any file to activate the counts feature - config.controler().setMobsim("dummy"); - config.controler().setFirstIteration(0); - config.controler().setLastIteration(3); + config.controller().setMobsim("dummy"); + config.controller().setFirstIteration(0); + config.controller().setLastIteration(3); createAndRunControler(config); - Assert.assertEquals(150, getVolume(config.controler().getOutputDirectory() + "ITERS/it.3/3.countscompareAWTV.txt"), 1e-8); + Assert.assertEquals(150, getVolume(config.controller().getOutputDirectory() + "ITERS/it.3/3.countscompareAWTV.txt"), 1e-8); // enable modes filtering and count only car cConfig.setAnalyzedModes(TransportMode.car); cConfig.setFilterModes(true); createAndRunControler(config); - Assert.assertEquals(100, getVolume(config.controler().getOutputDirectory() + "ITERS/it.3/3.countscompareAWTV.txt"), 1e-8); + Assert.assertEquals(100, getVolume(config.controller().getOutputDirectory() + "ITERS/it.3/3.countscompareAWTV.txt"), 1e-8); // enable modes filtering and count only walk cConfig.setAnalyzedModes(TransportMode.walk); cConfig.setFilterModes(true); createAndRunControler(config); - Assert.assertEquals(50, getVolume(config.controler().getOutputDirectory() + "ITERS/it.3/3.countscompareAWTV.txt"), 1e-8); + Assert.assertEquals(50, getVolume(config.controller().getOutputDirectory() + "ITERS/it.3/3.countscompareAWTV.txt"), 1e-8); // enable modes filtering and count only bike cConfig.setAnalyzedModes(TransportMode.bike); cConfig.setFilterModes(true); createAndRunControler(config); - Assert.assertEquals(0, getVolume(config.controler().getOutputDirectory() + "ITERS/it.3/3.countscompareAWTV.txt"), 1e-8); + Assert.assertEquals(0, getVolume(config.controller().getOutputDirectory() + "ITERS/it.3/3.countscompareAWTV.txt"), 1e-8); } @@ -375,11 +375,11 @@ public void install() { bind(EventsManager.class).to(EventsManagerImpl.class).in(Singleton.class); } }); - controler.getConfig().controler().setCreateGraphs(false); - controler.getConfig().controler().setDumpDataAtEnd(false); - controler.getConfig().controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles); - controler.getConfig().controler().setWriteEventsInterval(0); - config.controler().setWritePlansInterval(0); + controler.getConfig().controller().setCreateGraphs(false); + controler.getConfig().controller().setDumpDataAtEnd(false); + controler.getConfig().controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles); + controler.getConfig().controller().setWriteEventsInterval(0); + config.controller().setWritePlansInterval(0); controler.run(); } diff --git a/matsim/src/test/java/org/matsim/counts/CountsReprojectionIOTest.java b/matsim/src/test/java/org/matsim/counts/CountsReprojectionIOTest.java index 59e0ba11b01..55e42f43d49 100644 --- a/matsim/src/test/java/org/matsim/counts/CountsReprojectionIOTest.java +++ b/matsim/src/test/java/org/matsim/counts/CountsReprojectionIOTest.java @@ -32,7 +32,6 @@ import org.matsim.api.core.v01.network.Link; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.controler.AbstractModule; import org.matsim.core.controler.Controler; import org.matsim.core.scenario.ScenarioUtils; import org.matsim.core.utils.geometry.CoordinateTransformation; @@ -97,9 +96,9 @@ public void testWithControlerAndConfigParameters() { // TODO: test also with loading from Controler C'tor? final Scenario scenario = ScenarioUtils.loadScenario( config ); - config.controler().setLastIteration( 0 ); + config.controller().setLastIteration( 0 ); final String outputDirectory = utils.getOutputDirectory()+"/output/"; - config.controler().setOutputDirectory( outputDirectory ); + config.controller().setOutputDirectory( outputDirectory ); final Controler controler = new Controler( scenario ); controler.run(); diff --git a/matsim/src/test/java/org/matsim/examples/EquilTest.java b/matsim/src/test/java/org/matsim/examples/EquilTest.java index 13ccb964846..c884bf4b3a5 100644 --- a/matsim/src/test/java/org/matsim/examples/EquilTest.java +++ b/matsim/src/test/java/org/matsim/examples/EquilTest.java @@ -68,7 +68,7 @@ public static Collection parameterObjects () { @Test public void testEquil() { Config config = ConfigUtils.createConfig() ; - config.controler().setOutputDirectory( utils.getOutputDirectory() ); + config.controller().setOutputDirectory( utils.getOutputDirectory() ); config.qsim().setUsingFastCapacityUpdate(this.isUsingFastCapacityUpdate); config.facilities().setFacilitiesSource( FacilitiesConfigGroup.FacilitiesSource.onePerActivityLinkInPlansFile ); diff --git a/matsim/src/test/java/org/matsim/examples/OnePercentBerlin10sIT.java b/matsim/src/test/java/org/matsim/examples/OnePercentBerlin10sIT.java index dafea13f5b0..92e9431f0c5 100644 --- a/matsim/src/test/java/org/matsim/examples/OnePercentBerlin10sIT.java +++ b/matsim/src/test/java/org/matsim/examples/OnePercentBerlin10sIT.java @@ -66,7 +66,7 @@ public class OnePercentBerlin10sIT { config.qsim().setStorageCapFactor(0.04); config.qsim().setRemoveStuckVehicles(false); config.qsim().setStuckTime(10.0); - config.planCalcScore().setLearningRate(1.0); + config.scoring().setLearningRate(1.0); config.plans().setActivityDurationInterpretation(PlansConfigGroup.ActivityDurationInterpretation.minOfDurationAndEndTime); @@ -110,9 +110,9 @@ public class OnePercentBerlin10sIT { config.qsim().setStorageCapFactor(0.04); config.qsim().setRemoveStuckVehicles(false); config.qsim().setStuckTime(10.0); - config.planCalcScore().setLearningRate(1.0); + config.scoring().setLearningRate(1.0); - config.controler().setOutputDirectory(utils.getOutputDirectory()); + config.controller().setOutputDirectory(utils.getOutputDirectory()); Scenario scenario = ScenarioUtils.createScenario(config); diff --git a/matsim/src/test/java/org/matsim/examples/PtTutorialIT.java b/matsim/src/test/java/org/matsim/examples/PtTutorialIT.java index b6636c931a5..43c8378d326 100644 --- a/matsim/src/test/java/org/matsim/examples/PtTutorialIT.java +++ b/matsim/src/test/java/org/matsim/examples/PtTutorialIT.java @@ -51,13 +51,13 @@ public class PtTutorialIT { private final static Logger log = LogManager.getLogger(PtTutorialIT.class); - + public @Rule MatsimTestUtils utils = new MatsimTestUtils(); - + @Test public void ensure_tutorial_runs() throws MalformedURLException { Config config = this.utils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("pt-tutorial"), "0.config.xml")); - config.controler().setLastIteration(1); + config.controller().setLastIteration(1); try { Controler controler = new Controler(config); @@ -76,9 +76,9 @@ public void ensure_tutorial_runs() throws MalformedURLException { Assert.fail("There shouldn't be any exception, but there was ... :-("); } final String it1Plans = "ITERS/it.1/1.plans.xml.gz"; - Assert.assertTrue(new File(config.controler().getOutputDirectory(), it1Plans).exists()); - Assert.assertTrue(new File(config.controler().getOutputDirectory(), "output_config.xml").exists()); - + Assert.assertTrue(new File(config.controller().getOutputDirectory(), it1Plans).exists()); + Assert.assertTrue(new File(config.controller().getOutputDirectory(), "output_config.xml").exists()); + log.info( Controler.DIVIDER ) ; log.info( Controler.DIVIDER ) ; // try to restart from output: @@ -87,11 +87,11 @@ public void ensure_tutorial_runs() throws MalformedURLException { config.plans().setInputFile(new File(utils.getOutputDirectory() + "/" + it1Plans).toURI().toURL().toString()); - config.controler().setOverwriteFileSetting( OverwriteFileSetting.overwriteExistingFiles ); + config.controller().setOverwriteFileSetting( OverwriteFileSetting.overwriteExistingFiles ); // note: cannot delete directory since some of the input resides there. kai, sep'15 - - config.controler().setFirstIteration(10); - config.controler().setLastIteration(10); + + config.controller().setFirstIteration(10); + config.controller().setLastIteration(10); try { Controler controler = new Controler(config); @@ -110,7 +110,7 @@ public void ensure_tutorial_runs() throws MalformedURLException { log.error(e.getMessage(), e); Assert.fail("There shouldn't be any exception, but there was ... :-("); } - + } private static final class EnterVehicleEventCounter implements PersonEntersVehicleEventHandler { @@ -154,5 +154,5 @@ private static final class StageActivityDurationChecker implements ActivityStart } } } - + } diff --git a/matsim/src/test/java/org/matsim/examples/simple/PtScoringTest.java b/matsim/src/test/java/org/matsim/examples/simple/PtScoringTest.java index 912ee2e118b..c1c442de687 100644 --- a/matsim/src/test/java/org/matsim/examples/simple/PtScoringTest.java +++ b/matsim/src/test/java/org/matsim/examples/simple/PtScoringTest.java @@ -70,7 +70,7 @@ public static Object[] testParameters() { public void test_PtScoringLineswitch() { Config config = this.utils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("pt-simple-lineswitch"), "config.xml")); config.transit().setRoutingAlgorithmType(TransitRoutingAlgorithmType.DijkstraBased); - ScoringConfigGroup pcs = config.planCalcScore() ; + ScoringConfigGroup pcs = config.scoring() ; if(this.typicalDurationScoreComputation.equals(TypicalDurationScoreComputation.uniform)){ for(ActivityParams params : pcs.getActivityParams()){ @@ -81,8 +81,8 @@ public void test_PtScoringLineswitch() { pcs.setWriteExperiencedPlans(true); Controler controler = new Controler(config); - controler.getConfig().controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles); - controler.getConfig().controler().setCreateGraphs(false); + controler.getConfig().controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles); + controler.getConfig().controller().setCreateGraphs(false); EventsCollector collector = new EventsCollector(); controler.getEvents().addHandler(collector); @@ -223,7 +223,7 @@ public void test_PtScoringLineswitch() { public void test_PtScoringLineswitchAndPtConstant() { Config config = this.utils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("pt-simple-lineswitch"), "config.xml")); config.transit().setRoutingAlgorithmType(TransitRoutingAlgorithmType.DijkstraBased); - ScoringConfigGroup pcs = config.planCalcScore() ; + ScoringConfigGroup pcs = config.scoring() ; if(this.typicalDurationScoreComputation.equals(TypicalDurationScoreComputation.uniform)) for(ActivityParams params : pcs.getActivityParams()){ @@ -234,8 +234,8 @@ public void test_PtScoringLineswitchAndPtConstant() { pcs.getModes().get(TransportMode.pt).setConstant(1.); Controler controler = new Controler(config); - controler.getConfig().controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles); - controler.getConfig().controler().setCreateGraphs(false); + controler.getConfig().controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles); + controler.getConfig().controller().setCreateGraphs(false); EventsCollector collector = new EventsCollector(); controler.getEvents().addHandler(collector); @@ -379,7 +379,7 @@ public void test_PtScoringLineswitchAndPtConstant() { public void test_PtScoring_Wait() { Config config = this.utils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("pt-simple"), "config.xml")); config.transit().setRoutingAlgorithmType(TransitRoutingAlgorithmType.DijkstraBased); - ScoringConfigGroup pcs = config.planCalcScore() ; + ScoringConfigGroup pcs = config.scoring() ; if(this.typicalDurationScoreComputation.equals(TypicalDurationScoreComputation.uniform)){ for(ActivityParams params : pcs.getActivityParams()){ @@ -391,8 +391,8 @@ public void test_PtScoring_Wait() { pcs.setMarginalUtlOfWaitingPt_utils_hr(-18.0) ; Controler controler = new Controler(config); - controler.getConfig().controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles); - controler.getConfig().controler().setCreateGraphs(false); + controler.getConfig().controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles); + controler.getConfig().controller().setCreateGraphs(false); EventsCollector collector = new EventsCollector(); controler.getEvents().addHandler(collector); @@ -466,7 +466,7 @@ public void test_PtScoring_Wait() { public void test_PtScoring() { Config config = this.utils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("pt-simple"), "config.xml")); config.transit().setRoutingAlgorithmType(TransitRoutingAlgorithmType.DijkstraBased); - ScoringConfigGroup pcs = config.planCalcScore() ; + ScoringConfigGroup pcs = config.scoring() ; if(this.typicalDurationScoreComputation.equals(TypicalDurationScoreComputation.uniform)) for(ActivityParams params : pcs.getActivityParams()){ @@ -476,8 +476,8 @@ public void test_PtScoring() { pcs.setWriteExperiencedPlans(true); Controler controler = new Controler(config); - controler.getConfig().controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles); - controler.getConfig().controler().setCreateGraphs(false); + controler.getConfig().controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles); + controler.getConfig().controller().setCreateGraphs(false); EventsCollector collector = new EventsCollector(); controler.getEvents().addHandler(collector); diff --git a/matsim/src/test/java/org/matsim/facilities/ActivityFacilitiesSourceTest.java b/matsim/src/test/java/org/matsim/facilities/ActivityFacilitiesSourceTest.java index e4f5cbc305d..30d0e5a0a6e 100644 --- a/matsim/src/test/java/org/matsim/facilities/ActivityFacilitiesSourceTest.java +++ b/matsim/src/test/java/org/matsim/facilities/ActivityFacilitiesSourceTest.java @@ -52,7 +52,7 @@ @RunWith(Parameterized.class) public class ActivityFacilitiesSourceTest { - + @Rule public MatsimTestUtils utils = new MatsimTestUtils() ; // private static final String outDir = "test/output/"+ActivityFacilitiesSourceTest.class.getCanonicalName().replace('.','/')+"/"; @@ -86,14 +86,14 @@ public void test(){ new File(testOutDir).mkdirs(); Scenario scenario = prepareScenario(); - scenario.getConfig().controler().setOutputDirectory(testOutDir); - scenario.getConfig().controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles); + scenario.getConfig().controller().setOutputDirectory(testOutDir); + scenario.getConfig().controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles); // (overwriteExistingFiles is needed here for the parameterized test since otherwise all output directories except for // the last test will be deleted and thus not available for debugging. kai, sep'19) new Controler(scenario).run(); // checks - ActivityFacilities activityFacilities = getFacilities(scenario.getConfig().controler().getOutputDirectory()); + ActivityFacilities activityFacilities = getFacilities(scenario.getConfig().controller().getOutputDirectory()); switch (this.facilitiesSource) { case none: break; @@ -115,13 +115,13 @@ public void test(){ } break; case onePerActivityLinkInPlansFile: - Assert.assertEquals("wrong number of facilities", 4, getFacilities(scenario.getConfig().controler().getOutputDirectory()).getFacilities().size(), MatsimTestUtils.EPSILON); + Assert.assertEquals("wrong number of facilities", 4, getFacilities(scenario.getConfig().controller().getOutputDirectory()).getFacilities().size(), MatsimTestUtils.EPSILON); for (ActivityFacility af : activityFacilities.getFacilities().values()){ Assert.assertNotNull(af.getLinkId()); } break; case onePerActivityLocationInPlansFile: - Assert.assertEquals("wrong number of facilities", 2, getFacilities(scenario.getConfig().controler().getOutputDirectory()).getFacilities().size(), MatsimTestUtils.EPSILON); + Assert.assertEquals("wrong number of facilities", 2, getFacilities(scenario.getConfig().controller().getOutputDirectory()).getFacilities().size(), MatsimTestUtils.EPSILON); for (ActivityFacility af : activityFacilities.getFacilities().values()){ Assert.assertNotNull(af.getCoord()); Assert.assertNotNull(af.getLinkId()); @@ -136,13 +136,13 @@ private ActivityFacilities getFacilities(String outputDir){ return scenario.getActivityFacilities(); } - + // create basic scenario private Scenario prepareScenario() { Config config = ConfigUtils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("equil"), "config.xml")); config.plans().setInputFile(null); - config.controler().setLastIteration(0); - + config.controller().setLastIteration(0); + switch (facilitiesSource) { case fromFile: break; @@ -158,11 +158,11 @@ private Scenario prepareScenario() { // config.facilities().setAssigningLinksToFacilitiesIfMissing(false); break; } - + config.facilities().setFacilitiesSource(facilitiesSource); - + Scenario scenario = ScenarioUtils.loadScenario(config); - + if (facilitiesSource.equals(FacilitiesConfigGroup.FacilitiesSource.setInScenario)) { ActivityFacilities facilities = scenario.getActivityFacilities(); ActivityFacilitiesFactory factory = facilities.getFactory(); @@ -182,7 +182,7 @@ private Scenario prepareScenario() { Id.createLinkId("20"))); } } - + PopulationFactory populationFactory = scenario.getPopulation().getFactory(); String mode = TransportMode.car; @@ -297,7 +297,7 @@ private Scenario prepareScenario() { } return scenario; } - + private boolean assignFacilityIdToActivity(FacilitiesConfigGroup.FacilitiesSource facilitiesSource) { return facilitiesSource.equals(FacilitiesConfigGroup.FacilitiesSource.setInScenario) || facilitiesSource.equals( FacilitiesConfigGroup.FacilitiesSource.fromFile); diff --git a/matsim/src/test/java/org/matsim/facilities/ActivityWithOnlyFacilityIdTest.java b/matsim/src/test/java/org/matsim/facilities/ActivityWithOnlyFacilityIdTest.java index d23b6e962d4..11666860066 100644 --- a/matsim/src/test/java/org/matsim/facilities/ActivityWithOnlyFacilityIdTest.java +++ b/matsim/src/test/java/org/matsim/facilities/ActivityWithOnlyFacilityIdTest.java @@ -24,8 +24,8 @@ public void testSiouxFallsWithOnlyFacilityIds() { URL scenarioURL = ExamplesUtils.getTestScenarioURL("siouxfalls-2014"); Config config = ConfigUtils.loadConfig(IOUtils.extendUrl(scenarioURL, "config_default.xml")); - config.controler().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); - config.controler().setLastIteration(1); + config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); + config.controller().setLastIteration(1); Scenario scenario = ScenarioUtils.loadScenario(config); diff --git a/matsim/src/test/java/org/matsim/facilities/FacilitiesReprojectionIOTest.java b/matsim/src/test/java/org/matsim/facilities/FacilitiesReprojectionIOTest.java index 63bc92a1f39..e3ad1e04478 100644 --- a/matsim/src/test/java/org/matsim/facilities/FacilitiesReprojectionIOTest.java +++ b/matsim/src/test/java/org/matsim/facilities/FacilitiesReprojectionIOTest.java @@ -114,9 +114,9 @@ public void testWithControlerAndObjectAttributes() { TARGET_CRS, ProjectionUtils.getCRS(scenario.getActivityFacilities())); - config.controler().setLastIteration( -1 ); + config.controller().setLastIteration( -1 ); final String outputDirectory = utils.getOutputDirectory()+"/output/"; - config.controler().setOutputDirectory( outputDirectory ); + config.controller().setOutputDirectory( outputDirectory ); final Controler controler = new Controler( scenario ); controler.run(); @@ -179,9 +179,9 @@ public void testWithControlerAndConfigParameters() { epsilon ); } - config.controler().setLastIteration( -1 ); + config.controller().setLastIteration( -1 ); final String outputDirectory = utils.getOutputDirectory()+"/output/"; - config.controler().setOutputDirectory( outputDirectory ); + config.controller().setOutputDirectory( outputDirectory ); final Controler controler = new Controler( scenario ); controler.run(); diff --git a/matsim/src/test/java/org/matsim/integration/EquilTwoAgentsTest.java b/matsim/src/test/java/org/matsim/integration/EquilTwoAgentsTest.java index 583d36fa620..3d2df7affd6 100644 --- a/matsim/src/test/java/org/matsim/integration/EquilTwoAgentsTest.java +++ b/matsim/src/test/java/org/matsim/integration/EquilTwoAgentsTest.java @@ -93,16 +93,16 @@ public void testSingleIterationPlansV4() { ConfigUtils.loadConfig(config, IOUtils.extendUrl(utils.classInputResourcePath(), "config.xml")); config.plans().setInputFile(IOUtils.extendUrl(utils.classInputResourcePath(), "plans2.xml").toString()); - ScoringConfigGroup pcsConfig = config.planCalcScore() ; + ScoringConfigGroup pcsConfig = config.scoring() ; ActivityParams params = new ActivityParams("h") ; params.setTypicalDuration(123456789.0) ; // probably dummy params.setScoringThisActivityAtAll(false); pcsConfig.addActivityParams(params) ; final Controler controler = new Controler(config); - controler.getConfig().controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles); - controler.getConfig().controler().setCreateGraphs(false); - controler.getConfig().controler().setWriteEventsInterval(0); + controler.getConfig().controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles); + controler.getConfig().controller().setCreateGraphs(false); + controler.getConfig().controller().setWriteEventsInterval(0); controler.addOverridingModule(new AbstractModule() { @Override public void install() { diff --git a/matsim/src/test/java/org/matsim/integration/SimulateAndScoreTest.java b/matsim/src/test/java/org/matsim/integration/SimulateAndScoreTest.java index d57ff6a25d9..9d70490fc42 100644 --- a/matsim/src/test/java/org/matsim/integration/SimulateAndScoreTest.java +++ b/matsim/src/test/java/org/matsim/integration/SimulateAndScoreTest.java @@ -97,15 +97,15 @@ public class SimulateAndScoreTest { ScoringConfigGroup.ActivityParams transitActivityParams = new ScoringConfigGroup.ActivityParams(PtConstants.TRANSIT_ACTIVITY_TYPE); transitActivityParams.setTypicalDuration(120.0); - config.planCalcScore().setPerforming_utils_hr(0); - config.planCalcScore().getModes().get(TransportMode.car).setMarginalUtilityOfTraveling((double) 0); - config.planCalcScore().getModes().get(TransportMode.pt).setMarginalUtilityOfTraveling((double) 0); - config.planCalcScore().getModes().get(TransportMode.walk).setMarginalUtilityOfTraveling((double) 0); - config.planCalcScore().getModes().get(TransportMode.car).setMonetaryDistanceRate((double) 10); - config.planCalcScore().getModes().get(TransportMode.pt).setMonetaryDistanceRate((double) 0); - config.planCalcScore().addActivityParams(h); - config.planCalcScore().addActivityParams(w); - config.planCalcScore().addActivityParams(transitActivityParams); + config.scoring().setPerforming_utils_hr(0); + config.scoring().getModes().get(TransportMode.car).setMarginalUtilityOfTraveling((double) 0); + config.scoring().getModes().get(TransportMode.pt).setMarginalUtilityOfTraveling((double) 0); + config.scoring().getModes().get(TransportMode.walk).setMarginalUtilityOfTraveling((double) 0); + config.scoring().getModes().get(TransportMode.car).setMonetaryDistanceRate((double) 10); + config.scoring().getModes().get(TransportMode.pt).setMonetaryDistanceRate((double) 0); + config.scoring().addActivityParams(h); + config.scoring().addActivityParams(w); + config.scoring().addActivityParams(transitActivityParams); // --- @@ -282,13 +282,13 @@ public void install() { h.setTypicalDuration(16 * 3600); ScoringConfigGroup.ActivityParams w = new ScoringConfigGroup.ActivityParams("w"); w.setTypicalDuration(8 * 3600); - scenario.getConfig().planCalcScore().setPerforming_utils_hr(0); + scenario.getConfig().scoring().setPerforming_utils_hr(0); final double travelingPt = -1.00; - scenario.getConfig().planCalcScore().getModes().get(TransportMode.pt).setMarginalUtilityOfTraveling(travelingPt); + scenario.getConfig().scoring().getModes().get(TransportMode.pt).setMarginalUtilityOfTraveling(travelingPt); double monetaryDistanceRatePt = -0.001; - scenario.getConfig().planCalcScore().getModes().get(TransportMode.pt).setMonetaryDistanceRate(monetaryDistanceRatePt); - scenario.getConfig().planCalcScore().addActivityParams(h); - scenario.getConfig().planCalcScore().addActivityParams(w); + scenario.getConfig().scoring().getModes().get(TransportMode.pt).setMonetaryDistanceRate(monetaryDistanceRatePt); + scenario.getConfig().scoring().addActivityParams(h); + scenario.getConfig().scoring().addActivityParams(w); EventsToScore scorer = EventsToScore.createWithScoreUpdating(scenario, new CharyparNagelScoringFunctionFactory(scenario), events); EventsCollector handler = new EventsCollector(); events.addHandler(handler); diff --git a/matsim/src/test/java/org/matsim/integration/invertednetworks/InvertedNetworkRoutingIT.java b/matsim/src/test/java/org/matsim/integration/invertednetworks/InvertedNetworkRoutingIT.java index 0ae37563728..7373f84c106 100644 --- a/matsim/src/test/java/org/matsim/integration/invertednetworks/InvertedNetworkRoutingIT.java +++ b/matsim/src/test/java/org/matsim/integration/invertednetworks/InvertedNetworkRoutingIT.java @@ -36,11 +36,11 @@ public class InvertedNetworkRoutingIT { @Test public final void testLanesInvertedNetworkRouting() { InvertedNetworkRoutingTestFixture f = new InvertedNetworkRoutingTestFixture(false, true, false); - f.scenario.getConfig().controler().setOutputDirectory(testUtils.getOutputDirectory()); + f.scenario.getConfig().controller().setOutputDirectory(testUtils.getOutputDirectory()); f.scenario.getConfig().travelTimeCalculator().setSeparateModes( false ); Controler c = new Controler(f.scenario); - c.getConfig().controler().setDumpDataAtEnd(false); - c.getConfig().controler().setCreateGraphs(false); + c.getConfig().controller().setDumpDataAtEnd(false); + c.getConfig().controller().setCreateGraphs(false); final InvertedNetworkRoutingTestEventHandler testHandler = new InvertedNetworkRoutingTestEventHandler(); c.addControlerListener(new StartupListener(){ @Override @@ -56,11 +56,11 @@ public void notifyStartup(StartupEvent event) { @Test public final void testModesInvertedNetworkRouting() { InvertedNetworkRoutingTestFixture f = new InvertedNetworkRoutingTestFixture(true, false, false); - f.scenario.getConfig().controler().setOutputDirectory(testUtils.getOutputDirectory()); + f.scenario.getConfig().controller().setOutputDirectory(testUtils.getOutputDirectory()); f.scenario.getConfig().travelTimeCalculator().setSeparateModes( false ); Controler c = new Controler(f.scenario); - c.getConfig().controler().setDumpDataAtEnd(false); - c.getConfig().controler().setCreateGraphs(false); + c.getConfig().controller().setDumpDataAtEnd(false); + c.getConfig().controller().setCreateGraphs(false); final InvertedNetworkRoutingTestEventHandler testHandler = new InvertedNetworkRoutingTestEventHandler(); c.addControlerListener(new StartupListener(){ @Override @@ -75,13 +75,13 @@ public void notifyStartup(StartupEvent event) { @Test public final void testModesNotInvertedNetworkRouting() { InvertedNetworkRoutingTestFixture f = new InvertedNetworkRoutingTestFixture(true, false, false); - f.scenario.getConfig().controler().setOutputDirectory(testUtils.getOutputDirectory()); - f.scenario.getConfig().controler().setLinkToLinkRoutingEnabled(false); + f.scenario.getConfig().controller().setOutputDirectory(testUtils.getOutputDirectory()); + f.scenario.getConfig().controller().setLinkToLinkRoutingEnabled(false); f.scenario.getConfig().travelTimeCalculator().setCalculateLinkToLinkTravelTimes(false); Controler c = new Controler(f.scenario); //c.addOverridingModule(new InvertedNetworkRoutingGuiceModule()); - c.getConfig().controler().setDumpDataAtEnd(false); - c.getConfig().controler().setCreateGraphs(false); + c.getConfig().controller().setDumpDataAtEnd(false); + c.getConfig().controller().setCreateGraphs(false); final InvertedNetworkRoutingTestEventHandler testHandler = new InvertedNetworkRoutingTestEventHandler(); c.addControlerListener(new StartupListener(){ @Override diff --git a/matsim/src/test/java/org/matsim/integration/invertednetworks/InvertedNetworkRoutingTestFixture.java b/matsim/src/test/java/org/matsim/integration/invertednetworks/InvertedNetworkRoutingTestFixture.java index fcbcc11a78b..039fb91947f 100644 --- a/matsim/src/test/java/org/matsim/integration/invertednetworks/InvertedNetworkRoutingTestFixture.java +++ b/matsim/src/test/java/org/matsim/integration/invertednetworks/InvertedNetworkRoutingTestFixture.java @@ -78,10 +78,10 @@ public class InvertedNetworkRoutingTestFixture { public InvertedNetworkRoutingTestFixture(boolean doCreateModes, boolean doCreateLanes, boolean doCreateSignals) { Config config = ConfigUtils.createConfig(); - config.controler().setLastIteration(0); - config.controler().setLinkToLinkRoutingEnabled(true); + config.controller().setLastIteration(0); + config.controller().setLinkToLinkRoutingEnabled(true); config.travelTimeCalculator().setCalculateLinkToLinkTravelTimes(true); - config.controler().setMobsim("qsim"); + config.controller().setMobsim("qsim"); config.global().setNumberOfThreads(1); config.qsim().setRemoveStuckVehicles(false); config.qsim().setStuckTime(10000.0); @@ -90,12 +90,12 @@ public InvertedNetworkRoutingTestFixture(boolean doCreateModes, boolean doCreate StrategySettings stratSets = new StrategySettings(Id.create(1, StrategySettings.class)); stratSets.setStrategyName(DefaultPlanStrategiesModule.DefaultStrategy.ReRoute.toString()); stratSets.setWeight(1.0); - config.strategy().addStrategySettings(stratSets); + config.replanning().addStrategySettings(stratSets); final double traveling = -1200.0; - config.planCalcScore().getModes().get(TransportMode.car).setMarginalUtilityOfTraveling(traveling); + config.scoring().getModes().get(TransportMode.car).setMarginalUtilityOfTraveling(traveling); ActivityParams params = new ActivityParams("home"); params.setTypicalDuration(24.0 * 3600.0); - config.planCalcScore().addActivityParams(params); + config.scoring().addActivityParams(params); config.qsim().setUseLanes(doCreateLanes); this.scenario = (MutableScenario) ScenarioUtils.createScenario(config); diff --git a/matsim/src/test/java/org/matsim/integration/invertednetworks/LanesIT.java b/matsim/src/test/java/org/matsim/integration/invertednetworks/LanesIT.java index caa73ab9468..f31ec3a810e 100644 --- a/matsim/src/test/java/org/matsim/integration/invertednetworks/LanesIT.java +++ b/matsim/src/test/java/org/matsim/integration/invertednetworks/LanesIT.java @@ -66,11 +66,11 @@ public void testLanes(){ config.network().setInputFile("network.xml"); config.network().setLaneDefinitionsFile("testLaneDefinitions_v2.0.xml"); config.plans().setInputFile("population.xml"); - config.controler().setRoutingAlgorithmType(ControllerConfigGroup.RoutingAlgorithmType.Dijkstra); - config.controler().setOutputDirectory(testUtils.getOutputDirectory() + "output"); + config.controller().setRoutingAlgorithmType(ControllerConfigGroup.RoutingAlgorithmType.Dijkstra); + config.controller().setOutputDirectory(testUtils.getOutputDirectory() + "output"); final int lastIteration = 50; - config.controler().setLastIteration(lastIteration); - config.controler().setCreateGraphs(false); + config.controller().setLastIteration(lastIteration); + config.controller().setCreateGraphs(false); config.vspExperimental().setWritingOutputEvents(false); config.travelTimeCalculator().setSeparateModes( false ); // --- diff --git a/matsim/src/test/java/org/matsim/integration/population/NonAlternatingPlanElementsIT.java b/matsim/src/test/java/org/matsim/integration/population/NonAlternatingPlanElementsIT.java index a06e6aebf07..5c317f24862 100644 --- a/matsim/src/test/java/org/matsim/integration/population/NonAlternatingPlanElementsIT.java +++ b/matsim/src/test/java/org/matsim/integration/population/NonAlternatingPlanElementsIT.java @@ -55,7 +55,7 @@ /** * Tests that a simple simulation can be run with plans where * activities and legs are not always alternating. - * + * * @author mrieser / senozon */ public class NonAlternatingPlanElementsIT { @@ -65,11 +65,11 @@ public class NonAlternatingPlanElementsIT { @Test public void test_Controler_QSim_Routechoice_acts() { Config config = this.utils.loadConfig("test/scenarios/equil/config.xml"); - config.controler().setMobsim("qsim"); - config.controler().setLastIteration(10); + config.controller().setMobsim("qsim"); + config.controller().setLastIteration(10); config.plans().setHandlingOfPlansWithoutRoutingMode(HandlingOfPlansWithoutRoutingMode.useMainModeIdentifier); - config.strategy().addParam("Module_2", "ReRoute"); - config.strategy().addParam("ModuleProbability_2", "1.0"); + config.replanning().addParam("Module_2", "ReRoute"); + config.replanning().addParam("ModuleProbability_2", "1.0"); config.transit().setUseTransit(true); // a scenario is created to take only network from config file; rest inputs are ignored; @@ -87,8 +87,8 @@ public void test_Controler_QSim_Routechoice_acts() { scenario.getPopulation().addPerson(person); Controler controler = new Controler(scenario); - controler.getConfig().controler().setDumpDataAtEnd(false); - controler.getConfig().controler().setCreateGraphs(false); + controler.getConfig().controller().setDumpDataAtEnd(false); + controler.getConfig().controller().setCreateGraphs(false); controler.run(); Assert.assertTrue(person.getPlans().size() > 1); // ensure there was some replanning @@ -97,11 +97,11 @@ public void test_Controler_QSim_Routechoice_acts() { @Test public void test_Controler_QSim_Routechoice_legs() { Config config = this.utils.loadConfig("test/scenarios/equil/config.xml"); - config.controler().setMobsim("qsim"); - config.controler().setLastIteration(10); + config.controller().setMobsim("qsim"); + config.controller().setLastIteration(10); config.plans().setHandlingOfPlansWithoutRoutingMode(HandlingOfPlansWithoutRoutingMode.useMainModeIdentifier); - config.strategy().addParam("Module_2", "ReRoute"); - config.strategy().addParam("ModuleProbability_2", "1.0"); + config.replanning().addParam("Module_2", "ReRoute"); + config.replanning().addParam("ModuleProbability_2", "1.0"); config.transit().setUseTransit(true); // a scenario is created to take only network from config file; rest inputs are ignored; @@ -119,8 +119,8 @@ public void test_Controler_QSim_Routechoice_legs() { scenario.getPopulation().addPerson(person); Controler controler = new Controler(scenario); - controler.getConfig().controler().setDumpDataAtEnd(false); - controler.getConfig().controler().setCreateGraphs(false); + controler.getConfig().controller().setDumpDataAtEnd(false); + controler.getConfig().controller().setCreateGraphs(false); controler.run(); Assert.assertTrue(person.getPlans().size() > 1); // ensure there was some replanning @@ -129,9 +129,9 @@ public void test_Controler_QSim_Routechoice_legs() { // TODO: make more complicated plans when testing subtour mode choice private static Plan createPlanWithConsecutiveLegsForEquilNet(final Scenario scenario) { PopulationFactory pf = scenario.getPopulation().getFactory(); - + Plan plan = pf.createPlan(); - + Activity home1 = pf.createActivityFromLinkId("h", Id.create(1, Link.class)); final double x1 = -17000; ((Activity) home1).setCoord(new Coord(x1, (double) 500)); @@ -161,7 +161,7 @@ private static Plan createPlanWithConsecutiveLegsForEquilNet(final Scenario scen Activity home2 = pf.createActivityFromLinkId("h", Id.create(1, Link.class)); final double x = -17000; ((Activity) home2).setCoord(new Coord(x, (double) 500)); - + plan.addActivity(home1); plan.addLeg(leg1); plan.addLeg(leg2); @@ -169,15 +169,15 @@ private static Plan createPlanWithConsecutiveLegsForEquilNet(final Scenario scen plan.addActivity(work); plan.addLeg(leg4); plan.addActivity(home2); - + return plan; } private static Plan createPlanWithConsecutiveActivitiesForEquilNet(final Scenario scenario) { PopulationFactory pf = scenario.getPopulation().getFactory(); - + Plan plan = pf.createPlan(); - + Activity home1 = pf.createActivityFromLinkId("h", Id.create(1, Link.class)); final double x3 = -17000; ((Activity) home1).setCoord(new Coord(x3, (double) 500)); @@ -214,7 +214,7 @@ private static Plan createPlanWithConsecutiveActivitiesForEquilNet(final Scenari Activity home4 = pf.createActivityFromLinkId("h", Id.create(1, Link.class)); final double x = -17000; ((Activity) home2).setCoord(new Coord(x, (double) 500)); - + plan.addActivity(home1); plan.addLeg(leg1); plan.addActivity(work); @@ -223,12 +223,12 @@ private static Plan createPlanWithConsecutiveActivitiesForEquilNet(final Scenari plan.addActivity(home2); plan.addActivity(home3); plan.addActivity(home4); - + return plan; } private void addSimpleTransitServices(Scenario scenario) { - + TransitSchedule schedule = scenario.getTransitSchedule(); TransitScheduleFactory f = schedule.getFactory(); final double x = -6000; @@ -239,7 +239,7 @@ private void addSimpleTransitServices(Scenario scenario) { stopFacility2.setLinkId(Id.create(21, Link.class)); schedule.addStopFacility(stopFacility1); schedule.addStopFacility(stopFacility2); - + TransitLine line1 = f.createTransitLine(Id.create(1, TransitLine.class)); NetworkRoute netRoute = RouteUtils.createLinkNetworkRouteImpl(Id.create("14", Link.class), new Id[] { Id.create("20", Link.class) }, Id.create("21", Link.class)); List stops = new ArrayList(); @@ -248,11 +248,11 @@ private void addSimpleTransitServices(Scenario scenario) { TransitRoute route1 = f.createTransitRoute(Id.create(1, TransitRoute.class), netRoute, stops, "bus"); line1.addRoute(route1); schedule.addTransitLine(line1); - + for (int i = 0; i < 20; i++) { route1.addDeparture(f.createDeparture(Id.create(i, Departure.class), 6.0 * 3600 + i * 600)); } - + new CreateVehiclesForSchedule(schedule, scenario.getTransitVehicles()).run(); } diff --git a/matsim/src/test/java/org/matsim/integration/pt/TransitIntegrationTest.java b/matsim/src/test/java/org/matsim/integration/pt/TransitIntegrationTest.java index a83be7eadd9..b6caa9f2372 100644 --- a/matsim/src/test/java/org/matsim/integration/pt/TransitIntegrationTest.java +++ b/matsim/src/test/java/org/matsim/integration/pt/TransitIntegrationTest.java @@ -36,13 +36,13 @@ public class TransitIntegrationTest { @Test(expected = RuntimeException.class) public void testPtInteractionParams() { Config config = ConfigUtils.createConfig(); - config.controler().setOutputDirectory(utils.getOutputDirectory()); + config.controller().setOutputDirectory(utils.getOutputDirectory()); ScoringConfigGroup.ActivityParams params = new ScoringConfigGroup.ActivityParams(PtConstants.TRANSIT_ACTIVITY_TYPE); params.setScoringThisActivityAtAll(true); params.setTypicalDuration(60.0); - config.planCalcScore().addActivityParams(params); + config.scoring().addActivityParams(params); // --- - config.controler().setLastIteration(0); // in case the exception is _not_ thrown, we don't need 100 iterations to find that out ... + config.controller().setLastIteration(0); // in case the exception is _not_ thrown, we don't need 100 iterations to find that out ... // --- Controler controler = new Controler(config); controler.run(); @@ -52,16 +52,16 @@ public void testPtInteractionParams() { @Test(expected = RuntimeException.class) public void testSubpopulationParams() { Config config = ConfigUtils.createConfig(); - config.controler().setOutputDirectory(utils.getOutputDirectory()); + config.controller().setOutputDirectory(utils.getOutputDirectory()); ScoringConfigGroup.ActivityParams params = new ScoringConfigGroup.ActivityParams("home"); params.setScoringThisActivityAtAll(true); params.setTypicalDuration(60.0); - ScoringParameterSet sps = config.planCalcScore().getOrCreateScoringParameters("one"); + ScoringParameterSet sps = config.scoring().getOrCreateScoringParameters("one"); sps.addActivityParams(params); - ScoringParameterSet sps2 = config.planCalcScore().getOrCreateScoringParameters("two"); + ScoringParameterSet sps2 = config.scoring().getOrCreateScoringParameters("two"); sps2.addActivityParams(params); // --- - config.controler().setLastIteration(0); // in case the exception is _not_ thrown, we don't need 100 iterations to find that out ... + config.controller().setLastIteration(0); // in case the exception is _not_ thrown, we don't need 100 iterations to find that out ... config.checkConsistency(); Controler controler = new Controler(config); diff --git a/matsim/src/test/java/org/matsim/integration/replanning/ChangeTripModeIntegrationTest.java b/matsim/src/test/java/org/matsim/integration/replanning/ChangeTripModeIntegrationTest.java index fa69f0182e1..7672fd7769b 100644 --- a/matsim/src/test/java/org/matsim/integration/replanning/ChangeTripModeIntegrationTest.java +++ b/matsim/src/test/java/org/matsim/integration/replanning/ChangeTripModeIntegrationTest.java @@ -81,7 +81,7 @@ public class ChangeTripModeIntegrationTest { final StrategySettings strategySettings = new StrategySettings(Id.create("1", StrategySettings.class)); strategySettings.setStrategyName("ChangeTripMode"); strategySettings.setWeight(1.0); - config.strategy().addStrategySettings(strategySettings); + config.replanning().addStrategySettings(strategySettings); // config.setParam("changeMode", "modes", "car,walk"); String[] str = {"car","walk"} ; config.changeMode().setModes(str); diff --git a/matsim/src/test/java/org/matsim/integration/replanning/ReRoutingIT.java b/matsim/src/test/java/org/matsim/integration/replanning/ReRoutingIT.java index 608381cdd4e..19a67fdd437 100644 --- a/matsim/src/test/java/org/matsim/integration/replanning/ReRoutingIT.java +++ b/matsim/src/test/java/org/matsim/integration/replanning/ReRoutingIT.java @@ -54,8 +54,8 @@ private Scenario loadScenario() { config.qsim().setTimeStepSize(10.0); config.qsim().setStuckTime(100.0); config.qsim().setRemoveStuckVehicles(true); - config.controler().setEventsFileFormats(EnumSet.of(EventsFileFormat.xml)); - config.controler().setLastIteration(1); + config.controller().setEventsFileFormats(EnumSet.of(EventsFileFormat.xml)); + config.controller().setLastIteration(1); /* linear interpolate the into time bins aggregated travel time data to avoid artifacts at the boundaries of time bins: * e.g. a first time bin with aggregated travel time of 90 seconds and a second time bin with 45 seconds; time bin size 60; * i.e. consolidateData-method in TravelTimeCalculator will accept this difference; imagine an requested route starting 2 @@ -79,10 +79,10 @@ private Scenario loadScenario() { @Test public void testReRoutingDijkstra() throws MalformedURLException { Scenario scenario = this.loadScenario(); - scenario.getConfig().controler().setRoutingAlgorithmType(RoutingAlgorithmType.Dijkstra); + scenario.getConfig().controller().setRoutingAlgorithmType(RoutingAlgorithmType.Dijkstra); Controler controler = new Controler(scenario); - controler.getConfig().controler().setCreateGraphs(false); - controler.getConfig().controler().setDumpDataAtEnd(false); + controler.getConfig().controller().setCreateGraphs(false); + controler.getConfig().controller().setDumpDataAtEnd(false); controler.run(); this.evaluate(); } @@ -90,10 +90,10 @@ public void testReRoutingDijkstra() throws MalformedURLException { @Test public void testReRoutingAStarLandmarks() throws MalformedURLException { Scenario scenario = this.loadScenario(); - scenario.getConfig().controler().setRoutingAlgorithmType(RoutingAlgorithmType.AStarLandmarks); + scenario.getConfig().controller().setRoutingAlgorithmType(RoutingAlgorithmType.AStarLandmarks); Controler controler = new Controler(scenario); - controler.getConfig().controler().setCreateGraphs(false); - controler.getConfig().controler().setDumpDataAtEnd(false); + controler.getConfig().controller().setCreateGraphs(false); + controler.getConfig().controller().setDumpDataAtEnd(false); controler.run(); this.evaluate(); } @@ -101,10 +101,10 @@ public void testReRoutingAStarLandmarks() throws MalformedURLException { @Test public void testReRoutingSpeedyALT() throws MalformedURLException { Scenario scenario = this.loadScenario(); - scenario.getConfig().controler().setRoutingAlgorithmType(RoutingAlgorithmType.SpeedyALT); + scenario.getConfig().controller().setRoutingAlgorithmType(RoutingAlgorithmType.SpeedyALT); Controler controler = new Controler(scenario); - controler.getConfig().controler().setCreateGraphs(false); - controler.getConfig().controler().setDumpDataAtEnd(false); + controler.getConfig().controller().setCreateGraphs(false); + controler.getConfig().controller().setDumpDataAtEnd(false); controler.run(); this.evaluate("plans_speedyALT.xml.gz"); } diff --git a/matsim/src/test/java/org/matsim/integration/replanning/ResumableRunsIT.java b/matsim/src/test/java/org/matsim/integration/replanning/ResumableRunsIT.java index 67583d66662..ee859ca7b41 100644 --- a/matsim/src/test/java/org/matsim/integration/replanning/ResumableRunsIT.java +++ b/matsim/src/test/java/org/matsim/integration/replanning/ResumableRunsIT.java @@ -58,32 +58,32 @@ public class ResumableRunsIT { @Test public void testResumableRuns() throws MalformedURLException { Config config = utils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("equil"), "config.xml")); - config.controler().setLastIteration(11); - config.controler().setWriteEventsInterval(1); + config.controller().setLastIteration(11); + config.controller().setWriteEventsInterval(1); config.global().setNumberOfThreads(1); // only use one thread to rule out other disturbances for the test - config.controler().setWritePlansInterval(10); + config.controller().setWritePlansInterval(10); // run1 - config.controler().setOutputDirectory(utils.getOutputDirectory() + "/run1/"); + config.controller().setOutputDirectory(utils.getOutputDirectory() + "/run1/"); /* * The input plans file is not sorted. After switching from TreeMap to LinkedHashMap - * to store the persons in the population, we have to sort the population manually. + * to store the persons in the population, we have to sort the population manually. * cdobler, oct'11 */ Scenario scenario1 = ScenarioUtils.loadScenario(config); PopulationUtils.sortPersons(scenario1.getPopulation()); Controler controler1 = new Controler(scenario1); - controler1.getConfig().controler().setCreateGraphs(false); - controler1.getConfig().controler().setDumpDataAtEnd(false); + controler1.getConfig().controller().setCreateGraphs(false); + controler1.getConfig().controller().setDumpDataAtEnd(false); controler1.run(); // run2 - config.controler().setOutputDirectory(utils.getOutputDirectory() + "/run2/"); - config.controler().setFirstIteration(10); + config.controller().setOutputDirectory(utils.getOutputDirectory() + "/run2/"); + config.controller().setFirstIteration(10); config.plans().setInputFile(new File(utils.getOutputDirectory() + "/run1/ITERS/it.10/10.plans.xml.gz").toURI().toURL().toString()); Controler controler2 = new Controler(config); - controler2.getConfig().controler().setCreateGraphs(false); - controler2.getConfig().controler().setDumpDataAtEnd(false); + controler2.getConfig().controller().setCreateGraphs(false); + controler2.getConfig().controller().setDumpDataAtEnd(false); controler2.run(); // comparison diff --git a/matsim/src/test/java/org/matsim/modules/ScoreStatsModuleTest.java b/matsim/src/test/java/org/matsim/modules/ScoreStatsModuleTest.java index 5c8ed368e94..4951ffdf3c7 100644 --- a/matsim/src/test/java/org/matsim/modules/ScoreStatsModuleTest.java +++ b/matsim/src/test/java/org/matsim/modules/ScoreStatsModuleTest.java @@ -75,9 +75,9 @@ public void testScoreStats() { Config config = utils.loadConfig("test/scenarios/equil/config.xml"); config.qsim().setUsingFastCapacityUpdate(this.isUsingFastCapacityUpdate); - config.plansCalcRoute().setAccessEgressType(this.isInsertingAccessEgressWalk? AccessEgressType.accessEgressModeToLink : AccessEgressType.none); + config.routing().setAccessEgressType(this.isInsertingAccessEgressWalk? AccessEgressType.accessEgressModeToLink : AccessEgressType.none); - config.controler().setLastIteration(1); + config.controller().setLastIteration(1); Controler controler = new Controler(config); controler.addOverridingModule(new AbstractModule() { @Override @@ -107,7 +107,7 @@ public void notifyShutdown(ShutdownEvent event) { // } // yy the following is retrofitted from an older double[][] data structure and thus messy. Please improve it. kai, nov'16 - if ( config.plansCalcRoute().getAccessEgressType().equals(AccessEgressType.none) ) { + if ( config.routing().getAccessEgressType().equals(AccessEgressType.none) ) { { Double[] array = result.get(ScoreItem.worst).values().toArray(new Double[0]) ; Assert.assertEquals(64.75686659291274, array[0], DELTA); diff --git a/matsim/src/test/java/org/matsim/pt/analysis/TransitLoadIntegrationTest.java b/matsim/src/test/java/org/matsim/pt/analysis/TransitLoadIntegrationTest.java index 69dd39711d0..298664f0f7f 100644 --- a/matsim/src/test/java/org/matsim/pt/analysis/TransitLoadIntegrationTest.java +++ b/matsim/src/test/java/org/matsim/pt/analysis/TransitLoadIntegrationTest.java @@ -46,7 +46,7 @@ public class TransitLoadIntegrationTest { @Test public void testIntegration() { final Config cfg = this.util.loadConfig("test/scenarios/pt-tutorial/0.config.xml"); - cfg.controler().setLastIteration(0); + cfg.controller().setLastIteration(0); cfg.plans().setHandlingOfPlansWithoutRoutingMode(HandlingOfPlansWithoutRoutingMode.useMainModeIdentifier); final Scenario s = ScenarioUtils.loadScenario(cfg); final Controler c = new Controler(s); @@ -59,10 +59,10 @@ public void notifyStartup(StartupEvent event) { } }); - cfg.controler().setWritePlansInterval(0); - c.getConfig().controler().setCreateGraphs(false); - c.getConfig().controler().setWriteEventsInterval(0); - c.getConfig().controler().setDumpDataAtEnd(false); + cfg.controller().setWritePlansInterval(0); + c.getConfig().controller().setCreateGraphs(false); + c.getConfig().controller().setWriteEventsInterval(0); + c.getConfig().controller().setDumpDataAtEnd(false); c.run(); TransitLine line = s.getTransitSchedule().getTransitLines().get(Id.create("Blue Line", TransitLine.class)); diff --git a/matsim/src/test/java/org/matsim/pt/router/AdaptedTransitRouterNetworkTravelTimeCostTest.java b/matsim/src/test/java/org/matsim/pt/router/AdaptedTransitRouterNetworkTravelTimeCostTest.java index f4eacd02b10..abaf360b0e7 100644 --- a/matsim/src/test/java/org/matsim/pt/router/AdaptedTransitRouterNetworkTravelTimeCostTest.java +++ b/matsim/src/test/java/org/matsim/pt/router/AdaptedTransitRouterNetworkTravelTimeCostTest.java @@ -45,8 +45,8 @@ public class AdaptedTransitRouterNetworkTravelTimeCostTest { f.init(); //create the adapted router - TransitRouterConfig conf = new TransitRouterConfig(f.scenario.getConfig().planCalcScore(), - f.scenario.getConfig().plansCalcRoute(), f.scenario.getConfig().transitRouter(), + TransitRouterConfig conf = new TransitRouterConfig(f.scenario.getConfig().scoring(), + f.scenario.getConfig().routing(), f.scenario.getConfig().transitRouter(), f.scenario.getConfig().vspExperimental()); TransitRouterNetworkTravelTimeAndDisutility tc = new TransitRouterNetworkTravelTimeAndDisutility(conf); TransitRouterImpl router = new TransitRouterImpl(conf, f.schedule) ; @@ -68,8 +68,8 @@ public class AdaptedTransitRouterNetworkTravelTimeCostTest { @Test public void testVehArrivalTime() { Fixture f = new Fixture(); f.init(); - TransitRouterConfig conf = new TransitRouterConfig(f.scenario.getConfig().planCalcScore(), - f.scenario.getConfig().plansCalcRoute(), f.scenario.getConfig().transitRouter(), + TransitRouterConfig conf = new TransitRouterConfig(f.scenario.getConfig().scoring(), + f.scenario.getConfig().routing(), f.scenario.getConfig().transitRouter(), f.scenario.getConfig().vspExperimental()); TransitRouterNetworkTravelTimeAndDisutility tc = new TransitRouterNetworkTravelTimeAndDisutility(conf); TransitRouterImpl router = new TransitRouterImpl(conf, f.schedule) ; @@ -113,8 +113,8 @@ public class AdaptedTransitRouterNetworkTravelTimeCostTest { @Test public void testTravelTimeAfterMidnight() { Fixture f = new Fixture(); f.init(); - TransitRouterConfig conf = new TransitRouterConfig(f.scenario.getConfig().planCalcScore(), - f.scenario.getConfig().plansCalcRoute(), f.scenario.getConfig().transitRouter(), + TransitRouterConfig conf = new TransitRouterConfig(f.scenario.getConfig().scoring(), + f.scenario.getConfig().routing(), f.scenario.getConfig().transitRouter(), f.scenario.getConfig().vspExperimental()); TransitRouterNetworkTravelTimeAndDisutility tc = new TransitRouterNetworkTravelTimeAndDisutility(conf); TransitRouterImpl router = new TransitRouterImpl(conf, f.schedule) ; @@ -151,8 +151,8 @@ public class AdaptedTransitRouterNetworkTravelTimeCostTest { @Test public void testTravelCostLineSwitch() { Fixture f = new Fixture(); f.init(); - TransitRouterConfig conf = new TransitRouterConfig(f.scenario.getConfig().planCalcScore(), - f.scenario.getConfig().plansCalcRoute(), f.scenario.getConfig().transitRouter(), + TransitRouterConfig conf = new TransitRouterConfig(f.scenario.getConfig().scoring(), + f.scenario.getConfig().routing(), f.scenario.getConfig().transitRouter(), f.scenario.getConfig().vspExperimental()); TransitRouterNetworkTravelTimeAndDisutility tc = new TransitRouterNetworkTravelTimeAndDisutility(conf); TransitRouterImpl router = new TransitRouterImpl(conf, f.schedule) ; @@ -182,8 +182,8 @@ public class AdaptedTransitRouterNetworkTravelTimeCostTest { @Test public void testTravelCostLineSwitch_AdditionalTransferTime() { Fixture f = new Fixture(); f.init(); - TransitRouterConfig conf = new TransitRouterConfig(f.scenario.getConfig().planCalcScore(), - f.scenario.getConfig().plansCalcRoute(), f.scenario.getConfig().transitRouter(), + TransitRouterConfig conf = new TransitRouterConfig(f.scenario.getConfig().scoring(), + f.scenario.getConfig().routing(), f.scenario.getConfig().transitRouter(), f.scenario.getConfig().vspExperimental()); TransitRouterNetworkTravelTimeAndDisutility tc = new TransitRouterNetworkTravelTimeAndDisutility(conf); TransitRouterImpl router = new TransitRouterImpl(conf, f.schedule) ; diff --git a/matsim/src/test/java/org/matsim/pt/router/TransitRouterCustomDataTest.java b/matsim/src/test/java/org/matsim/pt/router/TransitRouterCustomDataTest.java index ecd8b62af48..da34930a8be 100644 --- a/matsim/src/test/java/org/matsim/pt/router/TransitRouterCustomDataTest.java +++ b/matsim/src/test/java/org/matsim/pt/router/TransitRouterCustomDataTest.java @@ -32,7 +32,6 @@ import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.network.Link; -import org.matsim.api.core.v01.population.Leg; import org.matsim.api.core.v01.population.Person; import org.matsim.api.core.v01.population.PlanElement; import org.matsim.core.config.ConfigUtils; @@ -57,17 +56,17 @@ public void testCustomDataIntegration() { Scenario scenario = ScenarioUtils.createScenario(ConfigUtils.createConfig()); scenario.getConfig().transit().setUseTransit(true); createTestSchedule(scenario); - - TransitRouterConfig trConfig = new TransitRouterConfig(scenario.getConfig().planCalcScore(), - scenario.getConfig().plansCalcRoute(), scenario.getConfig().transitRouter(), + + TransitRouterConfig trConfig = new TransitRouterConfig(scenario.getConfig().scoring(), + scenario.getConfig().routing(), scenario.getConfig().transitRouter(), scenario.getConfig().vspExperimental()); trConfig.setBeelineWalkSpeed(0.1); // something very slow, so the agent does not walk over night trConfig.setSearchRadius(200); - + TransitRouterNetworkTravelTimeAndDisutility transitRouterNetworkTravelTimeAndDisutility = new TransitRouterNetworkTravelTimeAndDisutility(trConfig); - + MockingTransitTravelDisutility disutility = new MockingTransitTravelDisutility(transitRouterNetworkTravelTimeAndDisutility); - + TransitRouterNetwork transitNetwork = TransitRouterNetwork.createFromSchedule(scenario.getTransitSchedule(), trConfig.getBeelineWalkConnectionDistance()); TransitRouterImpl router = new TransitRouterImpl(trConfig, new PreparedTransitSchedule(scenario.getTransitSchedule()), transitNetwork, transitRouterNetworkTravelTimeAndDisutility, disutility); @@ -75,13 +74,13 @@ public void testCustomDataIntegration() { double x = -100; List legs = router.calcRoute(DefaultRoutingRequest.withoutAttributes(new FakeFacility( new Coord(x, (double) 0)), new FakeFacility( new Coord((double) 3100, (double) 0)), 5.9*3600, null)); Assert.assertNull("The router should not find a route and return null, but did return something else.", legs); - + /* the following is not really nice as a test, but I had to somehow * keep track of the internal state and have to replay this now * to ensure everything works as expected... */ Assert.assertEquals(8, disutility.states.size()); - Assert.assertEquals("[[1>2 @ 22240.0]]", disutility.states.get(0)); // first link to be expanded: from stop 1 to stop 2, line 1 + Assert.assertEquals("[[1>2 @ 22240.0]]", disutility.states.get(0)); // first link to be expanded: from stop 1 to stop 2, line 1 Assert.assertEquals("[[1>3 @ 22240.0]]", disutility.states.get(1)); // now from stop 1 to stop 3, line 2 Assert.assertEquals("[[1>2 @ 22240.0], [2>3 @ 108300.0]]", disutility.states.get(2)); // from stop 2 to stop 3, coming from stop 1 before, line 1 Assert.assertEquals("[[1>2 @ 22240.0], [2>3 @ 108300.0], [3>4 @ 108600.0]]", disutility.states.get(3)); // continuing on line 1 @@ -89,19 +88,19 @@ public void testCustomDataIntegration() { Assert.assertEquals("[[1>3 @ 22240.0], [3>5 @ 108690.0]]", disutility.states.get(5)); // continue on line 2 Assert.assertEquals("[[1>3 @ 22240.0], [3>3 @ 108690.0]]", disutility.states.get(6)); // transfer at stop 3, coming from line 2, should be a dead end Assert.assertEquals("[[1>2 @ 22240.0], [2>3 @ 108300.0], [3>4 @ 108600.0], [4>5 @ 108900.0]]", disutility.states.get(7)); // continue on line 1 - + /* important to notice: * state[4] should be ignored, as it is a worse result than previously found solutions. * The ignoring of the state can be seen e.g. in state[5] which continues on line 2 state[4] switched to, * but using the original travel sequence. */ } - + private static class MockingTransitTravelDisutility implements TransitTravelDisutility { private final TransitRouterNetworkTravelTimeAndDisutility routerDisutility; private ArrayList states = new ArrayList<>(); - + public MockingTransitTravelDisutility(final TransitRouterNetworkTravelTimeAndDisutility routerDisutility) { this.routerDisutility = routerDisutility; } @@ -111,7 +110,7 @@ public double getLinkTravelDisutility(Link link, double time, Person person, Vehicle vehicle, CustomDataManager dataManager) { double val = this.routerDisutility.getLinkTravelDisutility(link, time, person, vehicle, dataManager); - System.out.print("handling link " + ((TransitRouterNetworkNode) link.getFromNode()).getStop().getStopFacility().getId() + System.out.print("handling link " + ((TransitRouterNetworkNode) link.getFromNode()).getStop().getStopFacility().getId() + ">" + ((TransitRouterNetworkNode) link.getToNode()).getStop().getStopFacility().getId()); ArrayList links = new ArrayList<>(); Object o = dataManager.getFromNodeCustomData(); @@ -123,10 +122,10 @@ public double getLinkTravelDisutility(Link link, double time, System.out.println(" : " + newState); this.states.add(newState); dataManager.setToNodeCustomData(links); - + return val; } - + @Override public double getWalkTravelDisutility(Person person, Coord coord, Coord toCoord) { return routerDisutility.getWalkTravelDisutility(person, coord, toCoord); @@ -136,9 +135,9 @@ public double getWalkTravelDisutility(Person person, Coord coord, Coord toCoord) public double getWalkTravelTime(Person person, Coord coord, Coord toCoord) { return routerDisutility.getWalkTravelTime(person, coord, toCoord); } - + } - + private static class LoggerData { private final Link link; private final double time; @@ -148,25 +147,25 @@ public LoggerData(final Link link, final double time) { } @Override public String toString() { - return "[" + ((TransitRouterNetworkNode) link.getFromNode()).getStop().getStopFacility().getId() + return "[" + ((TransitRouterNetworkNode) link.getFromNode()).getStop().getStopFacility().getId() + ">" + ((TransitRouterNetworkNode) link.getToNode()).getStop().getStopFacility().getId() + " @ " + time + "]"; } } - + /** * Creates the following test schedule: - * - * + * + * * (2) (4) * / \ / \ * / \ / \ * / \ / \ * (1)-------(3)-------(5) - * + * * line 1 traveling from 1 to 2 to 3 to 4 to 5 * line 2 traveling from 1 to 3 to 5, slower from 1 to 3 than line 1, faster from 3 to 5 and from 5 to 7 - * + * */ private final void createTestSchedule(final Scenario scenario) { TransitSchedule schedule = scenario.getTransitSchedule(); @@ -177,13 +176,13 @@ private final void createTestSchedule(final Scenario scenario) { TransitStopFacility f3 = f.createTransitStopFacility(Id.create("3", TransitStopFacility.class), new Coord((double) 1000, (double) 0), false); TransitStopFacility f4 = f.createTransitStopFacility(Id.create("4", TransitStopFacility.class), new Coord((double) 1500, (double) 500), false); TransitStopFacility f5 = f.createTransitStopFacility(Id.create("5", TransitStopFacility.class), new Coord((double) 2000, (double) 0), false); - + schedule.addStopFacility(f1); schedule.addStopFacility(f2); schedule.addStopFacility(f3); schedule.addStopFacility(f4); schedule.addStopFacility(f5); - + TransitLine line1 = f.createTransitLine(Id.create("1", TransitLine.class)); List stops = new ArrayList<>(); stops.add(f.createTransitRouteStopBuilder(f1).departureOffset(0.0).build()); @@ -195,7 +194,7 @@ private final void createTestSchedule(final Scenario scenario) { line1.addRoute(route1); schedule.addTransitLine(line1); route1.addDeparture(f.createDeparture(Id.create("1", Departure.class), 6.0*3600)); - + TransitLine line2 = f.createTransitLine(Id.create("2", TransitLine.class)); List stops2 = new ArrayList<>(); stops2.add(f.createTransitRouteStopBuilder(f1).departureOffset(0.0).build()); diff --git a/matsim/src/test/java/org/matsim/pt/router/TransitRouterImplTest.java b/matsim/src/test/java/org/matsim/pt/router/TransitRouterImplTest.java index 3e9ca095fef..ad312f938b2 100644 --- a/matsim/src/test/java/org/matsim/pt/router/TransitRouterImplTest.java +++ b/matsim/src/test/java/org/matsim/pt/router/TransitRouterImplTest.java @@ -155,8 +155,8 @@ public void testFromToSameStop() { public void testDirectWalkCheaper() { Fixture f = new Fixture(); f.init(); - TransitRouterConfig trConfig = new TransitRouterConfig(f.scenario.getConfig().planCalcScore(), - f.scenario.getConfig().plansCalcRoute(), f.scenario.getConfig().transitRouter(), + TransitRouterConfig trConfig = new TransitRouterConfig(f.scenario.getConfig().scoring(), + f.scenario.getConfig().routing(), f.scenario.getConfig().transitRouter(), f.scenario.getConfig().vspExperimental()); TransitRouter router = createTransitRouter(f.schedule, trConfig, routerType); Coord fromCoord = new Coord((double) 4000, (double) 3000); @@ -169,8 +169,8 @@ public void testDirectWalkCheaper() { public void testSingleLine_DifferentWaitingTime() { Fixture f = new Fixture(); f.init(); - TransitRouterConfig trConfig = new TransitRouterConfig(f.scenario.getConfig().planCalcScore(), - f.scenario.getConfig().plansCalcRoute(), f.scenario.getConfig().transitRouter(), + TransitRouterConfig trConfig = new TransitRouterConfig(f.scenario.getConfig().scoring(), + f.scenario.getConfig().routing(), f.scenario.getConfig().transitRouter(), f.scenario.getConfig().vspExperimental()); TransitRouter router = createTransitRouter(f.schedule, trConfig, routerType); Coord fromCoord = new Coord((double) 4000, (double) 5002); @@ -193,8 +193,8 @@ public void testSingleLine_DifferentWaitingTime() { public void testLineChange() { Fixture f = new Fixture(); f.init(); - TransitRouterConfig trConfig = new TransitRouterConfig(f.scenario.getConfig().planCalcScore(), - f.scenario.getConfig().plansCalcRoute(), f.scenario.getConfig().transitRouter(), + TransitRouterConfig trConfig = new TransitRouterConfig(f.scenario.getConfig().scoring(), + f.scenario.getConfig().routing(), f.scenario.getConfig().transitRouter(), f.scenario.getConfig().vspExperimental()); TransitRouter router = createTransitRouter(f.schedule, trConfig, routerType); Coord toCoord = new Coord((double) 16100, (double) 10050); @@ -230,8 +230,8 @@ public void testLineChange() { public void testTransferWalkDistance(){ Fixture f = new Fixture(); f.init(); - TransitRouterConfig config = new TransitRouterConfig(f.scenario.getConfig().planCalcScore(), - f.scenario.getConfig().plansCalcRoute(), f.scenario.getConfig().transitRouter(), + TransitRouterConfig config = new TransitRouterConfig(f.scenario.getConfig().scoring(), + f.scenario.getConfig().routing(), f.scenario.getConfig().transitRouter(), f.scenario.getConfig().vspExperimental()); TransitRouter router = createTransitRouter(f.schedule, config, routerType); Coord fromCoord = new Coord((double) 3800, (double) 5100); @@ -243,7 +243,7 @@ public void testTransferWalkDistance(){ Leg leg3 = (Leg) legs.get(3); TransitPassengerRoute route3 = (TransitPassengerRoute) leg3.getRoute(); Coord coord3 = f.schedule.getFacilities().get(route3.getAccessStopId()).getCoord(); - double beelineFactor = f.scenario.getConfig().plansCalcRoute().getModeRoutingParams().get(TransportMode.walk).getBeelineDistanceFactor(); + double beelineFactor = f.scenario.getConfig().routing().getModeRoutingParams().get(TransportMode.walk).getBeelineDistanceFactor(); assertEquals(CoordUtils.calcEuclideanDistance(coord1, coord3) * beelineFactor, ((Leg)legs.get(2)).getRoute().getDistance(), MatsimTestUtils.EPSILON); } @@ -252,8 +252,8 @@ public void testTransferWalkDistance(){ public void testFasterAlternative() { Fixture f = new Fixture(); f.init(); - TransitRouterConfig trConfig = new TransitRouterConfig(f.scenario.getConfig().planCalcScore(), - f.scenario.getConfig().plansCalcRoute(), f.scenario.getConfig().transitRouter(), + TransitRouterConfig trConfig = new TransitRouterConfig(f.scenario.getConfig().scoring(), + f.scenario.getConfig().routing(), f.scenario.getConfig().transitRouter(), f.scenario.getConfig().vspExperimental()); TransitRouter router = createTransitRouter(f.schedule, trConfig, routerType); Coord toCoord = new Coord((double) 28100, (double) 4950); @@ -295,8 +295,8 @@ public void testTransferWeights() { */ Fixture f = new Fixture(); f.init(); - TransitRouterConfig trConfig = new TransitRouterConfig(f.scenario.getConfig().planCalcScore(), - f.scenario.getConfig().plansCalcRoute(), f.scenario.getConfig().transitRouter(), + TransitRouterConfig trConfig = new TransitRouterConfig(f.scenario.getConfig().scoring(), + f.scenario.getConfig().routing(), f.scenario.getConfig().transitRouter(), f.scenario.getConfig().vspExperimental()); trConfig.setUtilityOfLineSwitch_utl(0); TransitRouter router = createTransitRouter(f.schedule, trConfig, routerType); @@ -331,8 +331,8 @@ public void testTransferTime() { */ Fixture f = new Fixture(); f.init(); - TransitRouterConfig trConfig = new TransitRouterConfig(f.scenario.getConfig().planCalcScore(), - f.scenario.getConfig().plansCalcRoute(), f.scenario.getConfig().transitRouter(), + TransitRouterConfig trConfig = new TransitRouterConfig(f.scenario.getConfig().scoring(), + f.scenario.getConfig().routing(), f.scenario.getConfig().transitRouter(), f.scenario.getConfig().vspExperimental()); trConfig.setUtilityOfLineSwitch_utl(0); assertEquals(0, trConfig.getAdditionalTransferTime(), 1e-8); @@ -361,8 +361,8 @@ public void testTransferTime() { public void testAfterMidnight() { Fixture f = new Fixture(); f.init(); - TransitRouterConfig trConfig = new TransitRouterConfig(f.scenario.getConfig().planCalcScore(), - f.scenario.getConfig().plansCalcRoute(), f.scenario.getConfig().transitRouter(), + TransitRouterConfig trConfig = new TransitRouterConfig(f.scenario.getConfig().scoring(), + f.scenario.getConfig().routing(), f.scenario.getConfig().transitRouter(), f.scenario.getConfig().vspExperimental()); trConfig.setBeelineWalkSpeed(0.1); // something very slow, so the agent does not walk over night TransitRouter router = createTransitRouter(f.schedule, trConfig, routerType); @@ -391,8 +391,8 @@ public void testAfterMidnight() { public void testCoordFarAway() { Fixture f = new Fixture(); f.init(); - final TransitRouterConfig trConfig = new TransitRouterConfig(f.scenario.getConfig().planCalcScore(), - f.scenario.getConfig().plansCalcRoute(), f.scenario.getConfig().transitRouter(), + final TransitRouterConfig trConfig = new TransitRouterConfig(f.scenario.getConfig().scoring(), + f.scenario.getConfig().routing(), f.scenario.getConfig().transitRouter(), f.scenario.getConfig().vspExperimental() ); TransitRouter router = createTransitRouter(f.schedule, trConfig, routerType); double x = +42000; @@ -490,7 +490,7 @@ public void testLongTransferTime() { Assert.assertEquals(1900.0, legDuration, 0.0); RoutingModule walkRoutingModule = DefaultRoutingModules.createTeleportationRouter(TransportMode.walk, f.scenario, - f.config.plansCalcRoute().getModeRoutingParams().get(TransportMode.walk)); + f.config.routing().getModeRoutingParams().get(TransportMode.walk)); TransitRouterWrapper wrapper = new TransitRouterWrapper( router, @@ -526,7 +526,7 @@ public void testLongTransferTime() { Assert.assertEquals(5500.0, legDuration, 0.0); RoutingModule walkRoutingModule = DefaultRoutingModules.createTeleportationRouter(TransportMode.walk, f.scenario, - f.config.plansCalcRoute().getModeRoutingParams().get(TransportMode.walk)); + f.config.routing().getModeRoutingParams().get(TransportMode.walk)); TransitRouterWrapper wrapper = new TransitRouterWrapper( router, @@ -555,7 +555,7 @@ public void testLongTransferTime() { Assert.assertNull("The router should not find a route and return null, but did return something else.", legs); RoutingModule walkRoutingModule = DefaultRoutingModules.createTeleportationRouter(TransportMode.walk, f.scenario, - f.config.plansCalcRoute().getModeRoutingParams().get(TransportMode.walk)); + f.config.routing().getModeRoutingParams().get(TransportMode.walk)); TransitRouterWrapper wrapper = new TransitRouterWrapper( router, @@ -629,8 +629,8 @@ private static class WalkFixture { /*package*/ WalkFixture() { this.scenario = (MutableScenario) ScenarioUtils.createScenario(ConfigUtils.createConfig()); this.scenario.getConfig().transit().setUseTransit(true); - this.routerConfig = new TransitRouterConfig(this.scenario.getConfig().planCalcScore(), - this.scenario.getConfig().plansCalcRoute(), this.scenario.getConfig().transitRouter(), + this.routerConfig = new TransitRouterConfig(this.scenario.getConfig().scoring(), + this.scenario.getConfig().routing(), this.scenario.getConfig().transitRouter(), this.scenario.getConfig().vspExperimental()); this.routerConfig.setSearchRadius(500.0); this.routerConfig.setBeelineWalkConnectionDistance(100.0); @@ -780,7 +780,7 @@ private static class TransferFixture { this.config.transitRouter().setAdditionalTransferTime(additionalTransferTime); this.scenario = ScenarioUtils.createScenario(this.config); this.scenario.getConfig().transit().setUseTransit(true); - this.routerConfig = new TransitRouterConfig(this.scenario.getConfig().planCalcScore(), this.scenario.getConfig().plansCalcRoute(), this.scenario.getConfig().transitRouter(), this.scenario.getConfig().vspExperimental()); + this.routerConfig = new TransitRouterConfig(this.scenario.getConfig().scoring(), this.scenario.getConfig().routing(), this.scenario.getConfig().transitRouter(), this.scenario.getConfig().vspExperimental()); this.routerConfig.setSearchRadius(500.0); this.routerConfig.setBeelineWalkConnectionDistance(100.0); this.routerConfig.setBeelineWalkSpeed(1.0); // so the agents can walk the distance in 100 seconds diff --git a/matsim/src/test/java/org/matsim/pt/router/TransitRouterModuleTest.java b/matsim/src/test/java/org/matsim/pt/router/TransitRouterModuleTest.java index 11b6c5b8226..3eb275ea9f6 100644 --- a/matsim/src/test/java/org/matsim/pt/router/TransitRouterModuleTest.java +++ b/matsim/src/test/java/org/matsim/pt/router/TransitRouterModuleTest.java @@ -22,9 +22,9 @@ public class TransitRouterModuleTest { public void testTransitRoutingAlgorithm_DependencyInjection_Dijkstra() { Fixture f = new Fixture(); f.config.transit().setRoutingAlgorithmType(TransitRoutingAlgorithmType.DijkstraBased); - f.config.controler().setOutputDirectory(this.utils.getOutputDirectory()); - f.config.controler().setLastIteration(0); - f.config.controler().setDumpDataAtEnd(false); + f.config.controller().setOutputDirectory(this.utils.getOutputDirectory()); + f.config.controller().setLastIteration(0); + f.config.controller().setDumpDataAtEnd(false); Controler controler = new Controler(f.scenario); controler.addOverridingModule(new AbstractModule() { @@ -44,9 +44,9 @@ public void install() { public void testTransitRoutingAlgorithm_DependencyInjection_Raptor() { Fixture f = new Fixture(); f.config.transit().setRoutingAlgorithmType(TransitRoutingAlgorithmType.SwissRailRaptor); - f.config.controler().setOutputDirectory(this.utils.getOutputDirectory()); - f.config.controler().setLastIteration(0); - f.config.controler().setDumpDataAtEnd(false); + f.config.controller().setOutputDirectory(this.utils.getOutputDirectory()); + f.config.controller().setLastIteration(0); + f.config.controller().setDumpDataAtEnd(false); Controler controler = new Controler(f.scenario); controler.addOverridingModule(new AbstractModule() { @@ -71,4 +71,4 @@ public void run() { } } -} \ No newline at end of file +} diff --git a/matsim/src/test/java/org/matsim/pt/router/TransitRouterNetworkTravelTimeCostTest.java b/matsim/src/test/java/org/matsim/pt/router/TransitRouterNetworkTravelTimeCostTest.java index 901f33e5737..5e2afb97a50 100644 --- a/matsim/src/test/java/org/matsim/pt/router/TransitRouterNetworkTravelTimeCostTest.java +++ b/matsim/src/test/java/org/matsim/pt/router/TransitRouterNetworkTravelTimeCostTest.java @@ -34,8 +34,8 @@ public class TransitRouterNetworkTravelTimeCostTest { @Test public void testTravelTime() { Fixture f = new Fixture(); f.init(); - TransitRouterConfig conf = new TransitRouterConfig(f.scenario.getConfig().planCalcScore(), - f.scenario.getConfig().plansCalcRoute(), f.scenario.getConfig().transitRouter(), + TransitRouterConfig conf = new TransitRouterConfig(f.scenario.getConfig().scoring(), + f.scenario.getConfig().routing(), f.scenario.getConfig().transitRouter(), f.scenario.getConfig().vspExperimental()); TransitRouterNetworkTravelTimeAndDisutility tc = new TransitRouterNetworkTravelTimeAndDisutility(conf); TransitRouterImpl router = new TransitRouterImpl(conf, f.schedule); @@ -55,8 +55,8 @@ public class TransitRouterNetworkTravelTimeCostTest { @Test public void testWaitingTime() { Fixture f = new Fixture(); f.init(); - TransitRouterConfig conf = new TransitRouterConfig(f.scenario.getConfig().planCalcScore(), - f.scenario.getConfig().plansCalcRoute(), f.scenario.getConfig().transitRouter(), + TransitRouterConfig conf = new TransitRouterConfig(f.scenario.getConfig().scoring(), + f.scenario.getConfig().routing(), f.scenario.getConfig().transitRouter(), f.scenario.getConfig().vspExperimental()); TransitRouterNetworkTravelTimeAndDisutility tc = new TransitRouterNetworkTravelTimeAndDisutility(conf); TransitRouterImpl router = new TransitRouterImpl(conf, f.schedule); @@ -79,8 +79,8 @@ public class TransitRouterNetworkTravelTimeCostTest { @Test public void testTravelTimeAfterMidnight() { Fixture f = new Fixture(); f.init(); - TransitRouterConfig conf = new TransitRouterConfig(f.scenario.getConfig().planCalcScore(), - f.scenario.getConfig().plansCalcRoute(), f.scenario.getConfig().transitRouter(), + TransitRouterConfig conf = new TransitRouterConfig(f.scenario.getConfig().scoring(), + f.scenario.getConfig().routing(), f.scenario.getConfig().transitRouter(), f.scenario.getConfig().vspExperimental()); TransitRouterNetworkTravelTimeAndDisutility tc = new TransitRouterNetworkTravelTimeAndDisutility(conf); TransitRouterImpl router = new TransitRouterImpl(conf, f.schedule); @@ -105,8 +105,8 @@ public class TransitRouterNetworkTravelTimeCostTest { @Test public void testTravelCostLineSwitch() { Fixture f = new Fixture(); f.init(); - TransitRouterConfig conf = new TransitRouterConfig(f.scenario.getConfig().planCalcScore(), - f.scenario.getConfig().plansCalcRoute(), f.scenario.getConfig().transitRouter(), + TransitRouterConfig conf = new TransitRouterConfig(f.scenario.getConfig().scoring(), + f.scenario.getConfig().routing(), f.scenario.getConfig().transitRouter(), f.scenario.getConfig().vspExperimental()); TransitRouterNetworkTravelTimeAndDisutility tc = new TransitRouterNetworkTravelTimeAndDisutility(conf); TransitRouterImpl router = new TransitRouterImpl(conf, f.schedule); @@ -134,8 +134,8 @@ public class TransitRouterNetworkTravelTimeCostTest { @Test public void testTravelCostLineSwitch_AdditionalTransferTime() { Fixture f = new Fixture(); f.init(); - TransitRouterConfig conf = new TransitRouterConfig(f.scenario.getConfig().planCalcScore(), - f.scenario.getConfig().plansCalcRoute(), f.scenario.getConfig().transitRouter(), + TransitRouterConfig conf = new TransitRouterConfig(f.scenario.getConfig().scoring(), + f.scenario.getConfig().routing(), f.scenario.getConfig().transitRouter(), f.scenario.getConfig().vspExperimental()); TransitRouterNetworkTravelTimeAndDisutility tc = new TransitRouterNetworkTravelTimeAndDisutility(conf); TransitRouterImpl router = new TransitRouterImpl(conf, f.schedule); diff --git a/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitScheduleReprojectionIOTest.java b/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitScheduleReprojectionIOTest.java index 45377793872..1ba6c69e18a 100644 --- a/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitScheduleReprojectionIOTest.java +++ b/matsim/src/test/java/org/matsim/pt/transitSchedule/TransitScheduleReprojectionIOTest.java @@ -54,7 +54,7 @@ */ public class TransitScheduleReprojectionIOTest { private static final Logger log = LogManager.getLogger( TransitScheduleReprojectionIOTest.class ) ; - + private static final String INITIAL_CRS = TransformationFactory.CH1903_LV03_GT; private static final String TARGET_CRS = "EPSG:3857"; private static final CoordinateTransformation transformation = @@ -103,7 +103,7 @@ public void testWithControlerAndConfigParameters() { } final String outputDirectory = utils.getOutputDirectory()+"/output/"; - + // read same thing via scenario loader: Scenario scenario ; { @@ -113,13 +113,13 @@ public void testWithControlerAndConfigParameters() { config.transit().setUseTransit( true ); config.transit().setInputScheduleCRS( INITIAL_CRS ); config.global().setCoordinateSystem( TARGET_CRS ); - config.controler().setLastIteration( -1 ); - config.controler().setOutputDirectory( outputDirectory ); + config.controller().setLastIteration( -1 ); + config.controller().setOutputDirectory( outputDirectory ); scenario = ScenarioUtils.loadScenario( config ); } - + // TODO: test also with loading from Controler C'tor? - + for ( Id id : originalScenario.getTransitSchedule().getFacilities().keySet() ) { final Coord originalCoord = originalScenario.getTransitSchedule().getFacilities().get( id ).getCoord(); final Coord internalCoord = scenario.getTransitSchedule().getFacilities().get( id ).getCoord(); @@ -129,10 +129,10 @@ public void testWithControlerAndConfigParameters() { transformation.transform(originalCoord), internalCoord); } - + final Controler controler = new Controler( scenario ); controler.run(); - + Scenario dumpedScenario ; { final Config config = ConfigUtils.createConfig( ExamplesUtils.getTestScenarioURL( "pt-tutorial" ) ); @@ -160,7 +160,7 @@ public void testWithControlerAndAttributes() { originalScenario = ScenarioUtils.createScenario( config ); new TransitScheduleReader( originalScenario ).readURL( ConfigGroup.getInputFileURL( config.getContext(), "transitschedule.xml" ) ); } - + final String outputDirectory = utils.getOutputDirectory()+"/output/"; // same thing via scenario loader, @@ -172,7 +172,7 @@ public void testWithControlerAndAttributes() { final String withAttributes = new File( utils.getOutputDirectory() ).getAbsolutePath() + "/transitschedule.xml"; // (need the absolute path since later it is put into the config, and that will otherwise be relative to some other context. kai, sep'18) new TransitScheduleWriter( originalScenario.getTransitSchedule() ).writeFile( withAttributes ); - + final Config config = ConfigUtils.createConfig( ExamplesUtils.getTestScenarioURL( "pt-tutorial" ) ); config.transit().setRoutingAlgorithmType(TransitRoutingAlgorithmType.DijkstraBased); config.transit().setTransitScheduleFile( withAttributes ); @@ -180,15 +180,15 @@ public void testWithControlerAndAttributes() { config.transit().setInputScheduleCRS( INITIAL_CRS ); // yyyyyy Is it so plausible that this is given here when the test is about having this in the file? kai, sep'18 config.global().setCoordinateSystem( TARGET_CRS ); - config.controler().setLastIteration( -1 ); - config.controler().setOutputDirectory( outputDirectory ); - + config.controller().setLastIteration( -1 ); + config.controller().setOutputDirectory( outputDirectory ); + log.info( "" ) ; log.info("just before we are getting the exception:") ; log.info( "context=" + config.getContext() ) ; log.info( "transitScheduleFilename=" + withAttributes ) ; log.info("") ; - + // TODO: test also with loading from Controler C'tor? scenario = ScenarioUtils.loadScenario( config ); } diff --git a/matsim/src/test/java/org/matsim/testcases/MatsimTestUtils.java b/matsim/src/test/java/org/matsim/testcases/MatsimTestUtils.java index b54560b533d..2f1b5b76dc7 100644 --- a/matsim/src/test/java/org/matsim/testcases/MatsimTestUtils.java +++ b/matsim/src/test/java/org/matsim/testcases/MatsimTestUtils.java @@ -24,12 +24,10 @@ import org.junit.Assert; import org.junit.rules.TestWatcher; import org.junit.runner.Description; -import org.matsim.api.core.v01.population.Population; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigGroup; import org.matsim.core.config.ConfigUtils; import org.matsim.core.gbl.MatsimRandom; -import org.matsim.core.population.PopulationUtils; import org.matsim.core.utils.io.IOUtils; import org.matsim.core.utils.io.UncheckedIOException; import org.matsim.core.utils.misc.CRCChecksum; @@ -41,7 +39,6 @@ import java.lang.reflect.Method; import java.net.MalformedURLException; import java.net.URL; -import java.security.Permission; import java.util.Objects; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -116,7 +113,7 @@ public Config createConfigWithInputResourcePathAsContext() { Config config = ConfigUtils.createConfig(); config.setContext(inputResourcePath()); this.outputDirectory = getOutputDirectory(); - config.controler().setOutputDirectory(this.outputDirectory); + config.controller().setOutputDirectory(this.outputDirectory); return config; } @@ -124,7 +121,7 @@ public Config createConfigWithClassInputResourcePathAsContext() { Config config = ConfigUtils.createConfig(); config.setContext(classInputResourcePath()); this.outputDirectory = getOutputDirectory(); - config.controler().setOutputDirectory(this.outputDirectory); + config.controller().setOutputDirectory(this.outputDirectory); return config; } @@ -132,7 +129,7 @@ public Config createConfigWithPackageInputResourcePathAsContext() { Config config = ConfigUtils.createConfig(); config.setContext(packageInputResourcePath()); this.outputDirectory = getOutputDirectory(); - config.controler().setOutputDirectory(this.outputDirectory); + config.controller().setOutputDirectory(this.outputDirectory); return config; } @@ -164,7 +161,7 @@ public Config createConfigWithTestInputFilePathAsContext() { Config config = ConfigUtils.createConfig(); config.setContext(new File(this.getInputDirectory()).toURI().toURL()); this.outputDirectory = getOutputDirectory(); - config.controler().setOutputDirectory(this.outputDirectory); + config.controller().setOutputDirectory(this.outputDirectory); return config; } catch (MalformedURLException e) { throw new RuntimeException(e); @@ -175,7 +172,7 @@ public Config createConfig(URL context) { Config config = ConfigUtils.createConfig(); config.setContext(context); this.outputDirectory = getOutputDirectory(); - config.controler().setOutputDirectory(this.outputDirectory); + config.controller().setOutputDirectory(this.outputDirectory); return config; } @@ -194,7 +191,7 @@ public Config loadConfig(final String configfile, final ConfigGroup... customGro config = ConfigUtils.createConfig( customGroups ); } this.outputDirectory = getOutputDirectory(); - config.controler().setOutputDirectory(this.outputDirectory); + config.controller().setOutputDirectory(this.outputDirectory); return config; } @@ -206,14 +203,14 @@ public Config loadConfig(final URL configfile, final ConfigGroup... customGroups config = ConfigUtils.createConfig( customGroups ); } this.outputDirectory = getOutputDirectory(); - config.controler().setOutputDirectory(this.outputDirectory); + config.controller().setOutputDirectory(this.outputDirectory); return config; } public Config createConfig(final ConfigGroup... customGroups) { Config config = ConfigUtils.createConfig( customGroups ); this.outputDirectory = getOutputDirectory(); - config.controler().setOutputDirectory(this.outputDirectory); + config.controller().setOutputDirectory(this.outputDirectory); return config; } diff --git a/matsim/src/test/java/org/matsim/withinday/controller/ExampleWithinDayControllerTest.java b/matsim/src/test/java/org/matsim/withinday/controller/ExampleWithinDayControllerTest.java index f9af7981774..01a9e44a166 100644 --- a/matsim/src/test/java/org/matsim/withinday/controller/ExampleWithinDayControllerTest.java +++ b/matsim/src/test/java/org/matsim/withinday/controller/ExampleWithinDayControllerTest.java @@ -45,8 +45,8 @@ public class ExampleWithinDayControllerTest { @Test public void testRun() { Config config = utils.loadConfig("test/scenarios/equil/config.xml"); - config.controler().setLastIteration(1); - config.controler().setRoutingAlgorithmType(ControllerConfigGroup.RoutingAlgorithmType.Dijkstra); + config.controller().setLastIteration(1); + config.controller().setRoutingAlgorithmType(ControllerConfigGroup.RoutingAlgorithmType.Dijkstra); Scenario scenario = ScenarioUtils.loadScenario(config); preparePlans(scenario); final Controler controler = new Controler(scenario); diff --git a/matsim/src/test/java/org/matsim/withinday/controller/ExperiencedPlansWriterTest.java b/matsim/src/test/java/org/matsim/withinday/controller/ExperiencedPlansWriterTest.java index dcd8b5444cb..a9290886cb9 100644 --- a/matsim/src/test/java/org/matsim/withinday/controller/ExperiencedPlansWriterTest.java +++ b/matsim/src/test/java/org/matsim/withinday/controller/ExperiencedPlansWriterTest.java @@ -81,16 +81,16 @@ public void testWriteFile() { Config config = ConfigUtils.createConfig(); - config.controler().setOutputDirectory(this.utils.getOutputDirectory()); + config.controller().setOutputDirectory(this.utils.getOutputDirectory()); config.qsim().setEndTime(24 * 3600); - config.controler().setLastIteration(0); - config.controler().setRoutingAlgorithmType( ControllerConfigGroup.RoutingAlgorithmType.Dijkstra ); + config.controller().setLastIteration(0); + config.controller().setRoutingAlgorithmType( ControllerConfigGroup.RoutingAlgorithmType.Dijkstra ); ActivityParams homeParams = new ActivityParams("home"); homeParams.setTypicalDuration(16*3600); - config.planCalcScore().addActivityParams(homeParams); + config.scoring().addActivityParams(homeParams); Scenario scenario = ScenarioUtils.createScenario(config); @@ -101,10 +101,10 @@ public void testWriteFile() { population.addPerson(createPerson(scenario, "p02")); Controler controler = new Controler(scenario); - controler.getConfig().controler().setCreateGraphs(false); - controler.getConfig().controler().setDumpDataAtEnd(false); - controler.getConfig().controler().setWriteEventsInterval(0); - controler.getConfig().controler().setOverwriteFileSetting( + controler.getConfig().controller().setCreateGraphs(false); + controler.getConfig().controller().setDumpDataAtEnd(false); + controler.getConfig().controller().setWriteEventsInterval(0); + controler.getConfig().controller().setOverwriteFileSetting( OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles); controler.addOverridingModule(new AbstractModule() { @Override diff --git a/matsim/src/test/java/org/matsim/withinday/replanning/identifiers/tools/ActivityReplanningMapTest.java b/matsim/src/test/java/org/matsim/withinday/replanning/identifiers/tools/ActivityReplanningMapTest.java index 4a96f92bd06..4aebdd6bb91 100644 --- a/matsim/src/test/java/org/matsim/withinday/replanning/identifiers/tools/ActivityReplanningMapTest.java +++ b/matsim/src/test/java/org/matsim/withinday/replanning/identifiers/tools/ActivityReplanningMapTest.java @@ -103,11 +103,11 @@ public class ActivityReplanningMapTest { Config config = utils.loadConfig("test/scenarios/equil/config.xml"); QSimConfigGroup qSimConfig = config.qsim(); qSimConfig.setNumberOfThreads(2); - config.controler().setMobsim("qsim"); - config.controler().setLastIteration(0); + config.controller().setMobsim("qsim"); + config.controller().setLastIteration(0); config.qsim().setStartTime(0.0); config.qsim().setSimStarttimeInterpretation(QSimConfigGroup.StarttimeInterpretation.onlyUseStarttime); - config.controler().setRoutingAlgorithmType( ControllerConfigGroup.RoutingAlgorithmType.Dijkstra ); + config.controller().setRoutingAlgorithmType( ControllerConfigGroup.RoutingAlgorithmType.Dijkstra ); Controler controler = new Controler(config); controler.addOverridingModule(new WithinDayModule()); @@ -117,10 +117,10 @@ public void install() { addMobsimListenerBinding().to(MobsimListenerForTests.class); } }); - controler.getConfig().controler().setCreateGraphs(false); - controler.getConfig().controler().setDumpDataAtEnd(false); - controler.getConfig().controler().setWriteEventsInterval(0); - controler.getConfig().controler().setWritePlansInterval(0); + controler.getConfig().controller().setCreateGraphs(false); + controler.getConfig().controller().setDumpDataAtEnd(false); + controler.getConfig().controller().setWriteEventsInterval(0); + controler.getConfig().controller().setWritePlansInterval(0); controler.run(); } diff --git a/matsim/src/test/java/org/matsim/withinday/replanning/identifiers/tools/LinkReplanningMapTest.java b/matsim/src/test/java/org/matsim/withinday/replanning/identifiers/tools/LinkReplanningMapTest.java index 36f262d4058..7dddab430db 100644 --- a/matsim/src/test/java/org/matsim/withinday/replanning/identifiers/tools/LinkReplanningMapTest.java +++ b/matsim/src/test/java/org/matsim/withinday/replanning/identifiers/tools/LinkReplanningMapTest.java @@ -58,9 +58,9 @@ public class LinkReplanningMapTest { qSimConfig.setNumberOfThreads(2); qSimConfig.setFlowCapFactor(100.0); // ensure that agents don't have to wait at an intersection qSimConfig.setStorageCapFactor(100.0); // ensure that agents don't have to wait at an intersection - config.controler().setMobsim("qsim"); - config.controler().setLastIteration(0); - config.controler().setRoutingAlgorithmType( ControllerConfigGroup.RoutingAlgorithmType.Dijkstra ); + config.controller().setMobsim("qsim"); + config.controller().setLastIteration(0); + config.controller().setRoutingAlgorithmType( ControllerConfigGroup.RoutingAlgorithmType.Dijkstra ); Controler controler = new Controler(config); controler.addOverridingModule(new WithinDayModule()); diff --git a/matsim/src/test/java/org/matsim/withinday/trafficmonitoring/WithinDayTravelTimeTest.java b/matsim/src/test/java/org/matsim/withinday/trafficmonitoring/WithinDayTravelTimeTest.java index db4366a64a5..8a1e15db1f4 100644 --- a/matsim/src/test/java/org/matsim/withinday/trafficmonitoring/WithinDayTravelTimeTest.java +++ b/matsim/src/test/java/org/matsim/withinday/trafficmonitoring/WithinDayTravelTimeTest.java @@ -75,21 +75,21 @@ public void testGetLinkTravelTime_noFastCapacityUpdate() { private void testGetLinkTravelTime(boolean isUsingFastCapacityUpdate) { Config config = ConfigUtils.loadConfig("test/scenarios/equil/config.xml"); - config.controler().setOutputDirectory(helper.getOutputDirectory()+"fastCapacityUpdate_"+isUsingFastCapacityUpdate); + config.controller().setOutputDirectory(helper.getOutputDirectory()+"fastCapacityUpdate_"+isUsingFastCapacityUpdate); QSimConfigGroup qSimConfig = config.qsim(); qSimConfig.setNumberOfThreads(2); qSimConfig.setUsingFastCapacityUpdate(isUsingFastCapacityUpdate); - config.controler().setLastIteration(0); + config.controller().setLastIteration(0); - config.controler().setCreateGraphs(false); - config.controler().setDumpDataAtEnd(false); - config.controler().setWriteEventsInterval(0); - config.controler().setWritePlansInterval(0); + config.controller().setCreateGraphs(false); + config.controller().setDumpDataAtEnd(false); + config.controller().setWriteEventsInterval(0); + config.controller().setWritePlansInterval(0); - config.controler().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); - config.controler().setRoutingAlgorithmType( ControllerConfigGroup.RoutingAlgorithmType.Dijkstra ); + config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); + config.controller().setRoutingAlgorithmType( ControllerConfigGroup.RoutingAlgorithmType.Dijkstra ); config.network().setTimeVariantNetwork(true); diff --git a/matsim/src/test/java/org/matsim/withinday/trafficmonitoring/WithinDayTravelTimeWithNetworkChangeEventsTest.java b/matsim/src/test/java/org/matsim/withinday/trafficmonitoring/WithinDayTravelTimeWithNetworkChangeEventsTest.java index 0de7387c904..ef68744005b 100644 --- a/matsim/src/test/java/org/matsim/withinday/trafficmonitoring/WithinDayTravelTimeWithNetworkChangeEventsTest.java +++ b/matsim/src/test/java/org/matsim/withinday/trafficmonitoring/WithinDayTravelTimeWithNetworkChangeEventsTest.java @@ -78,10 +78,10 @@ public final void testTTviaMobSimAfterSimStepListener() { final Config config = ConfigUtils.createConfig(); - config.controler().setFirstIteration(0); - config.controler().setLastIteration(0); - config.controler().setOutputDirectory(outputDirectory); - config.controler().setRoutingAlgorithmType( ControllerConfigGroup.RoutingAlgorithmType.Dijkstra ); + config.controller().setFirstIteration(0); + config.controller().setLastIteration(0); + config.controller().setOutputDirectory(outputDirectory); + config.controller().setRoutingAlgorithmType( ControllerConfigGroup.RoutingAlgorithmType.Dijkstra ); config.qsim().setStartTime(6. * 3600.); config.qsim().setEndTime(11 * 3600.); @@ -89,12 +89,12 @@ public final void testTTviaMobSimAfterSimStepListener() { ActivityParams paramsA = new ActivityParams(); paramsA.setActivityType("home"); paramsA.setTypicalDuration(1234.); - config.planCalcScore().addActivityParams(paramsA); + config.scoring().addActivityParams(paramsA); ActivityParams paramsB = new ActivityParams(); paramsB.setActivityType("work"); paramsB.setTypicalDuration(1234.); - config.planCalcScore().addActivityParams(paramsB); + config.scoring().addActivityParams(paramsB); config.network().setTimeVariantNetwork(true); @@ -108,7 +108,7 @@ public final void testTTviaMobSimAfterSimStepListener() { NetworkUtils.addNetworkChangeEvent(scenario.getNetwork(), nce); final Controler controler = new Controler(scenario); - controler.getConfig().controler().setOverwriteFileSetting(OverwriteFileSetting.overwriteExistingFiles); + controler.getConfig().controller().setOverwriteFileSetting(OverwriteFileSetting.overwriteExistingFiles); Set analyzedModes = new HashSet<>(); analyzedModes.add(TransportMode.car); diff --git a/matsim/src/test/java/org/matsim/withinday/utils/EditRoutesTest.java b/matsim/src/test/java/org/matsim/withinday/utils/EditRoutesTest.java index c441971cfc6..d6d29521b27 100644 --- a/matsim/src/test/java/org/matsim/withinday/utils/EditRoutesTest.java +++ b/matsim/src/test/java/org/matsim/withinday/utils/EditRoutesTest.java @@ -95,7 +95,7 @@ public class EditRoutesTest { int firstCarLeg = 1 ; // 1-->3 int scndCarLeg = 3 ; // 3-->9 - if ( !scenario.getConfig().plansCalcRoute().getAccessEgressType().equals(AccessEgressType.none) ) { + if ( !scenario.getConfig().routing().getAccessEgressType().equals(AccessEgressType.none) ) { firstCarLeg = 3 ; // 1-->3 scndCarLeg = 9 ; // 3-->9 } @@ -155,7 +155,7 @@ public class EditRoutesTest { int scndAct = 2 ; int scndCarLeg = 3 ; // 3-->9 int thrdAct = 4 ; - if ( !scenario.getConfig().plansCalcRoute().getAccessEgressType().equals(RoutingConfigGroup.AccessEgressType.none) ) { + if ( !scenario.getConfig().routing().getAccessEgressType().equals(RoutingConfigGroup.AccessEgressType.none) ) { firstCarLeg = 3 ; // 1-->3 scndAct = 6 ; scndCarLeg = 9 ; // 3-->9 @@ -232,7 +232,7 @@ public class EditRoutesTest { createScenario(); int firstCarLeg = 1 ; // 1-->3 int scndCarLeg = 3 ; // 3-->9 - if ( !scenario.getConfig().plansCalcRoute().getAccessEgressType().equals(RoutingConfigGroup.AccessEgressType.none) ) { + if ( !scenario.getConfig().routing().getAccessEgressType().equals(RoutingConfigGroup.AccessEgressType.none) ) { firstCarLeg = 3 ; // 1-->3 scndCarLeg = 9 ; // 3-->9 } @@ -280,7 +280,7 @@ public class EditRoutesTest { EditRoutes ed = new EditRoutes(scenario.getNetwork(), pathCalculator, scenario.getPopulation().getFactory()); int firstCarLeg = 1 ; // 1-->3 int scndCarLeg = 3 ; // 3-->9 - if ( !scenario.getConfig().plansCalcRoute().getAccessEgressType().equals(AccessEgressType.none) ) { + if ( !scenario.getConfig().routing().getAccessEgressType().equals(AccessEgressType.none) ) { firstCarLeg = 3 ; // 1-->3 scndCarLeg = 9 ; // 3-->9 } @@ -304,7 +304,7 @@ public class EditRoutesTest { int firstCarLeg = 1 ; // 1-->3 int scndCarLeg = 3 ; // 3-->9 - if ( !scenario.getConfig().plansCalcRoute().getAccessEgressType().equals(RoutingConfigGroup.AccessEgressType.none) ) { + if ( !scenario.getConfig().routing().getAccessEgressType().equals(RoutingConfigGroup.AccessEgressType.none) ) { firstCarLeg = 3 ; // 1-->3 scndCarLeg = 9 ; // 3-->9 } @@ -324,7 +324,7 @@ public class EditRoutesTest { int firstCarLeg = 1 ; // 1-->3 int scndCarLeg = 3 ; // 3-->9 - if ( !scenario.getConfig().plansCalcRoute().getAccessEgressType().equals(AccessEgressType.none) ) { + if ( !scenario.getConfig().routing().getAccessEgressType().equals(AccessEgressType.none) ) { firstCarLeg = 3 ; // 1-->3 scndCarLeg = 9 ; // 3-->9 } @@ -345,7 +345,7 @@ public class EditRoutesTest { int firstCarLeg = 1 ; // 1-->3 int scndCarLeg = 3 ; // 3-->9 - if ( !scenario.getConfig().plansCalcRoute().getAccessEgressType().equals(RoutingConfigGroup.AccessEgressType.none) ) { + if ( !scenario.getConfig().routing().getAccessEgressType().equals(RoutingConfigGroup.AccessEgressType.none) ) { firstCarLeg = 3 ; // 1-->3 scndCarLeg = 9 ; // 3-->9 } @@ -364,7 +364,7 @@ public class EditRoutesTest { int firstCarLeg = 1 ; // 1-->3 int scndCarLeg = 3 ; // 3-->9 - if ( !scenario.getConfig().plansCalcRoute().getAccessEgressType().equals(RoutingConfigGroup.AccessEgressType.none) ) { + if ( !scenario.getConfig().routing().getAccessEgressType().equals(RoutingConfigGroup.AccessEgressType.none) ) { firstCarLeg = 3 ; // 1-->3 scndCarLeg = 9 ; // 3-->9 } @@ -383,7 +383,7 @@ public class EditRoutesTest { int firstCarLeg = 1 ; // 1-->3 int scndCarLeg = 3 ; // 3-->9 - if ( !scenario.getConfig().plansCalcRoute().getAccessEgressType().equals(AccessEgressType.none) ) { + if ( !scenario.getConfig().routing().getAccessEgressType().equals(AccessEgressType.none) ) { firstCarLeg = 3 ; // 1-->3 scndCarLeg = 9 ; // 3-->9 } @@ -402,7 +402,7 @@ public class EditRoutesTest { int firstCarLeg = 1 ; // 1-->3 int scndCarLeg = 3 ; // 3-->9 - if ( !scenario.getConfig().plansCalcRoute().getAccessEgressType().equals(RoutingConfigGroup.AccessEgressType.none) ) { + if ( !scenario.getConfig().routing().getAccessEgressType().equals(RoutingConfigGroup.AccessEgressType.none) ) { firstCarLeg = 3 ; // 1-->3 scndCarLeg = 9 ; // 3-->9 } @@ -421,7 +421,7 @@ public class EditRoutesTest { int firstCarLeg = 1 ; // 1-->3 int scndCarLeg = 3 ; // 3-->9 - if ( !scenario.getConfig().plansCalcRoute().getAccessEgressType().equals(AccessEgressType.none) ) { + if ( !scenario.getConfig().routing().getAccessEgressType().equals(AccessEgressType.none) ) { firstCarLeg = 3 ; // 1-->3 scndCarLeg = 9 ; // 3-->9 } @@ -442,7 +442,7 @@ public class EditRoutesTest { int firstCarLeg = 1 ; // 1-->3 int scndCarLeg = 3 ; // 3-->9 - if ( !scenario.getConfig().plansCalcRoute().getAccessEgressType().equals(RoutingConfigGroup.AccessEgressType.none) ) { + if ( !scenario.getConfig().routing().getAccessEgressType().equals(RoutingConfigGroup.AccessEgressType.none) ) { firstCarLeg = 3 ; // 1-->3 scndCarLeg = 9 ; // 3-->9 } From 343dc01cbc94d8ee6e2c99f8d25d9ba2d5436621 Mon Sep 17 00:00:00 2001 From: Kai Martins-Turner Date: Thu, 12 Oct 2023 12:17:53 +0200 Subject: [PATCH 21/25] calculate travel time, distance etc for beginning of timeslice. --- .../contrib/freight/jsprit/NetworkBasedTransportCosts.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/contribs/freight/src/main/java/org/matsim/contrib/freight/jsprit/NetworkBasedTransportCosts.java b/contribs/freight/src/main/java/org/matsim/contrib/freight/jsprit/NetworkBasedTransportCosts.java index 1d6fb1f6f6c..01f79137571 100644 --- a/contribs/freight/src/main/java/org/matsim/contrib/freight/jsprit/NetworkBasedTransportCosts.java +++ b/contribs/freight/src/main/java/org/matsim/contrib/freight/jsprit/NetworkBasedTransportCosts.java @@ -592,6 +592,7 @@ public double getTransportTime(Location fromId, Location toId, double departureT } String typeId = vehicle.getType().getTypeId(); int timeSlice = getTimeSlice(departureTime); + departureTime = timeSlice*timeSliceWidth; TransportDataKey transportDataKey = makeKey(fromId.getId(), toId.getId(), timeSlice, typeId); TransportData data = costCache.get(transportDataKey); double transportTime; @@ -680,6 +681,7 @@ public double getTransportCost(Location fromId, Location toId, double departureT LeastCostPathCalculator router = createLeastCostPathCalculator(); int timeSlice = getTimeSlice(departureTime); + departureTime = timeSlice*timeSliceWidth; String typeId = vehicle.getType().getTypeId(); TransportDataKey transportDataKey = makeKey(fromId.getId(), toId.getId(), timeSlice, typeId); TransportData data = costCache.get(transportDataKey); @@ -738,6 +740,7 @@ public double getDistance(Location fromId, Location toId, double departureTime, } String typeId = vehicle.getType().getTypeId(); int timeSlice = getTimeSlice(departureTime); + departureTime = timeSlice*timeSliceWidth; TransportDataKey transportDataKey = makeKey(fromId.getId(), toId.getId(), timeSlice, typeId); TransportData data = costCache.get(transportDataKey); double travelDistance; From b2beb6790ee89eb76322400965ed83dccc1042d7 Mon Sep 17 00:00:00 2001 From: Marcel Rieser Date: Thu, 12 Oct 2023 14:32:24 +0200 Subject: [PATCH 22/25] use config aliases also in ConfigReaderMatsimV1 fix tests --- .../config_demand.xml | 9 ------- .../scenarios/grid/jointDemand_config.xml | 9 ------- .../useSignalInput/withLanes/config.xml | 12 --------- .../useSignalInput/woLanes/config.xml | 12 --------- .../org/matsim/contrib/socnetsim/config.xml | 1 - .../withinDayEvacuationConf.xml | 7 +++--- .../org/matsim/core/config/ConfigReader.java | 5 ++++ .../core/config/ConfigReaderMatsimV1.java | 25 ++++++++++++++++--- .../core/config/ConfigReaderMatsimV2.java | 10 +++++++- .../core/config/ConfigReaderMatsimV2Test.java | 22 ++++++++++++++++ .../matsim/core/controler/ControlerIT.java | 4 +-- .../config_v2_w_scoringparams.xml | 0 .../config_v2_wo_scoringparams.xml | 0 13 files changed, 62 insertions(+), 54 deletions(-) rename matsim/test/input/org/matsim/core/config/groups/{PlanCalcScoreConfigGroupTest => ScoringConfigGroupTest}/config_v2_w_scoringparams.xml (100%) rename matsim/test/input/org/matsim/core/config/groups/{PlanCalcScoreConfigGroupTest => ScoringConfigGroupTest}/config_v2_wo_scoringparams.xml (100%) diff --git a/contribs/application/test/input/org/matsim/smallScaleCommercialTrafficGeneration/config_demand.xml b/contribs/application/test/input/org/matsim/smallScaleCommercialTrafficGeneration/config_demand.xml index fa6c5559c71..67f61c5ca74 100644 --- a/contribs/application/test/input/org/matsim/smallScaleCommercialTrafficGeneration/config_demand.xml +++ b/contribs/application/test/input/org/matsim/smallScaleCommercialTrafficGeneration/config_demand.xml @@ -70,15 +70,6 @@ - - - - - - - - - diff --git a/contribs/commercialTrafficApplications/scenarios/grid/jointDemand_config.xml b/contribs/commercialTrafficApplications/scenarios/grid/jointDemand_config.xml index a90fd68807a..8dcb998aa8d 100644 --- a/contribs/commercialTrafficApplications/scenarios/grid/jointDemand_config.xml +++ b/contribs/commercialTrafficApplications/scenarios/grid/jointDemand_config.xml @@ -1,15 +1,6 @@ - - - - - - - - - diff --git a/contribs/signals/examples/tutorial/example90TrafficLights/useSignalInput/withLanes/config.xml b/contribs/signals/examples/tutorial/example90TrafficLights/useSignalInput/withLanes/config.xml index 74bbb0b2d06..dcbc59dfac2 100644 --- a/contribs/signals/examples/tutorial/example90TrafficLights/useSignalInput/withLanes/config.xml +++ b/contribs/signals/examples/tutorial/example90TrafficLights/useSignalInput/withLanes/config.xml @@ -2,18 +2,6 @@ - - - - - - - - - - - - diff --git a/contribs/signals/examples/tutorial/example90TrafficLights/useSignalInput/woLanes/config.xml b/contribs/signals/examples/tutorial/example90TrafficLights/useSignalInput/woLanes/config.xml index c1779b67f83..4dcd49397ff 100644 --- a/contribs/signals/examples/tutorial/example90TrafficLights/useSignalInput/woLanes/config.xml +++ b/contribs/signals/examples/tutorial/example90TrafficLights/useSignalInput/woLanes/config.xml @@ -2,18 +2,6 @@ - - - - - - - - - - - - diff --git a/contribs/socnetsim/test/input/org/matsim/contrib/socnetsim/config.xml b/contribs/socnetsim/test/input/org/matsim/contrib/socnetsim/config.xml index c62a391cbad..511d050ca86 100644 --- a/contribs/socnetsim/test/input/org/matsim/contrib/socnetsim/config.xml +++ b/contribs/socnetsim/test/input/org/matsim/contrib/socnetsim/config.xml @@ -32,7 +32,6 @@ - diff --git a/examples/scenarios/evacuation-tutorial/withinDayEvacuationConf.xml b/examples/scenarios/evacuation-tutorial/withinDayEvacuationConf.xml index 5e7845adf1b..b6d2cc8cecf 100644 --- a/examples/scenarios/evacuation-tutorial/withinDayEvacuationConf.xml +++ b/examples/scenarios/evacuation-tutorial/withinDayEvacuationConf.xml @@ -20,14 +20,14 @@ - + - + @@ -40,8 +40,7 @@ - - + diff --git a/matsim/src/main/java/org/matsim/core/config/ConfigReader.java b/matsim/src/main/java/org/matsim/core/config/ConfigReader.java index 319f1b65461..b39ba43eecf 100644 --- a/matsim/src/main/java/org/matsim/core/config/ConfigReader.java +++ b/matsim/src/main/java/org/matsim/core/config/ConfigReader.java @@ -45,6 +45,7 @@ public final class ConfigReader extends MatsimXmlParser { private final static String CONFIG_V1 = "config_v1.dtd"; private final static String CONFIG_V2 = "config_v2.dtd"; + private final ConfigAliases aliases = new ConfigAliases(); private final Config config; private MatsimXmlParser delegate = null; @@ -64,6 +65,10 @@ public ConfigReader(final Config config) { this.config = config; } + public ConfigAliases getConfigAliases() { + return this.aliases; + } + @Override public void startTag(final String name, final Attributes atts, final Stack context) { this.delegate.startTag(name, atts, context); diff --git a/matsim/src/main/java/org/matsim/core/config/ConfigReaderMatsimV1.java b/matsim/src/main/java/org/matsim/core/config/ConfigReaderMatsimV1.java index b3b9f9d9ae7..7d5c829d670 100644 --- a/matsim/src/main/java/org/matsim/core/config/ConfigReaderMatsimV1.java +++ b/matsim/src/main/java/org/matsim/core/config/ConfigReaderMatsimV1.java @@ -28,8 +28,12 @@ import org.matsim.core.utils.io.MatsimXmlParser; import org.xml.sax.Attributes; +import java.util.ArrayDeque; +import java.util.Deque; import java.util.Stack; +import static org.matsim.core.config.ConfigV2XmlNames.NAME; + /** * A reader for config-files of MATSim according to config_v1.dtd. * @@ -46,10 +50,12 @@ class ConfigReaderMatsimV1 extends MatsimXmlParser { private static final String msg = "using deprecated config version; please switch to config v2; your output_config.xml " + "will be in the correct version; v1 will fail eventually, since we want to reduce the " + "workload on keeping everything between v1 and v2 consistent (look into " + - "PlanCalcScoreConfigGroup or PlanCalcRouteConfigGroup if you want to know what we mean)."; + "ScoringConfigGroup or RoutingConfigGroup if you want to know what we mean)."; private final Config config; + private final ConfigAliases aliases; + private final Deque pathStack = new ArrayDeque<>(); private ConfigGroup currmodule = null; private String localDtd; @@ -57,6 +63,14 @@ class ConfigReaderMatsimV1 extends MatsimXmlParser { public ConfigReaderMatsimV1(final Config config) { super(ValidationType.DTD_ONLY); this.config = config; + this.aliases = new ConfigAliases(); + log.warn(msg); + } + + public ConfigReaderMatsimV1(final Config config, final ConfigAliases aliases) { + super(ValidationType.DTD_ONLY); + this.config = config; + this.aliases = aliases; log.warn(msg); } @@ -86,11 +100,12 @@ public void endTag(final String name, final String content, final Stack // :-( kai, aug'18 this.currmodule = null; + this.pathStack.removeFirst(); } } private void startModule(final Attributes atts) { - String name = atts.getValue("name"); + String name = this.aliases.resolveAlias(atts.getValue(NAME), this.pathStack); this.currmodule = this.config.getModule(name); if (this.currmodule == null) { @@ -106,10 +121,12 @@ private void startModule(final Attributes atts) { this.currmodule = this.config.createModule(atts.getValue("name")); } } + this.pathStack.addFirst(name); } - private void startParam(final Attributes meta) { - this.currmodule.addParam(meta.getValue("name"), meta.getValue("value")); + private void startParam(final Attributes atts) { + String name = this.aliases.resolveAlias(atts.getValue(NAME), this.pathStack); + this.currmodule.addParam(name, atts.getValue("value")); } /** diff --git a/matsim/src/main/java/org/matsim/core/config/ConfigReaderMatsimV2.java b/matsim/src/main/java/org/matsim/core/config/ConfigReaderMatsimV2.java index 706e9d5cbd0..02fcde5d57e 100644 --- a/matsim/src/main/java/org/matsim/core/config/ConfigReaderMatsimV2.java +++ b/matsim/src/main/java/org/matsim/core/config/ConfigReaderMatsimV2.java @@ -38,6 +38,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.checkerframework.checker.units.qual.C; import org.matsim.core.utils.io.MatsimXmlParser; import org.xml.sax.Attributes; @@ -50,13 +51,20 @@ class ConfigReaderMatsimV2 extends MatsimXmlParser { private final Config config; - private final ConfigAliases aliases = new ConfigAliases(); + private final ConfigAliases aliases; private final Deque moduleStack = new ArrayDeque<>(); private final Deque pathStack = new ArrayDeque<>(); ConfigReaderMatsimV2(final Config config) { super(ValidationType.DTD_ONLY); this.config = config; + this.aliases = new ConfigAliases(); + } + + ConfigReaderMatsimV2(final Config config, final ConfigAliases aliases) { + super(ValidationType.DTD_ONLY); + this.config = config; + this.aliases = aliases; } public ConfigAliases getConfigAliases() { diff --git a/matsim/src/test/java/org/matsim/core/config/ConfigReaderMatsimV2Test.java b/matsim/src/test/java/org/matsim/core/config/ConfigReaderMatsimV2Test.java index b2650dd0264..af1a7d1a58b 100644 --- a/matsim/src/test/java/org/matsim/core/config/ConfigReaderMatsimV2Test.java +++ b/matsim/src/test/java/org/matsim/core/config/ConfigReaderMatsimV2Test.java @@ -36,6 +36,28 @@ public void testModuleNameAlias() { Assert.assertEquals(27, config.controller().getLastIteration()); } + @Test + public void testModuleNameAlias_noOldModules() { + Config config = ConfigUtils.createConfig(); + ConfigReaderMatsimV2 r2 = new ConfigReaderMatsimV2(config); + + String xml = """ + + + + + + + + """; + ByteArrayInputStream bais = new ByteArrayInputStream(xml.getBytes(StandardCharsets.UTF_8)); + + r2.readStream(bais); + + Assert.assertEquals(27, config.controller().getLastIteration()); + Assert.assertNull(config.getModules().get("controler")); + } + @Test public void testParamNameAlias() { Config config = ConfigUtils.createConfig(); diff --git a/matsim/src/test/java/org/matsim/core/controler/ControlerIT.java b/matsim/src/test/java/org/matsim/core/controler/ControlerIT.java index f572f9ecacc..a0c6bc24154 100644 --- a/matsim/src/test/java/org/matsim/core/controler/ControlerIT.java +++ b/matsim/src/test/java/org/matsim/core/controler/ControlerIT.java @@ -136,13 +136,13 @@ public void testConstructor_EventsManagerTypeImmutable() { final Config config = utils.loadConfig(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("equil"), "config.xml")); MatsimServices controler = new Controler(config); try { - controler.getConfig().setParam("parallelEventHandling", "numberOfThreads", "2"); + controler.getConfig().setParam("eventsManager", "numberOfThreads", "2"); Assert.fail("Expected exception"); } catch (Exception e) { log.info("catched expected exception", e); } try { - controler.getConfig().setParam("parallelEventHandling", "estimatedNumberOfEvents", "200000"); + controler.getConfig().setParam("eventsManager", "estimatedNumberOfEvents", "200000"); Assert.fail("Expected exception"); } catch (Exception e) { log.info("catched expected exception", e); diff --git a/matsim/test/input/org/matsim/core/config/groups/PlanCalcScoreConfigGroupTest/config_v2_w_scoringparams.xml b/matsim/test/input/org/matsim/core/config/groups/ScoringConfigGroupTest/config_v2_w_scoringparams.xml similarity index 100% rename from matsim/test/input/org/matsim/core/config/groups/PlanCalcScoreConfigGroupTest/config_v2_w_scoringparams.xml rename to matsim/test/input/org/matsim/core/config/groups/ScoringConfigGroupTest/config_v2_w_scoringparams.xml diff --git a/matsim/test/input/org/matsim/core/config/groups/PlanCalcScoreConfigGroupTest/config_v2_wo_scoringparams.xml b/matsim/test/input/org/matsim/core/config/groups/ScoringConfigGroupTest/config_v2_wo_scoringparams.xml similarity index 100% rename from matsim/test/input/org/matsim/core/config/groups/PlanCalcScoreConfigGroupTest/config_v2_wo_scoringparams.xml rename to matsim/test/input/org/matsim/core/config/groups/ScoringConfigGroupTest/config_v2_wo_scoringparams.xml From fa77a3dc78f7d8d2667df51b714e53e4ee0cd921 Mon Sep 17 00:00:00 2001 From: Marcel Rieser Date: Thu, 12 Oct 2023 15:02:38 +0200 Subject: [PATCH 23/25] adapt config files of example scenarios to new config names --- examples/scenarios/benchmark/config.xml | 14 +- examples/scenarios/berlin/config.xml | 14 +- .../scenarios/berlin/config_multimodal.xml | 10 +- .../scenarios/berlin/config_withinday.xml | 10 +- examples/scenarios/chessboard/config.xml | 8 +- examples/scenarios/daganzo/config.xml | 10 +- .../dvrp-grid/eight_shared_taxi_config.xml | 6 +- .../generic_dvrp_one_taxi_config.xml | 6 +- .../multi_mode_one_shared_taxi_config.xml | 6 +- .../dvrp-grid/multi_mode_one_taxi_config.xml | 6 +- .../dvrp-grid/one_etaxi_benchmark_config.xml | 6 +- .../scenarios/dvrp-grid/one_etaxi_config.xml | 6 +- .../dvrp-grid/one_shared_taxi_config.xml | 6 +- .../one_taxi_and_one_shared_taxi_config.xml | 6 +- .../dvrp-grid/one_taxi_benchmark_config.xml | 6 +- .../scenarios/dvrp-grid/one_taxi_config.xml | 6 +- .../dvrp-grid/one_taxi_one_truck_config.xml | 6 +- .../scenarios/dvrp-grid/one_truck_config.xml | 2 +- .../testv2_Vehv1/config_average.xml | 14 +- .../testv2_Vehv1/config_detailed.xml | 14 +- .../testv2_Vehv2/config_average.xml | 14 +- .../testv2_Vehv2/config_detailed.xml | 16 +- .../equil-extended/config-with-lanes.xml | 14 +- .../config-with-network-change-events.xml | 14 +- .../config-with-roadpricing.xml | 14 +- .../config-with-subpopulation.xml | 10 +- examples/scenarios/equil-extended/config.xml | 14 +- .../config-with-all-vehicles-from-file.xml | 34 +- .../config-with-mode-vehicles.xml | 34 +- examples/scenarios/equil/config.xml | 12 +- examples/scenarios/equil/config_plans1.xml | 10 +- .../evacuation-tutorial/evacuationConf.xml | 9 +- .../withinDayEvacuationConf.xml | 9 +- .../example8DemandGeneration/config.xml | 6 +- .../freight-chessboard-9x9/config.xml | 6 +- .../gridCarRestrictedInCenter_config.xml | 6 +- .../itsumo-sesam-scenario/config.xml | 10 +- .../scenarios/kelheim/config-with-drt.xml | 10 +- examples/scenarios/kelheim/config.xml | 12 +- examples/scenarios/lesson-3/config.xml | 571 +++++++++--------- .../scenarios/mielec/mielec_drt_config.xml | 6 +- .../scenarios/mielec/mielec_edrt_config.xml | 6 +- .../mielec/mielec_etaxi_benchmark_config.xml | 6 +- .../scenarios/mielec/mielec_etaxi_config.xml | 6 +- .../mielec/mielec_etaxi_config_assignment.xml | 6 +- .../mielec_serviceArea_based_drt_config.xml | 6 +- .../mielec/mielec_stop_based_drt_config.xml | 6 +- .../mielec/mielec_taxi_benchmark_config.xml | 6 +- .../scenarios/mielec/mielec_taxi_config.xml | 6 +- .../mielec_taxi_mini_benchmark_config.xml | 6 +- .../scenarios/pt-simple-lineswitch/config.xml | 14 +- examples/scenarios/pt-simple/config.xml | 18 +- examples/scenarios/pt-tutorial/0.config.xml | 14 +- examples/scenarios/ptdisturbances/config.xml | 6 +- examples/scenarios/roundabout/config.xml | 8 +- .../siouxfalls-2014/config_default.xml | 32 +- examples/scenarios/two-routes/config.xml | 18 +- 57 files changed, 575 insertions(+), 582 deletions(-) diff --git a/examples/scenarios/benchmark/config.xml b/examples/scenarios/benchmark/config.xml index 241477eaebc..21b81fe965a 100644 --- a/examples/scenarios/benchmark/config.xml +++ b/examples/scenarios/benchmark/config.xml @@ -16,7 +16,7 @@ - + @@ -27,16 +27,16 @@ - + - + - + - + @@ -75,8 +75,8 @@ - - + + diff --git a/examples/scenarios/berlin/config.xml b/examples/scenarios/berlin/config.xml index 00953b6ed19..849080d1798 100644 --- a/examples/scenarios/berlin/config.xml +++ b/examples/scenarios/berlin/config.xml @@ -15,19 +15,15 @@ - + - - - - - + - + @@ -75,8 +71,8 @@ - - + + diff --git a/examples/scenarios/berlin/config_multimodal.xml b/examples/scenarios/berlin/config_multimodal.xml index f95e9776da6..0e81bf84fa9 100644 --- a/examples/scenarios/berlin/config_multimodal.xml +++ b/examples/scenarios/berlin/config_multimodal.xml @@ -15,14 +15,14 @@ - + - + @@ -46,9 +46,9 @@ - + - + @@ -101,7 +101,7 @@ - + diff --git a/examples/scenarios/berlin/config_withinday.xml b/examples/scenarios/berlin/config_withinday.xml index 3e162fabc93..63f74259e9b 100644 --- a/examples/scenarios/berlin/config_withinday.xml +++ b/examples/scenarios/berlin/config_withinday.xml @@ -15,14 +15,14 @@ - + - + @@ -37,9 +37,9 @@ - + - + @@ -88,7 +88,7 @@ - + diff --git a/examples/scenarios/chessboard/config.xml b/examples/scenarios/chessboard/config.xml index 1a2577bbfae..5520454364a 100755 --- a/examples/scenarios/chessboard/config.xml +++ b/examples/scenarios/chessboard/config.xml @@ -18,10 +18,10 @@ - - + + - + @@ -78,7 +78,7 @@ - + diff --git a/examples/scenarios/daganzo/config.xml b/examples/scenarios/daganzo/config.xml index 09883208ec4..154f0afdb82 100644 --- a/examples/scenarios/daganzo/config.xml +++ b/examples/scenarios/daganzo/config.xml @@ -16,7 +16,7 @@ - + @@ -25,7 +25,7 @@ - + @@ -45,9 +45,9 @@ - + - + @@ -71,7 +71,7 @@ - + diff --git a/examples/scenarios/dvrp-grid/eight_shared_taxi_config.xml b/examples/scenarios/dvrp-grid/eight_shared_taxi_config.xml index 9122ab3ee45..fa26707492f 100644 --- a/examples/scenarios/dvrp-grid/eight_shared_taxi_config.xml +++ b/examples/scenarios/dvrp-grid/eight_shared_taxi_config.xml @@ -33,20 +33,20 @@ - + - + - + diff --git a/examples/scenarios/dvrp-grid/generic_dvrp_one_taxi_config.xml b/examples/scenarios/dvrp-grid/generic_dvrp_one_taxi_config.xml index bddf61f8647..1573fab0bc1 100644 --- a/examples/scenarios/dvrp-grid/generic_dvrp_one_taxi_config.xml +++ b/examples/scenarios/dvrp-grid/generic_dvrp_one_taxi_config.xml @@ -20,20 +20,20 @@ - + - + - + diff --git a/examples/scenarios/dvrp-grid/multi_mode_one_shared_taxi_config.xml b/examples/scenarios/dvrp-grid/multi_mode_one_shared_taxi_config.xml index d8274d55658..4c218d03a23 100644 --- a/examples/scenarios/dvrp-grid/multi_mode_one_shared_taxi_config.xml +++ b/examples/scenarios/dvrp-grid/multi_mode_one_shared_taxi_config.xml @@ -64,14 +64,14 @@ - + - + @@ -85,7 +85,7 @@ - + diff --git a/examples/scenarios/dvrp-grid/multi_mode_one_taxi_config.xml b/examples/scenarios/dvrp-grid/multi_mode_one_taxi_config.xml index 57d4f8d4258..ffc5b9dea0a 100644 --- a/examples/scenarios/dvrp-grid/multi_mode_one_taxi_config.xml +++ b/examples/scenarios/dvrp-grid/multi_mode_one_taxi_config.xml @@ -76,14 +76,14 @@ - + - + @@ -101,7 +101,7 @@ - + diff --git a/examples/scenarios/dvrp-grid/one_etaxi_benchmark_config.xml b/examples/scenarios/dvrp-grid/one_etaxi_benchmark_config.xml index d6eb3f758d7..dc38c096a0c 100644 --- a/examples/scenarios/dvrp-grid/one_etaxi_benchmark_config.xml +++ b/examples/scenarios/dvrp-grid/one_etaxi_benchmark_config.xml @@ -56,7 +56,7 @@ - + @@ -68,13 +68,13 @@ - + - + diff --git a/examples/scenarios/dvrp-grid/one_etaxi_config.xml b/examples/scenarios/dvrp-grid/one_etaxi_config.xml index 1edcffbb546..87d69f624a7 100644 --- a/examples/scenarios/dvrp-grid/one_etaxi_config.xml +++ b/examples/scenarios/dvrp-grid/one_etaxi_config.xml @@ -56,20 +56,20 @@ - + - + - + diff --git a/examples/scenarios/dvrp-grid/one_shared_taxi_config.xml b/examples/scenarios/dvrp-grid/one_shared_taxi_config.xml index e0ccdd2ef74..4e59438bbff 100644 --- a/examples/scenarios/dvrp-grid/one_shared_taxi_config.xml +++ b/examples/scenarios/dvrp-grid/one_shared_taxi_config.xml @@ -39,20 +39,20 @@ - + - + - + diff --git a/examples/scenarios/dvrp-grid/one_taxi_and_one_shared_taxi_config.xml b/examples/scenarios/dvrp-grid/one_taxi_and_one_shared_taxi_config.xml index ddcb59aecb3..4d953cfcf33 100644 --- a/examples/scenarios/dvrp-grid/one_taxi_and_one_shared_taxi_config.xml +++ b/examples/scenarios/dvrp-grid/one_taxi_and_one_shared_taxi_config.xml @@ -52,14 +52,14 @@ - + - + @@ -68,7 +68,7 @@ - + diff --git a/examples/scenarios/dvrp-grid/one_taxi_benchmark_config.xml b/examples/scenarios/dvrp-grid/one_taxi_benchmark_config.xml index 0186ae8ff51..541d14ca29b 100644 --- a/examples/scenarios/dvrp-grid/one_taxi_benchmark_config.xml +++ b/examples/scenarios/dvrp-grid/one_taxi_benchmark_config.xml @@ -37,7 +37,7 @@ - + @@ -49,13 +49,13 @@ - + - + diff --git a/examples/scenarios/dvrp-grid/one_taxi_config.xml b/examples/scenarios/dvrp-grid/one_taxi_config.xml index 140d79c8953..5cef94a0c96 100644 --- a/examples/scenarios/dvrp-grid/one_taxi_config.xml +++ b/examples/scenarios/dvrp-grid/one_taxi_config.xml @@ -37,20 +37,20 @@ - + - + - + diff --git a/examples/scenarios/dvrp-grid/one_taxi_one_truck_config.xml b/examples/scenarios/dvrp-grid/one_taxi_one_truck_config.xml index a8ea3bdb0f1..af587298e73 100644 --- a/examples/scenarios/dvrp-grid/one_taxi_one_truck_config.xml +++ b/examples/scenarios/dvrp-grid/one_taxi_one_truck_config.xml @@ -25,20 +25,20 @@ - + - + - + diff --git a/examples/scenarios/dvrp-grid/one_truck_config.xml b/examples/scenarios/dvrp-grid/one_truck_config.xml index b53844fbb4e..70ea1977db0 100644 --- a/examples/scenarios/dvrp-grid/one_truck_config.xml +++ b/examples/scenarios/dvrp-grid/one_truck_config.xml @@ -21,7 +21,7 @@ - + diff --git a/examples/scenarios/emissions-sampleScenario/testv2_Vehv1/config_average.xml b/examples/scenarios/emissions-sampleScenario/testv2_Vehv1/config_average.xml index 2016ff10164..854b768ce28 100644 --- a/examples/scenarios/emissions-sampleScenario/testv2_Vehv1/config_average.xml +++ b/examples/scenarios/emissions-sampleScenario/testv2_Vehv1/config_average.xml @@ -4,7 +4,7 @@ - + @@ -65,7 +65,7 @@ - + @@ -76,7 +76,7 @@ - + @@ -196,7 +196,7 @@ - + @@ -247,14 +247,14 @@ - + - + - + diff --git a/examples/scenarios/emissions-sampleScenario/testv2_Vehv1/config_detailed.xml b/examples/scenarios/emissions-sampleScenario/testv2_Vehv1/config_detailed.xml index e66a0b4cda0..f3e81cbbf33 100644 --- a/examples/scenarios/emissions-sampleScenario/testv2_Vehv1/config_detailed.xml +++ b/examples/scenarios/emissions-sampleScenario/testv2_Vehv1/config_detailed.xml @@ -4,7 +4,7 @@ - + @@ -69,7 +69,7 @@ - + @@ -80,7 +80,7 @@ - + @@ -200,7 +200,7 @@ - + @@ -251,14 +251,14 @@ - + - + - + diff --git a/examples/scenarios/emissions-sampleScenario/testv2_Vehv2/config_average.xml b/examples/scenarios/emissions-sampleScenario/testv2_Vehv2/config_average.xml index 38682a2a37e..ada64770327 100644 --- a/examples/scenarios/emissions-sampleScenario/testv2_Vehv2/config_average.xml +++ b/examples/scenarios/emissions-sampleScenario/testv2_Vehv2/config_average.xml @@ -4,7 +4,7 @@ - + @@ -58,7 +58,7 @@ - + @@ -69,7 +69,7 @@ - + @@ -189,7 +189,7 @@ - + @@ -240,14 +240,14 @@ - + - + - + diff --git a/examples/scenarios/emissions-sampleScenario/testv2_Vehv2/config_detailed.xml b/examples/scenarios/emissions-sampleScenario/testv2_Vehv2/config_detailed.xml index 14a268b8fe4..3390afc888d 100644 --- a/examples/scenarios/emissions-sampleScenario/testv2_Vehv2/config_detailed.xml +++ b/examples/scenarios/emissions-sampleScenario/testv2_Vehv2/config_detailed.xml @@ -4,7 +4,7 @@ - + @@ -66,7 +66,7 @@ - + @@ -77,7 +77,7 @@ - + @@ -197,7 +197,7 @@ - + @@ -250,14 +250,14 @@ - + - + - + - + diff --git a/examples/scenarios/equil-extended/config-with-lanes.xml b/examples/scenarios/equil-extended/config-with-lanes.xml index f46e5632c55..dfb69732040 100644 --- a/examples/scenarios/equil-extended/config-with-lanes.xml +++ b/examples/scenarios/equil-extended/config-with-lanes.xml @@ -16,7 +16,7 @@ - + @@ -30,13 +30,13 @@ - + - + - + @@ -70,8 +70,8 @@ - - + + @@ -84,7 +84,7 @@ - + diff --git a/examples/scenarios/equil-extended/config-with-network-change-events.xml b/examples/scenarios/equil-extended/config-with-network-change-events.xml index bf5335cb38c..c592ad75e20 100644 --- a/examples/scenarios/equil-extended/config-with-network-change-events.xml +++ b/examples/scenarios/equil-extended/config-with-network-change-events.xml @@ -17,26 +17,26 @@ - + - + - + - + - + @@ -70,8 +70,8 @@ - - + + diff --git a/examples/scenarios/equil-extended/config-with-roadpricing.xml b/examples/scenarios/equil-extended/config-with-roadpricing.xml index 3801d88f0fb..3cb0f97280a 100644 --- a/examples/scenarios/equil-extended/config-with-roadpricing.xml +++ b/examples/scenarios/equil-extended/config-with-roadpricing.xml @@ -19,26 +19,26 @@ - + - + - + - + - + @@ -72,8 +72,8 @@ - - + + diff --git a/examples/scenarios/equil-extended/config-with-subpopulation.xml b/examples/scenarios/equil-extended/config-with-subpopulation.xml index f70c0eb319f..234267d8d6a 100644 --- a/examples/scenarios/equil-extended/config-with-subpopulation.xml +++ b/examples/scenarios/equil-extended/config-with-subpopulation.xml @@ -4,13 +4,13 @@ - + - + @@ -37,8 +37,8 @@ - - + + @@ -99,7 +99,7 @@ - + diff --git a/examples/scenarios/equil-extended/config.xml b/examples/scenarios/equil-extended/config.xml index b1822bd96cf..eb3d56e93c2 100644 --- a/examples/scenarios/equil-extended/config.xml +++ b/examples/scenarios/equil-extended/config.xml @@ -15,26 +15,26 @@ - + - + - + - + - + @@ -68,8 +68,8 @@ - - + + diff --git a/examples/scenarios/equil-mixedTraffic/config-with-all-vehicles-from-file.xml b/examples/scenarios/equil-mixedTraffic/config-with-all-vehicles-from-file.xml index 20a7f3c6b53..2ed4aa5e123 100644 --- a/examples/scenarios/equil-mixedTraffic/config-with-all-vehicles-from-file.xml +++ b/examples/scenarios/equil-mixedTraffic/config-with-all-vehicles-from-file.xml @@ -15,34 +15,34 @@ - + - + - + - + - + - + - + @@ -51,7 +51,7 @@ - + @@ -59,18 +59,18 @@ - + - - + + - + - + - - + + @@ -83,10 +83,10 @@ - + - + diff --git a/examples/scenarios/equil-mixedTraffic/config-with-mode-vehicles.xml b/examples/scenarios/equil-mixedTraffic/config-with-mode-vehicles.xml index 8eeb8ddf395..138d6918359 100644 --- a/examples/scenarios/equil-mixedTraffic/config-with-mode-vehicles.xml +++ b/examples/scenarios/equil-mixedTraffic/config-with-mode-vehicles.xml @@ -15,34 +15,34 @@ - + - + - + - + - + - + - + @@ -51,7 +51,7 @@ - + @@ -59,18 +59,18 @@ - + - - + + - + - + - - + + @@ -83,10 +83,10 @@ - + - + diff --git a/examples/scenarios/equil/config.xml b/examples/scenarios/equil/config.xml index f7f24bc1708..b84cf324be0 100755 --- a/examples/scenarios/equil/config.xml +++ b/examples/scenarios/equil/config.xml @@ -20,7 +20,7 @@ - + @@ -30,13 +30,13 @@ - + - + - + @@ -73,8 +73,8 @@ - - + + diff --git a/examples/scenarios/equil/config_plans1.xml b/examples/scenarios/equil/config_plans1.xml index e08dc1a38d5..8a3be162708 100755 --- a/examples/scenarios/equil/config_plans1.xml +++ b/examples/scenarios/equil/config_plans1.xml @@ -20,7 +20,7 @@ - + @@ -35,9 +35,9 @@ - + - + @@ -71,8 +71,8 @@ - - + + diff --git a/examples/scenarios/evacuation-tutorial/evacuationConf.xml b/examples/scenarios/evacuation-tutorial/evacuationConf.xml index 0c2e62fe5d1..ee717e515f4 100644 --- a/examples/scenarios/evacuation-tutorial/evacuationConf.xml +++ b/examples/scenarios/evacuation-tutorial/evacuationConf.xml @@ -29,7 +29,7 @@ - + @@ -45,11 +45,10 @@ - + - - + @@ -84,7 +83,7 @@ - + diff --git a/examples/scenarios/evacuation-tutorial/withinDayEvacuationConf.xml b/examples/scenarios/evacuation-tutorial/withinDayEvacuationConf.xml index b6d2cc8cecf..0a72512f75b 100644 --- a/examples/scenarios/evacuation-tutorial/withinDayEvacuationConf.xml +++ b/examples/scenarios/evacuation-tutorial/withinDayEvacuationConf.xml @@ -36,7 +36,7 @@ - + @@ -52,11 +52,10 @@ - + - - + @@ -91,7 +90,7 @@ - + diff --git a/examples/scenarios/example8DemandGeneration/config.xml b/examples/scenarios/example8DemandGeneration/config.xml index 2255459c59b..3daebaca573 100644 --- a/examples/scenarios/example8DemandGeneration/config.xml +++ b/examples/scenarios/example8DemandGeneration/config.xml @@ -11,7 +11,7 @@ - + @@ -23,7 +23,7 @@ - + @@ -41,6 +41,6 @@ - + diff --git a/examples/scenarios/freight-chessboard-9x9/config.xml b/examples/scenarios/freight-chessboard-9x9/config.xml index 8a811ca100c..369971fb320 100644 --- a/examples/scenarios/freight-chessboard-9x9/config.xml +++ b/examples/scenarios/freight-chessboard-9x9/config.xml @@ -11,7 +11,7 @@ - + @@ -24,7 +24,7 @@ - + @@ -55,7 +55,7 @@ - + diff --git a/examples/scenarios/gridCarRestrictedInCenter/gridCarRestrictedInCenter_config.xml b/examples/scenarios/gridCarRestrictedInCenter/gridCarRestrictedInCenter_config.xml index bed46db24b6..106e768f27d 100644 --- a/examples/scenarios/gridCarRestrictedInCenter/gridCarRestrictedInCenter_config.xml +++ b/examples/scenarios/gridCarRestrictedInCenter/gridCarRestrictedInCenter_config.xml @@ -33,20 +33,20 @@ - + - + - + diff --git a/examples/scenarios/itsumo-sesam-scenario/config.xml b/examples/scenarios/itsumo-sesam-scenario/config.xml index 55fb23c70ff..ede3a701136 100755 --- a/examples/scenarios/itsumo-sesam-scenario/config.xml +++ b/examples/scenarios/itsumo-sesam-scenario/config.xml @@ -20,7 +20,7 @@ - + @@ -36,9 +36,9 @@ - + - + @@ -62,8 +62,8 @@ - - + + diff --git a/examples/scenarios/kelheim/config-with-drt.xml b/examples/scenarios/kelheim/config-with-drt.xml index e6f59db2d7d..76020e10903 100644 --- a/examples/scenarios/kelheim/config-with-drt.xml +++ b/examples/scenarios/kelheim/config-with-drt.xml @@ -1,11 +1,11 @@ - + - + @@ -43,7 +43,7 @@ - + @@ -73,7 +73,7 @@ - + @@ -142,7 +142,7 @@ - + diff --git a/examples/scenarios/kelheim/config.xml b/examples/scenarios/kelheim/config.xml index 7419c8e3a38..885e8191c67 100644 --- a/examples/scenarios/kelheim/config.xml +++ b/examples/scenarios/kelheim/config.xml @@ -1,11 +1,11 @@ - + - + @@ -43,7 +43,7 @@ - + @@ -73,7 +73,7 @@ - + @@ -140,7 +140,7 @@ - + @@ -215,4 +215,4 @@ - \ No newline at end of file + diff --git a/examples/scenarios/lesson-3/config.xml b/examples/scenarios/lesson-3/config.xml index a76f8c5351c..ed7b4aaae1f 100644 --- a/examples/scenarios/lesson-3/config.xml +++ b/examples/scenarios/lesson-3/config.xml @@ -3,34 +3,34 @@ - + - + - + - + - + - + @@ -39,13 +39,13 @@ - + - + - + @@ -54,9 +54,9 @@ - + - + @@ -67,7 +67,7 @@ - + @@ -85,20 +85,19 @@ - - + + - - - + + - - + + - + - + @@ -160,707 +159,707 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -878,6 +877,6 @@ - + diff --git a/examples/scenarios/mielec/mielec_drt_config.xml b/examples/scenarios/mielec/mielec_drt_config.xml index d19574049e0..db2a8763ade 100644 --- a/examples/scenarios/mielec/mielec_drt_config.xml +++ b/examples/scenarios/mielec/mielec_drt_config.xml @@ -49,20 +49,20 @@ - + - + - + diff --git a/examples/scenarios/mielec/mielec_edrt_config.xml b/examples/scenarios/mielec/mielec_edrt_config.xml index a230fe0c3cd..fdb3bd3c0f6 100644 --- a/examples/scenarios/mielec/mielec_edrt_config.xml +++ b/examples/scenarios/mielec/mielec_edrt_config.xml @@ -66,20 +66,20 @@ - + - + - + diff --git a/examples/scenarios/mielec/mielec_etaxi_benchmark_config.xml b/examples/scenarios/mielec/mielec_etaxi_benchmark_config.xml index 7e17db28699..5102b37d246 100644 --- a/examples/scenarios/mielec/mielec_etaxi_benchmark_config.xml +++ b/examples/scenarios/mielec/mielec_etaxi_benchmark_config.xml @@ -52,20 +52,20 @@ - + - + - + diff --git a/examples/scenarios/mielec/mielec_etaxi_config.xml b/examples/scenarios/mielec/mielec_etaxi_config.xml index 350877df1eb..59bfc20c581 100644 --- a/examples/scenarios/mielec/mielec_etaxi_config.xml +++ b/examples/scenarios/mielec/mielec_etaxi_config.xml @@ -58,20 +58,20 @@ - + - + - + diff --git a/examples/scenarios/mielec/mielec_etaxi_config_assignment.xml b/examples/scenarios/mielec/mielec_etaxi_config_assignment.xml index 501ef7e9364..b5df7dc9a9e 100644 --- a/examples/scenarios/mielec/mielec_etaxi_config_assignment.xml +++ b/examples/scenarios/mielec/mielec_etaxi_config_assignment.xml @@ -65,20 +65,20 @@ - + - + - + diff --git a/examples/scenarios/mielec/mielec_serviceArea_based_drt_config.xml b/examples/scenarios/mielec/mielec_serviceArea_based_drt_config.xml index 2af263fd983..d2bdd9305f7 100644 --- a/examples/scenarios/mielec/mielec_serviceArea_based_drt_config.xml +++ b/examples/scenarios/mielec/mielec_serviceArea_based_drt_config.xml @@ -63,20 +63,20 @@ - + - + - + diff --git a/examples/scenarios/mielec/mielec_stop_based_drt_config.xml b/examples/scenarios/mielec/mielec_stop_based_drt_config.xml index a7ca57a91aa..dd3df82fa60 100644 --- a/examples/scenarios/mielec/mielec_stop_based_drt_config.xml +++ b/examples/scenarios/mielec/mielec_stop_based_drt_config.xml @@ -59,20 +59,20 @@ - + - + - + diff --git a/examples/scenarios/mielec/mielec_taxi_benchmark_config.xml b/examples/scenarios/mielec/mielec_taxi_benchmark_config.xml index ac460c08fd5..f94bca1d15e 100644 --- a/examples/scenarios/mielec/mielec_taxi_benchmark_config.xml +++ b/examples/scenarios/mielec/mielec_taxi_benchmark_config.xml @@ -37,7 +37,7 @@ - + @@ -49,13 +49,13 @@ - + - + diff --git a/examples/scenarios/mielec/mielec_taxi_config.xml b/examples/scenarios/mielec/mielec_taxi_config.xml index ecfabf7d988..43389699cba 100644 --- a/examples/scenarios/mielec/mielec_taxi_config.xml +++ b/examples/scenarios/mielec/mielec_taxi_config.xml @@ -43,20 +43,20 @@ - + - + - + diff --git a/examples/scenarios/mielec/mielec_taxi_mini_benchmark_config.xml b/examples/scenarios/mielec/mielec_taxi_mini_benchmark_config.xml index c0441f76a5c..8ab14beb61a 100644 --- a/examples/scenarios/mielec/mielec_taxi_mini_benchmark_config.xml +++ b/examples/scenarios/mielec/mielec_taxi_mini_benchmark_config.xml @@ -33,7 +33,7 @@ - + @@ -45,13 +45,13 @@ - + - + diff --git a/examples/scenarios/pt-simple-lineswitch/config.xml b/examples/scenarios/pt-simple-lineswitch/config.xml index 967c37eeec3..ab0b7d7481f 100644 --- a/examples/scenarios/pt-simple-lineswitch/config.xml +++ b/examples/scenarios/pt-simple-lineswitch/config.xml @@ -22,11 +22,11 @@ - + - + @@ -47,8 +47,8 @@ - - + + @@ -80,8 +80,8 @@ - - + + @@ -115,6 +115,6 @@ - + diff --git a/examples/scenarios/pt-simple/config.xml b/examples/scenarios/pt-simple/config.xml index 19ee7006e9f..c97a2ce0874 100644 --- a/examples/scenarios/pt-simple/config.xml +++ b/examples/scenarios/pt-simple/config.xml @@ -22,23 +22,23 @@ - + - + - + - + @@ -46,8 +46,8 @@ - - + + @@ -80,8 +80,8 @@ - - + + @@ -115,6 +115,6 @@ - + diff --git a/examples/scenarios/pt-tutorial/0.config.xml b/examples/scenarios/pt-tutorial/0.config.xml index 72dd8e2c6f2..53354abfbef 100644 --- a/examples/scenarios/pt-tutorial/0.config.xml +++ b/examples/scenarios/pt-tutorial/0.config.xml @@ -15,7 +15,7 @@ - + @@ -27,13 +27,13 @@ - + - + - + @@ -82,8 +82,8 @@ - - + + @@ -113,7 +113,7 @@ - + diff --git a/examples/scenarios/ptdisturbances/config.xml b/examples/scenarios/ptdisturbances/config.xml index 1da30fbc8cd..a2d9036aaee 100644 --- a/examples/scenarios/ptdisturbances/config.xml +++ b/examples/scenarios/ptdisturbances/config.xml @@ -1,7 +1,7 @@ - + @@ -15,7 +15,7 @@ - + @@ -56,7 +56,7 @@ - + diff --git a/examples/scenarios/roundabout/config.xml b/examples/scenarios/roundabout/config.xml index 01d5c3494e5..35877624a50 100644 --- a/examples/scenarios/roundabout/config.xml +++ b/examples/scenarios/roundabout/config.xml @@ -11,7 +11,7 @@ - + @@ -24,9 +24,9 @@ - + - + @@ -59,7 +59,7 @@ - + diff --git a/examples/scenarios/siouxfalls-2014/config_default.xml b/examples/scenarios/siouxfalls-2014/config_default.xml index a3cf7ab6ede..237bf23ed66 100644 --- a/examples/scenarios/siouxfalls-2014/config_default.xml +++ b/examples/scenarios/siouxfalls-2014/config_default.xml @@ -10,13 +10,13 @@ - + - - + + @@ -25,7 +25,7 @@ - + @@ -43,13 +43,13 @@ - + - + - + @@ -107,8 +107,8 @@ - - + + @@ -134,10 +134,10 @@ - + - + @@ -158,7 +158,7 @@ - + @@ -170,13 +170,13 @@ - + - - - \ No newline at end of file + + + diff --git a/examples/scenarios/two-routes/config.xml b/examples/scenarios/two-routes/config.xml index 3f5538f6c9e..bb3bc0b91fc 100644 --- a/examples/scenarios/two-routes/config.xml +++ b/examples/scenarios/two-routes/config.xml @@ -2,7 +2,7 @@ - + @@ -11,7 +11,7 @@ - + @@ -21,14 +21,14 @@ - + - + - + @@ -58,8 +58,8 @@ - - + + @@ -72,5 +72,5 @@ - - \ No newline at end of file + + From 7d6c373a9a0242009630f129aec39eaa0f6575ad Mon Sep 17 00:00:00 2001 From: Marcel Rieser Date: Thu, 12 Oct 2023 15:25:45 +0200 Subject: [PATCH 24/25] fix compile error, somehow missed this file. --- .../routing/pt/raptor/SwissRailRaptorIntermodalTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorIntermodalTest.java b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorIntermodalTest.java index 96ceb1ad08f..973d16bb1f2 100644 --- a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorIntermodalTest.java +++ b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorIntermodalTest.java @@ -1242,9 +1242,9 @@ public void testIntermodalTripWithAccessAndEgressTimesAtStops() { IntermodalFixture f = new IntermodalFixture(); f.scenario.getTransitSchedule().getFacilities().values() .forEach(stopFacility -> TransitScheduleUtils.setSymmetricStopAccessEgressTime(stopFacility,120.0)); - PlanCalcScoreConfigGroup.ModeParams walk = new PlanCalcScoreConfigGroup.ModeParams(TransportMode.walk); + ScoringConfigGroup.ModeParams walk = new ScoringConfigGroup.ModeParams(TransportMode.walk); walk.setMarginalUtilityOfTraveling(0.0); - f.config.planCalcScore().addModeParams(walk); + f.config.scoring().addModeParams(walk); Map routingModules = new HashMap<>(); routingModules.put(TransportMode.walk, From 8635fa91016a1d0194ec297cf3a40285ec6e56dd Mon Sep 17 00:00:00 2001 From: Marcel Rieser Date: Thu, 12 Oct 2023 16:07:50 +0200 Subject: [PATCH 25/25] fix tests --- .../java/org/matsim/application/MATSimApplication.java | 10 +++++++--- .../scoring/CarsharingLegScoringFunction.java | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/contribs/application/src/main/java/org/matsim/application/MATSimApplication.java b/contribs/application/src/main/java/org/matsim/application/MATSimApplication.java index ad5923311de..c1951c1b2a4 100644 --- a/contribs/application/src/main/java/org/matsim/application/MATSimApplication.java +++ b/contribs/application/src/main/java/org/matsim/application/MATSimApplication.java @@ -11,6 +11,7 @@ import org.matsim.application.commands.RunScenario; import org.matsim.application.commands.ShowGUI; import org.matsim.core.config.Config; +import org.matsim.core.config.ConfigAliases; import org.matsim.core.config.ConfigGroup; import org.matsim.core.config.ConfigUtils; import org.matsim.core.config.groups.ControllerConfigGroup; @@ -230,6 +231,9 @@ private static void applySpecs(Config config, Path specs) { ObjectMapper mapper = new ObjectMapper(new YAMLFactory() .enable(YAMLGenerator.Feature.MINIMIZE_QUOTES)); + ConfigAliases aliases = new ConfigAliases(); + Deque emptyStack = new ArrayDeque<>(); + try (BufferedReader reader = Files.newBufferedReader(specs)) { JsonNode node = mapper.readTree(reader); @@ -238,10 +242,10 @@ private static void applySpecs(Config config, Path specs) { while (fields.hasNext()) { Map.Entry field = fields.next(); - - ConfigGroup group = config.getModules().get(field.getKey()); + String configGroupName = aliases.resolveAlias(field.getKey(), emptyStack); + ConfigGroup group = config.getModules().get(configGroupName); if (group == null) { - log.warn("Config group not found: {}", field.getKey()); + log.warn("Config group not found: {}", configGroupName); continue; } diff --git a/contribs/carsharing/src/main/java/org/matsim/contrib/carsharing/scoring/CarsharingLegScoringFunction.java b/contribs/carsharing/src/main/java/org/matsim/contrib/carsharing/scoring/CarsharingLegScoringFunction.java index d7d8fdc0c34..f30d27c9ad3 100644 --- a/contribs/carsharing/src/main/java/org/matsim/contrib/carsharing/scoring/CarsharingLegScoringFunction.java +++ b/contribs/carsharing/src/main/java/org/matsim/contrib/carsharing/scoring/CarsharingLegScoringFunction.java @@ -55,7 +55,7 @@ public void finish() { AgentRentals agentRentals = this.demandHandler.getAgentRentalsMap().get(person.getId()); if (agentRentals != null) { - double marginalUtilityOfMoney = ((ScoringConfigGroup)this.config.getModule("planCalcScore")).getMarginalUtilityOfMoney(); + double marginalUtilityOfMoney = this.config.scoring().getMarginalUtilityOfMoney(); for(RentalInfo rentalInfo : agentRentals.getArr()) { CSVehicle vehicle = this.carsharingSupplyContainer.getAllVehicles().get(rentalInfo.getVehId().toString()); if (marginalUtilityOfMoney != 0.0)