From 1c940ae9382385b67e23f2f146d31dd3041fe05c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Friedrich=20V=C3=B6lkers?= Date: Wed, 18 Dec 2024 11:05:07 +0100 Subject: [PATCH 01/18] added activity dashboard and activity analysis (#3544) * added activity dashboard and activity analysis * first version of the activity analysis and the dashboard * add csv example for berlin * remove unused files * remove unused files * remove unused files * remove unused files * remove unused files * remove unused files * remove unused files * remove unused files * remove unused files * Improve wording on the activity dashboards * add some documentation * fix: activity dashboard bug * catch non existing network nodes * update activity dashboard * fix relative legend * fix scale in test data * fix number of breakpoints --------- Co-authored-by: rakow --- .../activity/ActivityCountAnalysis.java | 220 ++++++++++++++++++ .../traveltime/TravelTimeComparison.java | 23 ++ .../application/options/ShpOptions.java | 1 + .../main/java/org/matsim/simwrapper/Data.java | 33 ++- .../simwrapper/SimWrapperConfigGroup.java | 14 ++ .../matsim/simwrapper/SimWrapperListener.java | 7 +- .../matsim/simwrapper/SimWrapperRunner.java | 5 + .../dashboard/ActivityDashboard.java | 185 +++++++++++++++ .../org/matsim/simwrapper/viz/MapPlot.java | 6 +- .../simwrapper/dashboard/DashboardTests.java | 19 +- .../src/test/resources/kehlheim_ref.csv | 12 + .../src/test/resources/kehlheim_shape.cpg | 1 + .../src/test/resources/kehlheim_shape.dbf | Bin 0 -> 187 bytes .../src/test/resources/kehlheim_shape.prj | 1 + .../src/test/resources/kehlheim_shape.qmd | 44 ++++ .../src/test/resources/kehlheim_shape.shp | Bin 0 -> 4476 bytes .../src/test/resources/kehlheim_shape.shx | Bin 0 -> 188 bytes 17 files changed, 564 insertions(+), 7 deletions(-) create mode 100644 contribs/application/src/main/java/org/matsim/application/analysis/activity/ActivityCountAnalysis.java create mode 100644 contribs/simwrapper/src/main/java/org/matsim/simwrapper/dashboard/ActivityDashboard.java create mode 100644 contribs/simwrapper/src/test/resources/kehlheim_ref.csv create mode 100644 contribs/simwrapper/src/test/resources/kehlheim_shape.cpg create mode 100644 contribs/simwrapper/src/test/resources/kehlheim_shape.dbf create mode 100644 contribs/simwrapper/src/test/resources/kehlheim_shape.prj create mode 100644 contribs/simwrapper/src/test/resources/kehlheim_shape.qmd create mode 100644 contribs/simwrapper/src/test/resources/kehlheim_shape.shp create mode 100644 contribs/simwrapper/src/test/resources/kehlheim_shape.shx diff --git a/contribs/application/src/main/java/org/matsim/application/analysis/activity/ActivityCountAnalysis.java b/contribs/application/src/main/java/org/matsim/application/analysis/activity/ActivityCountAnalysis.java new file mode 100644 index 00000000000..b944ee044fb --- /dev/null +++ b/contribs/application/src/main/java/org/matsim/application/analysis/activity/ActivityCountAnalysis.java @@ -0,0 +1,220 @@ +package org.matsim.application.analysis.activity; + +import it.unimi.dsi.fastutil.objects.Object2IntMap; +import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; +import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.geotools.api.feature.Property; +import org.geotools.api.feature.simple.SimpleFeature; +import org.locationtech.jts.geom.Geometry; +import org.matsim.api.core.v01.Coord; +import org.matsim.application.CommandSpec; +import org.matsim.application.MATSimAppCommand; +import org.matsim.application.options.*; +import org.matsim.core.utils.io.IOUtils; +import picocli.CommandLine; +import tech.tablesaw.api.*; +import tech.tablesaw.io.csv.CsvReadOptions; +import tech.tablesaw.selection.Selection; + +import java.util.*; +import java.util.regex.Pattern; + +@CommandSpec( + requires = {"activities.csv"}, + produces = {"activities_%s_per_region.csv"} +) +public class ActivityCountAnalysis implements MATSimAppCommand { + + private static final Logger log = LogManager.getLogger(ActivityCountAnalysis.class); + + @CommandLine.Mixin + private final InputOptions input = InputOptions.ofCommand(ActivityCountAnalysis.class); + @CommandLine.Mixin + private final OutputOptions output = OutputOptions.ofCommand(ActivityCountAnalysis.class); + @CommandLine.Mixin + private ShpOptions shp; + @CommandLine.Mixin + private SampleOptions sample; + @CommandLine.Mixin + private CrsOptions crs; + + /** + * Specifies the column in the shapefile used as the region ID. + */ + @CommandLine.Option(names = "--id-column", description = "Column to use as ID for the shapefile", required = true) + private String idColumn; + + /** + * Maps patterns to merge activity types into a single category. + * Example: `home;work` can merge activities "home1" and "work1" into categories "home" and "work". + */ + @CommandLine.Option(names = "--activity-mapping", description = "Map of patterns to merge activity types", split = ";") + private Map activityMapping; + + /** + * Specifies activity types that should be counted only once per agent per region. + */ + @CommandLine.Option(names = "--single-occurrence", description = "Activity types that are only counted once per agent") + private Set singleOccurrence; + + public static void main(String[] args) { + new ActivityCountAnalysis().execute(args); + } + + /** + * Executes the activity count analysis. + * + * @return Exit code (0 for success). + * @throws Exception if errors occur during execution. + */ + @Override + public Integer call() throws Exception { + + // Prepares the activity mappings and reads input data + HashMap> formattedActivityMapping = new HashMap<>(); + Map regionAreaMap = new HashMap<>(); + + if (this.activityMapping == null) this.activityMapping = new HashMap<>(); + + for (Map.Entry entry : this.activityMapping.entrySet()) { + String pattern = entry.getKey(); + String activity = entry.getValue(); + Set activities = new HashSet<>(Arrays.asList(activity.split(","))); + formattedActivityMapping.put(pattern, activities); + } + + // Reading the input csv + Table activities = Table.read().csv(CsvReadOptions.builder(IOUtils.getBufferedReader(input.getPath("activities.csv"))) + .columnTypesPartial(Map.of("person", ColumnType.TEXT, "activity_type", ColumnType.TEXT)) + .sample(false) + .separator(CsvOptions.detectDelimiter(input.getPath("activities.csv"))).build()); + + // remove the underscore and the number from the activity_type column + TextColumn activityType = activities.textColumn("activity_type"); + activityType.set(Selection.withRange(0, activityType.size()), activityType.replaceAll("_[0-9]{2,}$", "")); + + ShpOptions.Index index = crs.getInputCRS() == null ? shp.createIndex(idColumn) : shp.createIndex(crs.getInputCRS(), idColumn); + + // stores the counts of activities per region + Object2ObjectOpenHashMap> regionActivityCounts = new Object2ObjectOpenHashMap<>(); + // stores the activities that have been counted for each person in each region + Object2ObjectOpenHashMap> personActivityTracker = new Object2ObjectOpenHashMap<>(); + + // iterate over the csv rows + for (Row row : activities) { + String person = row.getString("person"); + String activity = row.getText("activity_type"); + + for (Map.Entry> entry : formattedActivityMapping.entrySet()) { + String pattern = entry.getKey(); + Set activities2 = entry.getValue(); + for (String act : activities2) { + if (Pattern.matches(act, activity)) { + activity = pattern; + break; + } + } + } + + Coord coord = new Coord(row.getDouble("coord_x"), row.getDouble("coord_y")); + + // get the region for the current coordinate + SimpleFeature feature = index.queryFeature(coord); + + if (feature == null) { + continue; + } + + Geometry geometry = (Geometry) feature.getDefaultGeometry(); + + Property prop = feature.getProperty(idColumn); + if (prop == null) + throw new IllegalArgumentException("No property found for column %s".formatted(idColumn)); + + Object region = prop.getValue(); + if (region != null && region.toString().length() > 0) { + + double area = geometry.getArea(); + regionAreaMap.put(region.toString(), area); + + // Add region to the activity counts and person activity tracker if not already present + regionActivityCounts.computeIfAbsent(region, k -> new Object2IntOpenHashMap<>()); + personActivityTracker.computeIfAbsent(region, k -> new HashSet<>()); + + Set trackedActivities = personActivityTracker.get(region); + String personActivityKey = person + "_" + activity; + + // adding activity only if it has not been counted for the person in the region + if (singleOccurrence == null || !singleOccurrence.contains(activity) || !trackedActivities.contains(personActivityKey)) { + Object2IntMap activityCounts = regionActivityCounts.get(region); + activityCounts.mergeInt(activity, 1, Integer::sum); + + // mark the activity as counted for the person in the region + trackedActivities.add(personActivityKey); + } + } + } + + Set uniqueActivities = new HashSet<>(); + + for (Object2IntMap map : regionActivityCounts.values()) { + uniqueActivities.addAll(map.keySet()); + } + + for (String activity : uniqueActivities) { + Table resultTable = Table.create(); + TextColumn regionColumn = TextColumn.create("id"); + DoubleColumn activityColumn = DoubleColumn.create("count"); + DoubleColumn distributionColumn = DoubleColumn.create("relative_density"); + DoubleColumn countRatioColumn = DoubleColumn.create("density"); + DoubleColumn areaColumn = DoubleColumn.create("area"); + + resultTable.addColumns(regionColumn, activityColumn, distributionColumn, countRatioColumn, areaColumn); + for (Map.Entry> entry : regionActivityCounts.entrySet()) { + Object region = entry.getKey(); + double value = 0; + for (Map.Entry entry2 : entry.getValue().object2IntEntrySet()) { + String ect = entry2.getKey(); + if (Pattern.matches(ect, activity)) { + value = entry2.getValue() * sample.getUpscaleFactor(); + break; + } + } + + + Row row = resultTable.appendRow(); + row.setString("id", region.toString()); + row.setDouble("count", value); + } + + for (Row row : resultTable) { + Double area = regionAreaMap.get(row.getString("id")); + if (area != null) { + row.setDouble("area", area); + row.setDouble("density", row.getDouble("count") / area); + } else { + log.warn("Area for region {} is not found", row.getString("id")); + } + } + + Double averageDensity = countRatioColumn.mean(); + + for (Row row : resultTable) { + Double value = row.getDouble("density"); + if (averageDensity != 0) { + row.setDouble("relative_density", value / averageDensity); + } else { + row.setDouble("relative_density", 0.0); + } + } + + + resultTable.write().csv(output.getPath("activities_%s_per_region.csv", activity).toFile()); + log.info("Wrote activity counts for {} to {}", activity, output.getPath("activities_%s_per_region.csv", activity)); + } + + return 0; + } +} diff --git a/contribs/application/src/main/java/org/matsim/application/analysis/traffic/traveltime/TravelTimeComparison.java b/contribs/application/src/main/java/org/matsim/application/analysis/traffic/traveltime/TravelTimeComparison.java index 3c22fc678a3..41abdbcff54 100644 --- a/contribs/application/src/main/java/org/matsim/application/analysis/traffic/traveltime/TravelTimeComparison.java +++ b/contribs/application/src/main/java/org/matsim/application/analysis/traffic/traveltime/TravelTimeComparison.java @@ -1,5 +1,7 @@ package org.matsim.application.analysis.traffic.traveltime; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; @@ -47,6 +49,8 @@ ) public class TravelTimeComparison implements MATSimAppCommand { + private static final Logger log = LogManager.getLogger(TravelTimeComparison.class); + @CommandLine.Mixin private InputOptions input = InputOptions.ofCommand(TravelTimeComparison.class); @@ -90,6 +94,13 @@ public Integer call() throws Exception { for (Row row : data) { LeastCostPathCalculator.Path congested = computePath(network, congestedRouter, row); + + // Skip if path is not found + if (congested == null) { + row.setDouble("simulated", Double.NaN); + continue; + } + double dist = congested.links.stream().mapToDouble(Link::getLength).sum(); double speed = 3.6 * dist / congested.travelTime; @@ -102,6 +113,8 @@ public Integer call() throws Exception { row.setDouble("free_flow", speed); } + data = data.dropWhere(data.doubleColumn("simulated").isMissing()); + data.addColumns( data.doubleColumn("simulated").subtract(data.doubleColumn("mean")).setName("bias") ); @@ -129,6 +142,16 @@ private LeastCostPathCalculator.Path computePath(Network network, LeastCostPathC Node fromNode = network.getNodes().get(Id.createNodeId(row.getString("from_node"))); Node toNode = network.getNodes().get(Id.createNodeId(row.getString("to_node"))); + if (fromNode == null) { + log.error("Node {} not found in network", row.getString("from_node")); + return null; + } + + if (toNode == null) { + log.error("Node {} not found in network", row.getString("to_node")); + return null; + } + return router.calcLeastCostPath(fromNode, toNode, row.getInt("hour") * 3600, null, null); } diff --git a/contribs/application/src/main/java/org/matsim/application/options/ShpOptions.java b/contribs/application/src/main/java/org/matsim/application/options/ShpOptions.java index 5d9f8ccec99..55b7e01846e 100644 --- a/contribs/application/src/main/java/org/matsim/application/options/ShpOptions.java +++ b/contribs/application/src/main/java/org/matsim/application/options/ShpOptions.java @@ -230,6 +230,7 @@ public Geometry getGeometry() { /** * Return the union of all geometries in the shape file and project it to the target crs. + * * @param toCRS target coordinate system */ public Geometry getGeometry(String toCRS) { diff --git a/contribs/simwrapper/src/main/java/org/matsim/simwrapper/Data.java b/contribs/simwrapper/src/main/java/org/matsim/simwrapper/Data.java index d13bbc48ae4..16029040d47 100644 --- a/contribs/simwrapper/src/main/java/org/matsim/simwrapper/Data.java +++ b/contribs/simwrapper/src/main/java/org/matsim/simwrapper/Data.java @@ -3,8 +3,10 @@ import org.apache.commons.io.FilenameUtils; import org.matsim.application.CommandRunner; import org.matsim.application.MATSimAppCommand; +import org.matsim.core.utils.io.IOUtils; import javax.annotation.Nullable; +import java.io.UncheckedIOException; import java.net.URISyntaxException; import java.net.URL; import java.nio.file.Path; @@ -154,13 +156,40 @@ public String subcommand(String command, String file) { */ public String resource(String name) { - URL resource = this.getClass().getResource(name); + String path = resolveResource(name, true); + + // Handle shape files separately, copy additional files that are known to belong to shp files + if (name.endsWith(".shp")) { + resolveResource(name.replace(".shp", ".cpg"), false); + resolveResource(name.replace(".shp", ".dbf"), false); + resolveResource(name.replace(".shp", ".qix"), false); + resolveResource(name.replace(".shp", ".qmd"), false); + resolveResource(name.replace(".shp", ".prj"), false); + resolveResource(name.replace(".shp", ".shx"), false); + } + + return path; + } + + private String resolveResource(String name, boolean required) { + URL resource = null; + + try { + resource = IOUtils.resolveFileOrResource(name); + } catch (UncheckedIOException e) { + // Nothing to do + } if (resource == null) { // Try to prefix / automatically resource = this.getClass().getResource("/" + name); - if (resource == null) + } + + if (resource == null) { + if (required) throw new IllegalArgumentException("Resource '" + name + "' not found!"); + else + return null; } String baseName = FilenameUtils.getName(resource.getPath()); diff --git a/contribs/simwrapper/src/main/java/org/matsim/simwrapper/SimWrapperConfigGroup.java b/contribs/simwrapper/src/main/java/org/matsim/simwrapper/SimWrapperConfigGroup.java index 6bb420d1292..0914fda1eb7 100644 --- a/contribs/simwrapper/src/main/java/org/matsim/simwrapper/SimWrapperConfigGroup.java +++ b/contribs/simwrapper/src/main/java/org/matsim/simwrapper/SimWrapperConfigGroup.java @@ -1,5 +1,6 @@ package org.matsim.simwrapper; +import org.matsim.core.config.Config; import org.matsim.core.config.ConfigGroup; import org.matsim.core.config.ReflectiveConfigGroup; @@ -28,6 +29,10 @@ public class SimWrapperConfigGroup extends ReflectiveConfigGroup { @Comment("Set of simple class names or fully qualified class names of dashboards to exclude") public Set exclude = new HashSet<>(); + @Parameter + @Comment("Set of simple class names or fully qualified class names of dashboards to include. Any none included dashboard will be excluded.") + public Set include = new HashSet<>(); + @Parameter @Comment("Sample size of the run, which may be required by certain analysis functions.") public Double sampleSize = 1.0d; @@ -83,6 +88,15 @@ public void addParameterSet(ConfigGroup set) { } } + @Override + protected void checkConsistency(Config config) { + super.checkConsistency(config); + + if (!include.isEmpty() && !exclude.isEmpty()) { + throw new IllegalStateException("Include and exclude option can't be set both."); + } + } + /** * Mode how default dashboards are loaded. */ diff --git a/contribs/simwrapper/src/main/java/org/matsim/simwrapper/SimWrapperListener.java b/contribs/simwrapper/src/main/java/org/matsim/simwrapper/SimWrapperListener.java index 1270c938ee4..b9bd8c261a3 100644 --- a/contribs/simwrapper/src/main/java/org/matsim/simwrapper/SimWrapperListener.java +++ b/contribs/simwrapper/src/main/java/org/matsim/simwrapper/SimWrapperListener.java @@ -34,8 +34,8 @@ public class SimWrapperListener implements StartupListener, ShutdownListener { @Inject public SimWrapperListener(SimWrapper simWrapper, Set bindings, Config config) { this.simWrapper = simWrapper; - this.bindings = bindings; - this.config = config; + this.bindings = bindings; + this.config = config; } /** @@ -105,6 +105,9 @@ private void addFromProvider(SimWrapperConfigGroup config, Iterable exclude; + @CommandLine.Option(names = "--include", split = ",", description = "Use only the dashboards which classnames match.") + private Set include; + public static void main(String[] args) { new SimWrapperRunner().execute(args); } @@ -58,6 +61,8 @@ public Integer call() throws Exception { if (exclude != null) simWrapperConfigGroup.exclude.addAll(exclude); + if (include != null) + simWrapperConfigGroup.include.addAll(include); SimWrapperListener listener = new SimWrapperListener(SimWrapper.create(config), config); try { diff --git a/contribs/simwrapper/src/main/java/org/matsim/simwrapper/dashboard/ActivityDashboard.java b/contribs/simwrapper/src/main/java/org/matsim/simwrapper/dashboard/ActivityDashboard.java new file mode 100644 index 00000000000..5561ea641e8 --- /dev/null +++ b/contribs/simwrapper/src/main/java/org/matsim/simwrapper/dashboard/ActivityDashboard.java @@ -0,0 +1,185 @@ +package org.matsim.simwrapper.dashboard; + +import org.apache.commons.lang3.StringUtils; +import org.matsim.application.analysis.activity.ActivityCountAnalysis; +import org.matsim.simwrapper.Dashboard; +import org.matsim.simwrapper.Header; +import org.matsim.simwrapper.Layout; +import org.matsim.simwrapper.viz.ColorScheme; +import org.matsim.simwrapper.viz.MapPlot; +import org.matsim.simwrapper.viz.TextBlock; + +import javax.annotation.Nullable; +import java.util.*; +import java.util.stream.Collectors; + +/** + * Dashboard to show activity related statistics aggregated by type and location. + *

+ * Note that {@link #addActivityType(String, List, List, boolean, String)} needs to be called for each activity type. + * There is no default configuration. + */ +public class ActivityDashboard implements Dashboard { + + private static final String ID_COLUMN = "id"; + private static final String REF_JOIN = "id"; + + private final String shpFile; + private final Map activityMapping = new LinkedHashMap<>(); + private final Map refCsvs = new LinkedHashMap<>(); + private final Set countMultipleOccurrencesSet = new HashSet<>(); + private List indicators = new ArrayList<>(); + + public ActivityDashboard(String shpFile) { + this.shpFile = Objects.requireNonNull(shpFile, "Shapefile can not be null!"); + } + + /** + * Convenience method to add an activity type with default configuration. + */ + public ActivityDashboard addActivityType(String name, List activities, List indicators) { + return addActivityType(name, activities, indicators, true, null); + } + + /** + * Add an activity type to the dashboard. + * + * @param name name to show in the dashboard + * @param activities List of activity names to include in this type + * @param indicators List of indicators to show + * @param countMultipleOccurrences Whether multiple occurrences of the same activity for one person should be counted. + * Can be used to count home or workplaces only once. + * @param refCsv Reference CSV file to compare the activities to. Can be null. + */ + public ActivityDashboard addActivityType(String name, List activities, List indicators, + boolean countMultipleOccurrences, @Nullable String refCsv) { + activityMapping.put(name, String.join(",", activities)); + refCsvs.put(name, refCsv); + + if (countMultipleOccurrences) { + countMultipleOccurrencesSet.add(name); + } + + this.indicators = indicators; + return this; + } + + @Override + public void configure(Header header, Layout layout) { + + header.title = "Activities"; + header.description = "Displays the activities by type and location."; + + List args = new ArrayList<>(List.of("--id-column", ID_COLUMN, "--shp", shpFile)); + args.add("--activity-mapping"); + args.add(activityMapping.entrySet().stream() + .map(e -> "%s=%s".formatted(e.getKey(), e.getValue())) + .collect(Collectors.joining(";"))); + + args.add("--single-occurrence"); + if (!countMultipleOccurrencesSet.isEmpty()) { + args.add(String.join(";", countMultipleOccurrencesSet)); + } + + + for (Map.Entry activity : activityMapping.entrySet()) { + + String activityName = StringUtils.capitalize(activity.getKey()); + + layout.row("category_header_" + activity.getKey()) + .el(TextBlock.class, (viz, data) -> { + viz.content = "## **" + activityName + "**"; + viz.backgroundColor = "transparent"; + }); + + for (Indicator ind : Indicator.values()) { + + if (indicators.contains(ind)) { + + Layout.Row row = layout.row(activity.getKey() + "_" + ind.name) + .el(MapPlot.class, (viz, data) -> { + viz.title = "Simulated %s Activities (%s)".formatted(activityName, ind.displayName); + viz.height = 8.; + String shp = data.resource(shpFile); + viz.setShape(shp, ID_COLUMN); + viz.addDataset("transit-trips", data.computeWithPlaceholder(ActivityCountAnalysis.class, "activities_%s_per_region.csv", activity.getKey(), args.toArray(new String[0]))); + viz.display.fill.columnName = ind.name; + viz.display.fill.dataset = "transit-trips"; + viz.display.fill.join = REF_JOIN; + if (ind == Indicator.RELATIVE_DENSITY) { + viz.display.fill.setColorRamp(ColorScheme.RdBu, 11, false, "0.2, 0.25, 0.33, 0.5, 0.67, 1.5, 2.0, 3.0, 4.0, 5.0"); + } + }); + + if (refCsvs.get(activity.getKey()) != null) { + row.el(MapPlot.class, (viz, data) -> { + + viz.title = "Reference %s Activities (%s)".formatted(activityName, ind.displayName); + viz.height = 8.; + + String shp = data.resource(shpFile); + viz.setShape(shp, ID_COLUMN); + + viz.addDataset("transit-trips", data.resource(refCsvs.get(activity.getKey()))); + + viz.display.fill.dataset = "transit-trips"; + viz.display.fill.join = REF_JOIN; + + if (ind == Indicator.RELATIVE_DENSITY) { + viz.display.fill.columnName = "relative_density"; + viz.display.fill.setColorRamp(ColorScheme.RdBu, 11, false, "0.2, 0.25, 0.33, 0.5, 0.67, 1.5, 2.0, 3.0, 4.0, 5.0"); + } else if (ind == Indicator.DENSITY) { + viz.display.fill.columnName = "density"; + } else { + viz.display.fill.columnName = "count"; + } + }); + } + } + } + } + } + + /** + * Metric to show in the dashboard. + */ + public enum Indicator { + COUNTS("count", "Counts"), + DENSITY("density", "Density"), + RELATIVE_DENSITY("relative_density", "Relative Density"); + + private final String name; + private final String displayName; + + Indicator(String name, String displayName) { + this.name = name; + this.displayName = displayName; + } + } +} + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/contribs/simwrapper/src/main/java/org/matsim/simwrapper/viz/MapPlot.java b/contribs/simwrapper/src/main/java/org/matsim/simwrapper/viz/MapPlot.java index ac675cc6381..96ea10d5d94 100644 --- a/contribs/simwrapper/src/main/java/org/matsim/simwrapper/viz/MapPlot.java +++ b/contribs/simwrapper/src/main/java/org/matsim/simwrapper/viz/MapPlot.java @@ -10,15 +10,14 @@ */ public final class MapPlot extends Viz { + private final Map datasets = new HashMap<>(); public double[] center; public Double zoom; - public Display display = new Display(); public Double minValue; public Double maxValue; @JsonProperty(required = true) private Object shapes; - private Map datasets = new HashMap<>(); public MapPlot() { super("map"); @@ -77,6 +76,9 @@ public static final class DisplaySettings { @JsonProperty(required = true) public String columnName; + @JsonProperty(required = true) + public String normalize; + @JsonProperty(required = true) public String join; 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 e3e92fa87a7..a741dfeba78 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 @@ -20,11 +20,12 @@ import java.io.IOException; import java.nio.file.Path; +import java.util.List; import java.util.Set; public class DashboardTests { @RegisterExtension - private MatsimTestUtils utils = new MatsimTestUtils(); + private final MatsimTestUtils utils = new MatsimTestUtils(); private void run(Dashboard... dashboards) { @@ -153,4 +154,20 @@ void ptCustom() { Assertions.assertThat(out) .isDirectoryContaining("glob:**pt_pax_volumes.csv.gz"); } + + @Test + void activity() { + ActivityDashboard ad = new ActivityDashboard("kehlheim_shape.shp"); + + ad.addActivityType( + "work", + List.of("work"), + List.of(ActivityDashboard.Indicator.COUNTS, ActivityDashboard.Indicator.RELATIVE_DENSITY, ActivityDashboard.Indicator.DENSITY), true, + "kehlheim_ref.csv" + ); + + run(ad); + } + + } diff --git a/contribs/simwrapper/src/test/resources/kehlheim_ref.csv b/contribs/simwrapper/src/test/resources/kehlheim_ref.csv new file mode 100644 index 00000000000..1b3ba9c3824 --- /dev/null +++ b/contribs/simwrapper/src/test/resources/kehlheim_ref.csv @@ -0,0 +1,12 @@ +id;count;area;density;relative_density +2;12000.0;1743518.43;0.006882634;1.07723188785 +6;11000.0;350075.92;0.031421756;3.91795945 +4;2000.0;545791.40;0.003664404;0.5735321986 +8;13000.0;2121061.25;0.006129007;0.9592783427 +9;15000.0;3785838.06;0.003962135;0.6201314016 +10;7000.0;5744728.89;0.001218508;0.19071418629999998 +1;2000.0;1981892.09;0.001009137;0.19071418629999998 +3;12000.0;1955593.52;0.006136245;0.9604110622400001 +7;7000.0;942460.23;0.007427369;1.1624907459 +5;1000.0;876651.07;0.001140705;0.1785367932 +0;8000.0;6205676.03;0.001289142;0.2017694383 \ No newline at end of file diff --git a/contribs/simwrapper/src/test/resources/kehlheim_shape.cpg b/contribs/simwrapper/src/test/resources/kehlheim_shape.cpg new file mode 100644 index 00000000000..3ad133c048f --- /dev/null +++ b/contribs/simwrapper/src/test/resources/kehlheim_shape.cpg @@ -0,0 +1 @@ +UTF-8 \ No newline at end of file diff --git a/contribs/simwrapper/src/test/resources/kehlheim_shape.dbf b/contribs/simwrapper/src/test/resources/kehlheim_shape.dbf new file mode 100644 index 0000000000000000000000000000000000000000..d3b37577b5dff9efce8a897c02f1f0018b8ded66 GIT binary patch literal 187 zcmZRs;TGX$U|?`$0Fjs=GX*Z@2V!x-xex}g0vs5@SqjDorU`;+ieQ={nC1wk1%hb_ OXBry7nF>fuLn#13UJ_6M literal 0 HcmV?d00001 diff --git a/contribs/simwrapper/src/test/resources/kehlheim_shape.prj b/contribs/simwrapper/src/test/resources/kehlheim_shape.prj new file mode 100644 index 00000000000..bd846aeb220 --- /dev/null +++ b/contribs/simwrapper/src/test/resources/kehlheim_shape.prj @@ -0,0 +1 @@ +PROJCS["ETRS_1989_UTM_Zone_32N",GEOGCS["GCS_ETRS_1989",DATUM["D_ETRS_1989",SPHEROID["GRS_1980",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",500000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",9.0],PARAMETER["Scale_Factor",0.9996],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0]] \ No newline at end of file diff --git a/contribs/simwrapper/src/test/resources/kehlheim_shape.qmd b/contribs/simwrapper/src/test/resources/kehlheim_shape.qmd new file mode 100644 index 00000000000..53f5af5ac96 --- /dev/null +++ b/contribs/simwrapper/src/test/resources/kehlheim_shape.qmd @@ -0,0 +1,44 @@ + + + + + + dataset + + + + + + + + + + + + + + + + + + GEOGCRS["WGS 84",ENSEMBLE["World Geodetic System 1984 ensemble",MEMBER["World Geodetic System 1984 (Transit)"],MEMBER["World Geodetic System 1984 (G730)"],MEMBER["World Geodetic System 1984 (G873)"],MEMBER["World Geodetic System 1984 (G1150)"],MEMBER["World Geodetic System 1984 (G1674)"],MEMBER["World Geodetic System 1984 (G1762)"],ELLIPSOID["WGS 84",6378137,298.257223563,LENGTHUNIT["metre",1]],ENSEMBLEACCURACY[2.0]],PRIMEM["Greenwich",0,ANGLEUNIT["degree",0.0174532925199433]],CS[ellipsoidal,2],AXIS["geodetic latitude (Lat)",north,ORDER[1],ANGLEUNIT["degree",0.0174532925199433]],AXIS["geodetic longitude (Lon)",east,ORDER[2],ANGLEUNIT["degree",0.0174532925199433]],USAGE[SCOPE["Horizontal component of 3D system."],AREA["World."],BBOX[-90,-180,90,180]],ID["EPSG",4326]] + +proj=longlat +datum=WGS84 +no_defs + 3452 + 4326 + EPSG:4326 + WGS 84 + longlat + EPSG:7030 + true + + + + + + + + + + + + diff --git a/contribs/simwrapper/src/test/resources/kehlheim_shape.shp b/contribs/simwrapper/src/test/resources/kehlheim_shape.shp new file mode 100644 index 0000000000000000000000000000000000000000..ff0f9b67afd83cba76787f3f2db8f4f606c8669a GIT binary patch literal 4476 zcmai%2{ct}8^6Rum@%{I`_Uf*^zO}xy)_d0at>@kE`#k^Wc_%);MKk&S=TE43a4H|4 zAZ+cn2U>xD{;INGEQ28R(z7qE28%7uS(}kgkSqT(6ITbT5XxM`G=fZfSGaaA z*o_ycnv+71=Yj;bR>L>ZCn0t*Nd)=GiL4t2|J?dhtk!=BQYN8Pc{cjHSe=hq5l4_L zAvI57uwPw9_No|yG}uDVY;M9`=oGj4mCTI-5Jg512`t-}U>h(6U(VwDi2;r2QsYcM?)Cq#Rl0a$Rn z(7&jZAT>+k2ye{wdChe3Wd%Rx-szgUJSLYQLvGFqaDx4toY=MPOgl0%Ri)zX{o!Ao5qn%Y1Y>t+3?Y{2Y- zo^^eB1nCekw(tP>Wbu1BdE`O&)~-kk@RRoG{cXhrxuWsQzN29EqNi63k(Y=t&TDEs zI##U&)$&u|X?t&IzlEJ8miodP{Pr{3s~+FCt9#q-1e?hF*_&hh<0F9yY;cTX-uO7? zr?vA-KKkJ;{O{bGeP##jy!GlQ%aJEl#nLC#{JxI)KM5oLuWhqyJ-|#oA+Z3OA(axn4Qt&c6>ond4JaqCKYmR?F{6nutbDUN}p;qp#_V?{lrNhSwzz zlA~bCPiZvjNB4azm(2EuP1d4J<1E%In|pm`8F|du0==ozmXzvf1`3d$zlBE$J6QK7wt?7eQ|JdCRuVDXp=BfFh z8BF^&J}k>i1qVr4L~Mkw#L`v`GTFdv$q6b z|6}=|GQ9}qL|$3%iW-820LrNzFm-)>gIAMeV~)zmtdJkUL>99&aZ z97x5#)$iOvS?~$D{xlBwhSs@5es>Ad_2(0xGQsR(+inNMcQa?XObIwG#5BVU@w=TB zzDx0g*7|B5_Pc`aWjHj`i1orXKq1Rie{i*BYxa~KvokFYRVeqAwbJ%mR zuANSceAo_dFm~M1fOYZk54o0QV8`;Uc^+8DzABDu2rxaj(6v9=3&8t1*DjR6PW$F; z|4Mu#_JLOKz`6PG)%yBK!E=nqTQ+hw2izhopp*#ac*lztf&I-=|B*yI{x)*)S|*Cy+fS;xVX zb^d*_&YAf{im9#S@AF{IPZmRo&|XH5lPZN+YB;i0i|Ywe?e(ua!ryw$1HaDvv8aWHo-o{#kWlv$!htt>nq}>nOv%xuCAw6nyx+_QY|-C;7hU*i!J!-R?uJILE)5 zj9!%k|J8hwNXD9?wWPKE6gx|48|=(FXX=TZ2w}a>rq(O%3w;NCwO_39$kQKMP+HYoD%($7lFm=me=vq5j6T2pLXXeE*Mcndk13~&Y3`6*vj z;VO8pP*-$zD?vt!=^7Y=_lxE$OSNI2d=a}t9sKg6e@}QjL2j}&Ya547bgXAR7Af_D zSI!HNvVKgEN!xszi@_HB2B#PDu-+Rv+ULOy`~rb>%>)^{@Fw35@EI>n9Uq*XSJc#Z zYk-fZDeqqefApUi^>T5ael4D6Wd%FGxukorx-Na38)dw5g zw-5J59R;g;jobjcdal`8fx6>wkW*;@mx}}(FnBFZL3L(yYE9@WFz9_Y2UKeS2!u@8J6Q`#0Y`$%EZ;c~qGU<{PNXv}-`#wXZkT55m6Cr${;ob(G0X>5T^SQjf+4cMxP9 zcVKTPSpRwcG_h{Pr{b}TAK%m3sMQ!8egS)UghP%H-c|2go9g4hdM{a?9{mKV{M)P? z>K^ao$L_TRA9dDNR0VgrFHC3$hk8X_dn4teZrq2q6lX92I$@BB1k${4>D38Rd(Xs^c$Wk3A^3nzDR4VgWvKZax}qQ z6_wIEh&QTw@fka?%bW?bR_Jq4qNI?zKL||T5eFylZOr_lPVm4hi+O1qc1o(Umxq)3xa81zQ=tqPX$-RHwByG`zWc~!p0fkt}xvQ z^tTFAdUXOUb;&is8Eh263Q7k{ez}+tiF*_M9exQ1FCUk%ltP@7$Kw4`;y33bxFX$9bJCHDtH}9KOe){RQrU zbsIv65Ae^&Zd~XW^fz@I3VsisQTD9=3hwn>z=5U$HCG$^ZMST z6J)8znfqnXW37I!RXpw&;}?9(%E8x`YuxO?eaS3P(&|sJMe?q|Enr!f_1czT*4iDG zZ^6pLCi6AHbglwf@maILW@#;B_h9EFJkc3NT{7Q$%y&C8pQsCAw7=iM^tbd|mEIF* v->ABv-@(jznSL?-X2!*go1Tk*a{r<0mwvY}-!;s4HuD`$$3oXQ)8GFB)An<@ literal 0 HcmV?d00001 diff --git a/contribs/simwrapper/src/test/resources/kehlheim_shape.shx b/contribs/simwrapper/src/test/resources/kehlheim_shape.shx new file mode 100644 index 0000000000000000000000000000000000000000..1be796e8141d61ef66765e3577cb6dce8dc65f5b GIT binary patch literal 188 zcmZQzQ0HR64&q)gGcd3M<#wH7^?5W;)p66Gw5i@}LL3T*1J=Xa%HCFfcH&0qFoB9R;LsFfcHi0p&Ot7+9Pj@~nJ7z5oLQn-YX( Khstw+ Date: Thu, 19 Dec 2024 13:35:57 +0100 Subject: [PATCH 02/18] Noise maintenance: Add an option to independently enable or disable reflection calculation, regardless of noise shielding. --- .../contrib/noise/NoiseConfigGroup.java | 23 +- .../contrib/noise/RLS19NoiseImmission.java | 34 +-- .../contrib/noise/ReflectionContext.java | 35 +-- .../contrib/noise/ShieldingContext.java | 249 ++++++++---------- 4 files changed, 159 insertions(+), 182 deletions(-) diff --git a/contribs/noise/src/main/java/org/matsim/contrib/noise/NoiseConfigGroup.java b/contribs/noise/src/main/java/org/matsim/contrib/noise/NoiseConfigGroup.java index c2c9bc8d039..0833d66f019 100644 --- a/contribs/noise/src/main/java/org/matsim/contrib/noise/NoiseConfigGroup.java +++ b/contribs/noise/src/main/java/org/matsim/contrib/noise/NoiseConfigGroup.java @@ -43,7 +43,7 @@ * Provides the parameters required to build a simple grid with some basic spatial functionality. * Provides the parameters required to compute noise emissions, immissions and damages. * - * @author ikaddoura + * @author ikaddoura, nkuehnel */ public final class NoiseConfigGroup extends ReflectiveConfigGroup { @@ -81,6 +81,7 @@ public final class NoiseConfigGroup extends ReflectiveConfigGroup { private static final String RECEIVER_POINT_GAP_CMT = "horizontal and vertical distance between receiver points in x-/y-coordinate units"; private static final String WRITE_OUTPUT_ITERATION_CMT = "Specifies how often the noise-specific output is written out."; private static final String CONSIDER_NOISE_BARRIERS = "considerNoiseBarriers"; + private static final String CONSIDER_NOISE_REFLECTION = "considerNoiseReflection"; private static final String NOISE_BARRIERS_GEOJSON_FILE = "noiseBarriersGeojsonPath"; private static final String NOISE_BARRIERS_SOURCE_CRS = "source coordinate reference system of noise barriers geojson file"; private static final String NETWORK_MODES_TO_IGNORE = "networkModesToIgnore"; @@ -142,6 +143,7 @@ public enum NoiseAllocationApproach { private double noiseTollFactor = 1.0; private boolean considerNoiseBarriers = false; + private boolean considerNoiseReflection = false; private String noiseBarriersFilePath = null; private String noiseBarriersSourceCrs = null; @@ -204,6 +206,7 @@ public Map getComments() { comments.put(NOISE_TOLL_FACTOR, "To be used for sensitivity analysis. Default: 1.0 (= the parameter has no effect)"); comments.put(CONSIDER_NOISE_BARRIERS, "Set to 'true' if noise barriers / building shielding should be considered. Otherwise set to 'false'."); + comments.put(CONSIDER_NOISE_REFLECTION, "Set to 'true' if reflections should be considered. Otherwise set to 'false'. Has a considerable performance impact."); comments.put(NOISE_BARRIERS_GEOJSON_FILE, "Path to the geojson file for noise barriers."); comments.put(NOISE_BARRIERS_SOURCE_CRS, "Source coordinate reference system of noise barriers geojson file."); @@ -308,6 +311,14 @@ private void checkNoiseParametersForConsistency(Config config) { + " It is therefore recommended not to use speeds outside of the range of valid parameters!"); } + if(considerNoiseReflection) { + if (!this.considerNoiseBarriers) { + if (this.noiseBarriersFilePath == null || "".equals(this.noiseBarriersFilePath)) { + log.warn("Cannot consider noise reflection without a specified file path to the geojson file of barriers / buildings."); + this.considerNoiseBarriers = false; + } + } + } if (this.considerNoiseBarriers) { if (this.noiseBarriersFilePath == null || "".equals(this.noiseBarriersFilePath)) { log.warn("Cannot consider noise barriers without a specified file path to the geojson file of barriers / buildings."); @@ -782,6 +793,16 @@ public void setConsiderNoiseBarriers(boolean considerNoiseBarriers) { this.considerNoiseBarriers = considerNoiseBarriers; } + @StringGetter(CONSIDER_NOISE_REFLECTION) + public boolean isConsiderNoiseReflection() { + return this.considerNoiseReflection; + } + + @StringSetter(CONSIDER_NOISE_REFLECTION) + public void setConsiderNoiseReflection(boolean considerNoiseReflection) { + this.considerNoiseReflection = considerNoiseReflection; + } + @StringGetter(NOISE_BARRIERS_GEOJSON_FILE) public String getNoiseBarriersFilePath() { return this.noiseBarriersFilePath; diff --git a/contribs/noise/src/main/java/org/matsim/contrib/noise/RLS19NoiseImmission.java b/contribs/noise/src/main/java/org/matsim/contrib/noise/RLS19NoiseImmission.java index 1e8f1cd2563..e0bb566141c 100644 --- a/contribs/noise/src/main/java/org/matsim/contrib/noise/RLS19NoiseImmission.java +++ b/contribs/noise/src/main/java/org/matsim/contrib/noise/RLS19NoiseImmission.java @@ -101,7 +101,9 @@ public double calculateCorrection(double projectedDistance, NoiseReceiverPoint n @Override public void setCurrentRp(NoiseReceiverPoint nrp) { - reflection.setCurrentReceiver(nrp); + if(noiseParams.isConsiderNoiseReflection()) { + reflection.setCurrentReceiver(nrp); + } } private double getSectionsCorrection(NoiseReceiverPoint nrp, Link link) { @@ -127,10 +129,12 @@ private double getSubSectionsCorrection(Coordinate nrpCoordinate, LineSegment se final double sectionCorrection = 10 * Math.log10(length) - calculateCorrection(nrpCoordinate, segment, null); correctionTemp += Math.pow(10, 0.1*sectionCorrection); - final Set reflectionLinks = reflection.getReflections(segment); - for(ReflectionContext.ReflectionTuple reflection: reflectionLinks) { - double sectionCorrectionReflection = 10 * Math.log10(reflection.reflectionLink.getLength()) - calculateCorrection(nrpCoordinate, reflection.reflectionLink, reflection.facade); - correctionTemp += Math.pow(10, 0.1 * sectionCorrectionReflection); + if(noiseParams.isConsiderNoiseReflection()) { + final Set reflectionLinks = reflection.getReflections(segment); + for (ReflectionContext.ReflectionTuple reflection : reflectionLinks) { + double sectionCorrectionReflection = 10 * Math.log10(reflection.reflectionLink().getLength()) - calculateCorrection(nrpCoordinate, reflection.reflectionLink(), reflection.facade()); + correctionTemp += Math.pow(10, 0.1 * sectionCorrectionReflection); + } } } else { double lMid = length / 2; @@ -149,10 +153,12 @@ private double getSubSectionsCorrection(Coordinate nrpCoordinate, LineSegment se final double sectionCorrection = 10 * Math.log10(central.getLength()) - calculateCorrection(nrpCoordinate, central, null); correctionTemp += Math.pow(10, 0.1 * sectionCorrection); - final Set reflectionLinks = reflection.getReflections(central); - for(ReflectionContext.ReflectionTuple reflection: reflectionLinks) { - double sectionCorrectionReflection = 10 * Math.log10(reflection.reflectionLink.getLength()) - calculateCorrection(nrpCoordinate, reflection.reflectionLink, reflection.facade); - correctionTemp += Math.pow(10, 0.1 * sectionCorrectionReflection); + if(noiseParams.isConsiderNoiseReflection()) { + final Set reflectionLinks = reflection.getReflections(central); + for (ReflectionContext.ReflectionTuple reflection : reflectionLinks) { + double sectionCorrectionReflection = 10 * Math.log10(reflection.reflectionLink().getLength()) - calculateCorrection(nrpCoordinate, reflection.reflectionLink(), reflection.facade()); + correctionTemp += Math.pow(10, 0.1 * sectionCorrectionReflection); + } } correctionTemp += getSubSectionsCorrection(nrpCoordinate, leftRemaining); @@ -174,7 +180,10 @@ private double calculateCorrection(Coordinate nrp, LineSegment segment, LineSegm //to maintain the correct signs. nk, Sep'20 double intersectionCorrection = intersection.calculateIntersectionCorrection(coordinate); - double multipleReflectionCorrection = reflection.getMultipleReflectionCorrection(segment); + double multipleReflectionCorrection = 0; + if(noiseParams.isConsiderNoiseReflection()) { + multipleReflectionCorrection = reflection.getMultipleReflectionCorrection(segment); + } double geometricDivergence = 20 * Math.log10(distance) + 10 * Math.log10(2 * Math.PI); double airDampeningFactor = distance / 200.; @@ -191,11 +200,6 @@ private double calculateCorrection(Coordinate nrp, LineSegment segment, LineSegm } else { return geometricDivergence + airDampeningFactor - intersectionCorrection + groundDampening ; } - - //TODO: implement reflection - if someone is looking for a (bachelor) thesis... -// double firstReflectionCorrection = 0; -// double secondReflectionCorrection = 0; -// return dampeningCorrection + firstReflectionCorrection + secondReflectionCorrection; } diff --git a/contribs/noise/src/main/java/org/matsim/contrib/noise/ReflectionContext.java b/contribs/noise/src/main/java/org/matsim/contrib/noise/ReflectionContext.java index 02639ac3d3b..145367afee6 100644 --- a/contribs/noise/src/main/java/org/matsim/contrib/noise/ReflectionContext.java +++ b/contribs/noise/src/main/java/org/matsim/contrib/noise/ReflectionContext.java @@ -1,5 +1,6 @@ package org.matsim.contrib.noise; +import jakarta.inject.Inject; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.locationtech.jts.algorithm.Angle; @@ -7,7 +8,6 @@ import org.locationtech.jts.geom.util.AffineTransformation; import org.matsim.core.config.Config; -import jakarta.inject.Inject; import java.util.*; /** @@ -15,18 +15,19 @@ * * @author nkuehnel */ -public class ReflectionContext { +public final class ReflectionContext { static final double SCAN_LINE_LENGTH = 1; - private final static Logger logger = LogManager.getLogger(org.matsim.contrib.noise.ShieldingContext.class); + private final static Logger logger = LogManager.getLogger(ReflectionContext.class); private Set visibleEdges; private Coordinate receiver; - private BarrierContext barrierContext; - private GeometryFactory geomFactory = new GeometryFactory(); + private final BarrierContext barrierContext; + private final GeometryFactory geomFactory = new GeometryFactory(); + record ReflectionTuple(LineSegment facade, LineSegment reflectionLink) { } @Inject ReflectionContext(BarrierContext barrierContext) { @@ -38,6 +39,7 @@ public class ReflectionContext { } void setCurrentReceiver(NoiseReceiverPoint nrp) { + receiver = new Coordinate(nrp.getCoord().getX(), nrp.getCoord().getY()); final Collection candidates = @@ -60,7 +62,7 @@ void setCurrentReceiver(NoiseReceiverPoint nrp) { } - Set findVisibleEdgesOfPolygon(List polygonEdges, Coordinate coordinate) { + private Set findVisibleEdgesOfPolygon(List polygonEdges, Coordinate coordinate) { Coordinate coordXinc = new Coordinate(coordinate.x + 1, coordinate.y); @@ -155,13 +157,9 @@ Set getReflections(LineSegment originalLink) { } } return reflections; -// return Collections.EMPTY_SET; } double getMultipleReflectionCorrection(LineSegment segment) { - if(this.receiver.x == 1420 && this.receiver.y == 20) { - System.out.println("jo"); - } final Coordinate coordinate = segment.midPoint(); Coordinate candidateRight = getReflectionSegment(coordinate, segment, 400); @@ -174,7 +172,7 @@ Set getReflections(LineSegment originalLink) { } else { return 0; } - if (candidateLeft != null && candidateRight != null){ + if (candidateLeft != null){ double w = candidateLeft.distance(candidateRight); return Math.min(2 * Math.min(candidateLeft.z, candidateRight.z) / w, 1.6); } @@ -265,7 +263,7 @@ private boolean hit(LineSegment facade, LineSegment originalLink) { return true; } - static boolean intersects(LineSegment segment1, LineSegment segment2) { + private static boolean intersects(LineSegment segment1, LineSegment segment2) { double dx0 = segment1.p1.x - segment1.p0.x; double dx1 = segment2.p1.x - segment2.p0.x; @@ -277,17 +275,6 @@ static boolean intersects(LineSegment segment1, LineSegment segment2) { double p1 = dy1 * (segment2.p1.x - segment1.p1.x) - dx1 * (segment2.p1.y - segment1.p1.y); double p2 = dy0 * (segment1.p1.x - segment2.p0.x) - dx0 * (segment1.p1.y - segment2.p0.y); double p3 = dy0 * (segment1.p1.x - segment2.p1.x) - dx0 * (segment1.p1.y - segment2.p1.y); - return (p0 * p1 <= 0) & (p2 * p3 <= 0); - } - - - static class ReflectionTuple { - final LineSegment facade; - final LineSegment reflectionLink; - - public ReflectionTuple(LineSegment facade, LineSegment reflectionLink) { - this.facade = facade; - this.reflectionLink = reflectionLink; - } + return (p0 * p1 <= 0) && (p2 * p3 <= 0); } } diff --git a/contribs/noise/src/main/java/org/matsim/contrib/noise/ShieldingContext.java b/contribs/noise/src/main/java/org/matsim/contrib/noise/ShieldingContext.java index 97af40ce515..ea4e97ca7e6 100644 --- a/contribs/noise/src/main/java/org/matsim/contrib/noise/ShieldingContext.java +++ b/contribs/noise/src/main/java/org/matsim/contrib/noise/ShieldingContext.java @@ -24,8 +24,6 @@ final class ShieldingContext { private final static Logger logger = LogManager.getLogger(ShieldingContext.class); - //STRtree increases performance by ~40% by reducing the amount of potential - //obstruction candidates. nkuehnel, mar '20 private final static double GROUND_HEIGHT = 0.5; private final ShieldingCorrection shieldingCorrection; @@ -35,7 +33,6 @@ final class ShieldingContext { ShieldingContext(Config config, ShieldingCorrection shieldingCorrection, BarrierContext barrierContext) { this.shieldingCorrection = shieldingCorrection; this.barrierContext = barrierContext; - NoiseConfigGroup noiseParams = ConfigUtils.addOrGetModule(config, NoiseConfigGroup.class); } ShieldingContext(ShieldingCorrection shieldingCorrection, BarrierContext barrierContext) { @@ -51,83 +48,73 @@ final class ShieldingContext { final Coordinate midPoint = segment.midPoint(); midPoint.z = GROUND_HEIGHT; -// final Point fromPoint = GeometryUtils.createGeotoolsPoint(link.getFromNode().getCoord()); -// final Point toPoint = GeometryUtils.createGeotoolsPoint(link.getToNode().getCoord()); - - Coordinate from = segment.p0; - Coordinate to = segment.p1; - LineString projectedLineOfSight = constructLineOfSight(rpPoint, midPoint); -// LineString fromLineOfSight = constructLineOfSight(rpPoint, from); -// LineString toLineOfSight = constructLineOfSight(rpPoint, to); NavigableMap edgeCandidates = getObstructionEdges(rpPoint, midPoint, projectedLineOfSight); edgeCandidates.put(projectedLineOfSight.getLength(), midPoint); - if (!edgeCandidates.isEmpty()) { - Coordinate lastFixedEdge = rpPoint; - Coordinate tmpEdge = rpPoint; - double currentHeight = GROUND_HEIGHT; + Coordinate lastFixedEdge = rpPoint; + Coordinate tmpEdge = rpPoint; + double currentHeight = GROUND_HEIGHT; - List consideredEdges = new ArrayList<>(); + List consideredEdges = new ArrayList<>(); - double distToCurrentEdge = 0; - while (lastFixedEdge != midPoint) { - if (edgeCandidates.isEmpty()) { - logger.warn("Skipping obstacle as distance appears to be 0."); - return correctionTermShielding; - } - Iterator edgesIterator = edgeCandidates.values().iterator(); - double maxSlope = Double.NEGATIVE_INFINITY; - double tmpDistance = 0; - while (edgesIterator.hasNext()) { - Coordinate edge = edgesIterator.next(); - double distance = lastFixedEdge.distance(edge); - double slope = (edge.z - currentHeight) / distance; - if (slope >= maxSlope) { - maxSlope = slope; - tmpEdge = edge; - tmpDistance = distance; - } + double distToCurrentEdge = 0; + while (lastFixedEdge != midPoint) { + if (edgeCandidates.isEmpty()) { + logger.warn("Skipping obstacle as distance appears to be 0."); + return correctionTermShielding; + } + Iterator edgesIterator = edgeCandidates.values().iterator(); + double maxSlope = Double.NEGATIVE_INFINITY; + double tmpDistance = 0; + while (edgesIterator.hasNext()) { + Coordinate edge = edgesIterator.next(); + double distance = lastFixedEdge.distance(edge); + double slope = (edge.z - currentHeight) / distance; + if (slope >= maxSlope) { + maxSlope = slope; + tmpEdge = edge; + tmpDistance = distance; } - lastFixedEdge = tmpEdge; - distToCurrentEdge += tmpDistance; - currentHeight = tmpEdge.z; - consideredEdges.add(lastFixedEdge); - edgeCandidates = edgeCandidates.tailMap(distToCurrentEdge, false); } + lastFixedEdge = tmpEdge; + distToCurrentEdge += tmpDistance; + currentHeight = tmpEdge.z; + consideredEdges.add(lastFixedEdge); + edgeCandidates = edgeCandidates.tailMap(distToCurrentEdge, false); + } - consideredEdges.remove(midPoint); + consideredEdges.remove(midPoint); - if (consideredEdges.isEmpty()) { - return correctionTermShielding; - } + if (consideredEdges.isEmpty()) { + return correctionTermShielding; + } - final double firstEdgeYDiff = GROUND_HEIGHT - consideredEdges.get(0).z; - double firstEdgeDistance = rpPoint.distance(consideredEdges.get(0)); - double receiverToFirstEdgeDistance - = Math.sqrt(firstEdgeYDiff * firstEdgeYDiff + firstEdgeDistance * firstEdgeDistance); - - double shieldingDepth = 0; - - Iterator it = consideredEdges.iterator(); - Coordinate edgeTemp = it.next(); - while (it.hasNext()) { - Coordinate edge = it.next(); - double xyDiff = edgeTemp.distance(edge); - double zDiff = edgeTemp.z - edge.z; - shieldingDepth += Math.sqrt(xyDiff * xyDiff + zDiff * zDiff); - edgeTemp = edge; - } + final double firstEdgeYDiff = GROUND_HEIGHT - consideredEdges.get(0).z; + double firstEdgeDistance = rpPoint.distance(consideredEdges.get(0)); + double receiverToFirstEdgeDistance + = Math.sqrt(firstEdgeYDiff * firstEdgeYDiff + firstEdgeDistance * firstEdgeDistance); + + double shieldingDepth = 0; + + Iterator it = consideredEdges.iterator(); + Coordinate edgeTemp = it.next(); + while (it.hasNext()) { + Coordinate edge = it.next(); + double xyDiff = edgeTemp.distance(edge); + double zDiff = edgeTemp.z - edge.z; + shieldingDepth += Math.sqrt(xyDiff * xyDiff + zDiff * zDiff); + edgeTemp = edge; + } - final double lastEdgeSourceXYDiff = midPoint.distance(edgeTemp); - final double lastEdgeSourceZDiff = GROUND_HEIGHT - edgeTemp.z; - double lastEdgeToSourceDistance = Math.sqrt(lastEdgeSourceXYDiff * lastEdgeSourceXYDiff - + lastEdgeSourceZDiff * lastEdgeSourceZDiff); + final double lastEdgeSourceXYDiff = midPoint.distance(edgeTemp); + final double lastEdgeSourceZDiff = GROUND_HEIGHT - edgeTemp.z; + double lastEdgeToSourceDistance = Math.sqrt(lastEdgeSourceXYDiff * lastEdgeSourceXYDiff + + lastEdgeSourceZDiff * lastEdgeSourceZDiff); - correctionTermShielding = shieldingCorrection.calculateShieldingCorrection( - rpPoint.distance(midPoint), lastEdgeToSourceDistance, receiverToFirstEdgeDistance, shieldingDepth); - } + correctionTermShielding = shieldingCorrection.calculateShieldingCorrection( + rpPoint.distance(midPoint), lastEdgeToSourceDistance, receiverToFirstEdgeDistance, shieldingDepth); return correctionTermShielding; } @@ -170,7 +157,6 @@ private ConcurrentSkipListMap getObstructionEdges(Coordinate //using intersects() and intersection() directly on the jts geometry. nkuehnel, aug '20 final Set intersections = intersection((Polygon) noiseBarrier.getGeometry().getGeometry(), directLineOfSight.getCoordinates()); - for (Coordinate coordinate : intersections) { coordinate.z = noiseBarrier.getHeight(); final double distance = receiver.distance(coordinate); @@ -226,25 +212,7 @@ private LineString constructLineOfSight(Coordinate receiver, Coordinate source) private Set intersection(Polygon polygon, Coordinate[] coords) { - - Set externalIntersections = intersection(polygon.getExteriorRing(), coords); - -// Set internalIntersections = null; -// for (int i = 0; i < polygon.getNumInteriorRing(); i++) { -// Set intersects = intersection(polygon.getInteriorRingN(i), coords); -// if (!intersects.isEmpty()) { -// if (internalIntersections == null) { -// internalIntersections = new HashSet<>(); -// } -// internalIntersections.addAll(intersects); -// } -// } - -// if(internalIntersections != null) { -// externalIntersections.addAll(internalIntersections); -// } - - return externalIntersections; + return intersection(polygon.getExteriorRing(), coords); } private Set intersection(LineString ring, Coordinate[] coords) { @@ -285,7 +253,6 @@ private static boolean intersects(Polygon polygon, LineString string) { } - /** * determines the shielding value z for a receiver point for a given link emission source */ @@ -305,70 +272,68 @@ private static boolean intersects(Polygon polygon, LineString string) { NavigableMap edgeCandidates = getObstructionEdges(rpPoint, projectedPoint, projectedLineOfSight, fromLineOfSight, toLineOfSight); edgeCandidates.put(projectedLineOfSight.getLength(), projectedPoint.getCoordinate()); - if (!edgeCandidates.isEmpty()) { - Coordinate lastFixedEdge = rpPoint.getCoordinate(); - Coordinate tmpEdge = rpPoint.getCoordinate(); - double currentHeight = GROUND_HEIGHT; + Coordinate lastFixedEdge = rpPoint.getCoordinate(); + Coordinate tmpEdge = rpPoint.getCoordinate(); + double currentHeight = GROUND_HEIGHT; - List consideredEdges = new ArrayList<>(); + List consideredEdges = new ArrayList<>(); - double distToCurrentEdge = 0; - while (lastFixedEdge != projectedPoint.getCoordinate()) { - if (edgeCandidates.isEmpty()) { - logger.warn("Skipping obstacle as distance appears to be 0."); - return correctionTermShielding; - } - Iterator edgesIterator = edgeCandidates.values().iterator(); - double maxSlope = Double.NEGATIVE_INFINITY; - double tmpDistance = 0; - while (edgesIterator.hasNext()) { - Coordinate edge = edgesIterator.next(); - double distance = lastFixedEdge.distance(edge); - double slope = (edge.z - currentHeight) / distance; - if (slope >= maxSlope) { - maxSlope = slope; - tmpEdge = edge; - tmpDistance = distance; - } + double distToCurrentEdge = 0; + while (lastFixedEdge != projectedPoint.getCoordinate()) { + if (edgeCandidates.isEmpty()) { + logger.warn("Skipping obstacle as distance appears to be 0."); + return correctionTermShielding; + } + Iterator edgesIterator = edgeCandidates.values().iterator(); + double maxSlope = Double.NEGATIVE_INFINITY; + double tmpDistance = 0; + while (edgesIterator.hasNext()) { + Coordinate edge = edgesIterator.next(); + double distance = lastFixedEdge.distance(edge); + double slope = (edge.z - currentHeight) / distance; + if (slope >= maxSlope) { + maxSlope = slope; + tmpEdge = edge; + tmpDistance = distance; } - lastFixedEdge = tmpEdge; - distToCurrentEdge += tmpDistance; - currentHeight = tmpEdge.z; - consideredEdges.add(lastFixedEdge); - edgeCandidates = edgeCandidates.tailMap(distToCurrentEdge, false); } + lastFixedEdge = tmpEdge; + distToCurrentEdge += tmpDistance; + currentHeight = tmpEdge.z; + consideredEdges.add(lastFixedEdge); + edgeCandidates = edgeCandidates.tailMap(distToCurrentEdge, false); + } - consideredEdges.remove(projectedPoint.getCoordinate()); + consideredEdges.remove(projectedPoint.getCoordinate()); - if (consideredEdges.isEmpty()) { - return correctionTermShielding; - } + if (consideredEdges.isEmpty()) { + return correctionTermShielding; + } - final double firstEdgeYDiff = GROUND_HEIGHT - consideredEdges.get(0).z; - double firstEdgeDistance = rpPoint.getCoordinate().distance(consideredEdges.get(0)); - double receiverToFirstEdgeDistance - = Math.sqrt(firstEdgeYDiff * firstEdgeYDiff + firstEdgeDistance * firstEdgeDistance); - - double shieldingDepth = 0; - - Iterator it = consideredEdges.iterator(); - Coordinate edgeTemp = it.next(); - while (it.hasNext()) { - Coordinate edge = it.next(); - double xyDiff = edgeTemp.distance(edge); - double zDiff = edgeTemp.z - edge.z; - shieldingDepth += Math.sqrt(xyDiff * xyDiff + zDiff * zDiff); - edgeTemp = edge; - } + final double firstEdgeYDiff = GROUND_HEIGHT - consideredEdges.getFirst().z; + double firstEdgeDistance = rpPoint.getCoordinate().distance(consideredEdges.getFirst()); + double receiverToFirstEdgeDistance + = Math.sqrt(firstEdgeYDiff * firstEdgeYDiff + firstEdgeDistance * firstEdgeDistance); + + double shieldingDepth = 0; + + Iterator it = consideredEdges.iterator(); + Coordinate edgeTemp = it.next(); + while (it.hasNext()) { + Coordinate edge = it.next(); + double xyDiff = edgeTemp.distance(edge); + double zDiff = edgeTemp.z - edge.z; + shieldingDepth += Math.sqrt(xyDiff * xyDiff + zDiff * zDiff); + edgeTemp = edge; + } - final double lastEdgeSourceXYDiff = projectedPoint.getCoordinate().distance(edgeTemp); - final double lastEdgeSourceZDiff = GROUND_HEIGHT - edgeTemp.z; - double lastEdgeToSourceDistance = Math.sqrt(lastEdgeSourceXYDiff * lastEdgeSourceXYDiff - + lastEdgeSourceZDiff * lastEdgeSourceZDiff); + final double lastEdgeSourceXYDiff = projectedPoint.getCoordinate().distance(edgeTemp); + final double lastEdgeSourceZDiff = GROUND_HEIGHT - edgeTemp.z; + double lastEdgeToSourceDistance = Math.sqrt(lastEdgeSourceXYDiff * lastEdgeSourceXYDiff + + lastEdgeSourceZDiff * lastEdgeSourceZDiff); - correctionTermShielding = shieldingCorrection.calculateShieldingCorrection( - rpPoint.distance(projectedPoint), lastEdgeToSourceDistance, receiverToFirstEdgeDistance, shieldingDepth); - } + correctionTermShielding = shieldingCorrection.calculateShieldingCorrection( + rpPoint.distance(projectedPoint), lastEdgeToSourceDistance, receiverToFirstEdgeDistance, shieldingDepth); return correctionTermShielding; } } From 2c26b6ab612995f6cec658b26ee9d49853d8517b Mon Sep 17 00:00:00 2001 From: Kai Martins-Turner Date: Fri, 20 Dec 2024 12:40:52 +0100 Subject: [PATCH 03/18] add getId() and getDemand() to interface --- .../matsim/freight/carriers/CarrierJob.java | 6 +++- .../freight/carriers/CarrierService.java | 29 ++++++++++++------- .../freight/carriers/CarrierShipment.java | 23 +++++++++++---- 3 files changed, 42 insertions(+), 16 deletions(-) diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierJob.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierJob.java index 1dc1cd32f8d..926c5ae379f 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierJob.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierJob.java @@ -1,5 +1,6 @@ package org.matsim.freight.carriers; +import org.matsim.api.core.v01.Id; import org.matsim.utils.objectattributes.attributable.Attributable; /** @@ -16,4 +17,7 @@ * future) It maybe gets generalized in way, that we only have one job definition with 1 or 2 * location(s). This then defines, if jsprit takes the job as a service or as a shipment. */ -public interface CarrierJob extends Attributable {} +public interface CarrierJob extends Attributable { + Id getId(); + int getDemand(); +} diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierService.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierService.java index 69a5ce75e42..244c95dd409 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierService.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierService.java @@ -23,7 +23,6 @@ import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; -import org.matsim.utils.objectattributes.attributable.Attributable; import org.matsim.utils.objectattributes.attributable.Attributes; import org.matsim.utils.objectattributes.attributable.AttributesImpl; @@ -41,7 +40,7 @@ public static Builder newInstance(Id id, Id locationLinkId private double serviceTime = 0.0; private TimeWindow timeWindow = TimeWindow.newInstance(0.0, Integer.MAX_VALUE); - private int capacityDemand = 0; + private int demand = 0; private Builder(Id id, Id locationLinkId) { super(); @@ -84,7 +83,7 @@ public CarrierService build(){ } public Builder setCapacityDemand(int value) { - this.capacityDemand = value; + this.demand = value; return this; } @@ -92,17 +91,11 @@ public Builder setCapacityDemand(int value) { private final Id id; - private final Id locationId; - private final String name; - private final double serviceDuration; - private final TimeWindow timeWindow; - private final int demand; - private final Attributes attributes = new AttributesImpl(); private CarrierService(Builder builder){ @@ -110,14 +103,17 @@ private CarrierService(Builder builder){ locationId = builder.locationLinkId; serviceDuration = builder.serviceTime; timeWindow = builder.timeWindow; - demand = builder.capacityDemand; + demand = builder.demand; name = builder.name; } + @Override public Id getId() { return id; } + + public Id getLocationLinkId() { return locationId; } @@ -130,10 +126,23 @@ public TimeWindow getServiceStartTimeWindow(){ return timeWindow; } + /** + * @deprecated please inline and use {@link #getDemand()} instead + */ + @Deprecated(since = "dez 2024") public int getCapacityDemand() { + return getDemand(); + } + + /** + * @return the demand (size; capacity needed) of the service. + */ + @Override + public int getDemand() { return demand; } + @Override public Attributes getAttributes() { return attributes; diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierShipment.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierShipment.java index 01c8b873e70..3cb62a59182 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierShipment.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierShipment.java @@ -23,7 +23,6 @@ import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; -import org.matsim.utils.objectattributes.attributable.Attributable; import org.matsim.utils.objectattributes.attributable.Attributes; import org.matsim.utils.objectattributes.attributable.AttributesImpl; @@ -136,7 +135,7 @@ public CarrierShipment build(){ private final Id id; private final Id from; private final Id to; - private final int size; + private final int demand; private final TimeWindow pickupTimeWindow; private final TimeWindow deliveryTimeWindow; private double pickupServiceTime; @@ -148,7 +147,7 @@ private CarrierShipment(Builder builder) { id = builder.id; from = builder.from; to = builder.to; - size = builder.size; + demand = builder.size; pickupServiceTime = builder.pickServiceTime; deliveryServiceTime = builder.delServiceTime; pickupTimeWindow = builder.pickTW; @@ -171,9 +170,11 @@ public void setDeliveryServiceTime(double deliveryServiceTime) { this.deliveryServiceTime = deliveryServiceTime; } + @Override public Id getId() { return id; } + public Id getFrom() { return from; } @@ -182,8 +183,20 @@ public Id getTo() { return to; } + /** + * @deprecated please inline and use {@link #getDemand()} instead + */ + @Deprecated(since = "dez 2024") public int getSize() { - return size; + return getDemand(); + } + + /** + * @return the demand (size; capacity needed) of the shipment. + */ + @Override + public int getDemand() { + return demand; } public TimeWindow getPickupTimeWindow() { @@ -201,7 +214,7 @@ public Attributes getAttributes() { @Override public String toString() { - return "[id= "+ id.toString() + "][hash=" + this.hashCode() + "][from=" + from.toString() + "][to=" + to.toString() + "][size=" + size + "][pickupServiceTime=" + pickupServiceTime + "]" + + return "[id= "+ id.toString() + "][hash=" + this.hashCode() + "][from=" + from.toString() + "][to=" + to.toString() + "][size=" + demand + "][pickupServiceTime=" + pickupServiceTime + "]" + "[deliveryServiceTime="+deliveryServiceTime+"][pickupTimeWindow="+pickupTimeWindow+"][deliveryTimeWindow="+deliveryTimeWindow+"]"; } From 9e964e0c937bec769766c15c8c039545b219e166 Mon Sep 17 00:00:00 2001 From: Kai Martins-Turner Date: Fri, 20 Dec 2024 12:44:21 +0100 Subject: [PATCH 04/18] replace getSize() and getCapacityDemand() by new method getDemand() --- .../DemandReaderFromCSV.java | 4 +- .../DemandReaderFromCSVTest.java | 98 ++++++++++--------- .../carriers/CarrierPlanXmlWriterV2_1.java | 6 +- .../freight/carriers/CarriersUtils.java | 2 +- .../analysis/CarrierPlanAnalysis.java | 8 +- .../events/CarrierServiceStartEvent.java | 2 +- .../CarrierShipmentDeliveryEndEvent.java | 2 +- .../CarrierShipmentDeliveryStartEvent.java | 2 +- .../events/CarrierShipmentPickupEndEvent.java | 2 +- .../CarrierShipmentPickupStartEvent.java | 2 +- .../carriers/jsprit/MatsimJspritFactory.java | 6 +- .../multipleChains/MultipleChainsUtils.java | 2 +- .../freight/carriers/CarriersUtilsTest.java | 2 +- .../jsprit/MatsimTransformerTest.java | 4 +- .../utils/CarrierControllerUtilsTest.java | 16 +-- .../CollectionTrackerTest.java | 3 +- .../CollectionLSPSchedulingTest.java | 4 +- .../CompleteLSPSchedulingTest.java | 16 +-- .../FirstReloadLSPSchedulingTest.java | 6 +- .../MainRunLSPSchedulingTest.java | 10 +- ...eShipmentsCollectionLSPSchedulingTest.java | 4 +- ...pleShipmentsCompleteLSPSchedulingTest.java | 16 +-- ...ShipmentsFirstReloadLSPSchedulingTest.java | 6 +- ...ipleShipmentsMainRunLSPSchedulingTest.java | 16 +-- ...hipmentsSecondReloadLSPSchedulingTest.java | 18 ++-- .../SecondReloadLSPSchedulingTest.java | 12 +-- ...iverTriggersCarrierReplanningListener.java | 2 +- 27 files changed, 137 insertions(+), 134 deletions(-) diff --git a/contribs/application/src/main/java/org/matsim/freightDemandGeneration/DemandReaderFromCSV.java b/contribs/application/src/main/java/org/matsim/freightDemandGeneration/DemandReaderFromCSV.java index 63179128cc4..3f7c9c242e0 100644 --- a/contribs/application/src/main/java/org/matsim/freightDemandGeneration/DemandReaderFromCSV.java +++ b/contribs/application/src/main/java/org/matsim/freightDemandGeneration/DemandReaderFromCSV.java @@ -1200,7 +1200,7 @@ private static void combineSimilarJobs(Scenario scenario) { double serviceTimePickup = 0; double serviceTimeDelivery = 0; for (CarrierShipment carrierShipment : shipmentsToConnect.values()) { - demandForThisLink = demandForThisLink + carrierShipment.getSize(); + demandForThisLink = demandForThisLink + carrierShipment.getDemand(); serviceTimePickup = serviceTimePickup + carrierShipment.getPickupServiceTime(); serviceTimeDelivery = serviceTimeDelivery + carrierShipment.getDeliveryServiceTime(); shipmentsToRemove.put(carrierShipment.getId(), carrierShipment); @@ -1245,7 +1245,7 @@ private static void combineSimilarJobs(Scenario scenario) { int demandForThisLink = 0; double serviceTimeService = 0; for (CarrierService carrierService : servicesToConnect.values()) { - demandForThisLink = demandForThisLink + carrierService.getCapacityDemand(); + demandForThisLink = demandForThisLink + carrierService.getDemand(); serviceTimeService = serviceTimeService + carrierService.getServiceDuration(); servicesToRemove.put(carrierService.getId(), carrierService); } diff --git a/contribs/application/src/test/java/org/matsim/freightDemandGeneration/DemandReaderFromCSVTest.java b/contribs/application/src/test/java/org/matsim/freightDemandGeneration/DemandReaderFromCSVTest.java index 9cd21c16d9d..0658741aacd 100644 --- a/contribs/application/src/test/java/org/matsim/freightDemandGeneration/DemandReaderFromCSVTest.java +++ b/contribs/application/src/test/java/org/matsim/freightDemandGeneration/DemandReaderFromCSVTest.java @@ -101,9 +101,9 @@ void demandCreationWithSampleWithChangeNumberOfLocations() throws IOException { locationsPerShipmentElement = new HashMap<>(); countDemand = 0; for (CarrierShipment shipment : testCarrier3.getShipments().values()) { - countShipmentsWithCertainDemand.merge((Integer) shipment.getSize(), 1, Integer::sum); - countDemand = countDemand + shipment.getSize(); - Assertions.assertEquals(5, shipment.getSize()); + countShipmentsWithCertainDemand.merge((Integer) shipment.getDemand(), 1, Integer::sum); + countDemand = countDemand + shipment.getDemand(); + Assertions.assertEquals(5, shipment.getDemand()); Assertions.assertEquals(2000, shipment.getPickupServiceTime(), MatsimTestUtils.EPSILON); Assertions.assertEquals(1250, shipment.getDeliveryServiceTime(), MatsimTestUtils.EPSILON); Assertions.assertEquals(TimeWindow.newInstance(8000, 50000), shipment.getPickupTimeWindow()); @@ -168,9 +168,9 @@ void demandCreationWithSampleWithDemandOnLocation() throws IOException { locationsPerShipmentElement = new HashMap<>(); countDemand = 0; for (CarrierShipment shipment : testCarrier3.getShipments().values()) { - countShipmentsWithCertainDemand.merge((Integer) shipment.getSize(), 1, Integer::sum); - countDemand = countDemand + shipment.getSize(); - Assertions.assertEquals(10, shipment.getSize()); + countShipmentsWithCertainDemand.merge((Integer) shipment.getDemand(), 1, Integer::sum); + countDemand = countDemand + shipment.getDemand(); + Assertions.assertEquals(10, shipment.getDemand()); Assertions.assertEquals(4000, shipment.getPickupServiceTime(), MatsimTestUtils.EPSILON); Assertions.assertEquals(2500, shipment.getDeliveryServiceTime(), MatsimTestUtils.EPSILON); Assertions.assertEquals(TimeWindow.newInstance(8000, 50000), shipment.getPickupTimeWindow()); @@ -235,9 +235,9 @@ void demandCreationWithSampleWithDemandOnLocationWithCombiningJobs() throws IOEx locationsPerShipmentElement = new HashMap<>(); countDemand = 0; for (CarrierShipment shipment : testCarrier3.getShipments().values()) { - countShipmentsWithCertainDemand.merge((Integer) shipment.getSize(), 1, Integer::sum); - countDemand = countDemand + shipment.getSize(); - Assertions.assertEquals(10, shipment.getSize()); + countShipmentsWithCertainDemand.merge((Integer) shipment.getDemand(), 1, Integer::sum); + countDemand = countDemand + shipment.getDemand(); + Assertions.assertEquals(10, shipment.getDemand()); Assertions.assertEquals(4000, shipment.getPickupServiceTime(), MatsimTestUtils.EPSILON); Assertions.assertEquals(2500, shipment.getDeliveryServiceTime(), MatsimTestUtils.EPSILON); Assertions.assertEquals(TimeWindow.newInstance(8000, 50000), shipment.getPickupTimeWindow()); @@ -305,9 +305,9 @@ void demandCreationNoSampling() throws IOException { locationsPerShipmentElement = new HashMap<>(); countDemand = 0; for (CarrierShipment shipment : testCarrier3.getShipments().values()) { - countShipmentsWithCertainDemand.merge((Integer) shipment.getSize(), 1, Integer::sum); - countDemand = countDemand + shipment.getSize(); - Assertions.assertEquals(10, shipment.getSize()); + countShipmentsWithCertainDemand.merge((Integer) shipment.getDemand(), 1, Integer::sum); + countDemand = countDemand + shipment.getDemand(); + Assertions.assertEquals(10, shipment.getDemand()); Assertions.assertEquals(4000, shipment.getPickupServiceTime(), MatsimTestUtils.EPSILON); Assertions.assertEquals(2500, shipment.getDeliveryServiceTime(), MatsimTestUtils.EPSILON); Assertions.assertEquals(TimeWindow.newInstance(8000, 50000), shipment.getPickupTimeWindow()); @@ -474,25 +474,27 @@ private static void checkCarrier1and2(Scenario scenario, Network network, ShpOpt Map> locationsPerServiceElement = new HashMap<>(); int countDemand = 0; for (CarrierService service : testCarrier1.getServices().values()) { - countServicesWithCertainDemand.merge((Integer) service.getCapacityDemand(), 1, Integer::sum); - countDemand = countDemand + service.getCapacityDemand(); - if (service.getCapacityDemand() == 0) { + countServicesWithCertainDemand.merge((Integer) service.getDemand(), 1, Integer::sum); + countDemand = countDemand + service.getDemand(); + if (service.getDemand() == 0) { Assertions.assertEquals(180, service.getServiceDuration(), MatsimTestUtils.EPSILON); Assertions.assertEquals(TimeWindow.newInstance(3000, 13000), service.getServiceStartTimeWindow()); locationsPerServiceElement.computeIfAbsent("serviceElement1", (k) -> new HashSet<>()) .add(service.getLocationLinkId().toString()); - } else if (service.getCapacityDemand() == 1) { + } else if (service.getDemand() == 1) { Assertions.assertEquals(100, service.getServiceDuration(), MatsimTestUtils.EPSILON); Assertions.assertEquals(TimeWindow.newInstance(5000, 20000), service.getServiceStartTimeWindow()); locationsPerServiceElement.computeIfAbsent("serviceElement2", (k) -> new HashSet<>()) .add(service.getLocationLinkId().toString()); - } else if (service.getCapacityDemand() == 2) { - Assertions.assertEquals(200, service.getServiceDuration(), MatsimTestUtils.EPSILON); - Assertions.assertEquals(TimeWindow.newInstance(5000, 20000), service.getServiceStartTimeWindow()); - locationsPerServiceElement.computeIfAbsent("serviceElement2", (k) -> new HashSet<>()) - .add(service.getLocationLinkId().toString()); - } else - Assertions.fail("Service has a wrong demand."); + } else { + if (service.getDemand() == 2) { + Assertions.assertEquals(200, service.getServiceDuration(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(TimeWindow.newInstance(5000, 20000), service.getServiceStartTimeWindow()); + locationsPerServiceElement.computeIfAbsent("serviceElement2", (k) -> new HashSet<>()) + .add(service.getLocationLinkId().toString()); + } else + Assertions.fail("Service has a wrong demand."); + } } Assertions.assertEquals(12, countDemand); Assertions.assertEquals(4, countServicesWithCertainDemand.getInt(0)); @@ -520,9 +522,9 @@ private static void checkCarrier1and2(Scenario scenario, Network network, ShpOpt Map> locationsPerShipmentElement = new HashMap<>(); countDemand = 0; for (CarrierShipment shipment : testCarrier2.getShipments().values()) { - countShipmentsWithCertainDemand.merge((Integer) shipment.getSize(), 1, Integer::sum); - countDemand = countDemand + shipment.getSize(); - if (shipment.getSize() == 0) { + countShipmentsWithCertainDemand.merge((Integer) shipment.getDemand(), 1, Integer::sum); + countDemand = countDemand + shipment.getDemand(); + if (shipment.getDemand() == 0) { Assertions.assertEquals(300, shipment.getPickupServiceTime(), MatsimTestUtils.EPSILON); Assertions.assertEquals(350, shipment.getDeliveryServiceTime(), MatsimTestUtils.EPSILON); Assertions.assertEquals(TimeWindow.newInstance(10000, 45000), shipment.getPickupTimeWindow()); @@ -531,7 +533,7 @@ private static void checkCarrier1and2(Scenario scenario, Network network, ShpOpt .add(shipment.getFrom().toString()); locationsPerShipmentElement.computeIfAbsent("ShipmentElement1_delivery", (k) -> new HashSet<>()) .add(shipment.getTo().toString()); - } else if (shipment.getSize() == 2) { + } else if (shipment.getDemand() == 2) { Assertions.assertEquals(400, shipment.getPickupServiceTime(), MatsimTestUtils.EPSILON); Assertions.assertEquals(400, shipment.getDeliveryServiceTime(), MatsimTestUtils.EPSILON); Assertions.assertEquals(TimeWindow.newInstance(11000, 44000), shipment.getPickupTimeWindow()); @@ -540,17 +542,19 @@ private static void checkCarrier1and2(Scenario scenario, Network network, ShpOpt .add(shipment.getFrom().toString()); locationsPerShipmentElement.computeIfAbsent("ShipmentElement2_delivery", (k) -> new HashSet<>()) .add(shipment.getTo().toString()); - } else if (shipment.getSize() == 3) { - Assertions.assertEquals(600, shipment.getPickupServiceTime(), MatsimTestUtils.EPSILON); - Assertions.assertEquals(600, shipment.getDeliveryServiceTime(), MatsimTestUtils.EPSILON); - Assertions.assertEquals(TimeWindow.newInstance(11000, 44000), shipment.getPickupTimeWindow()); - Assertions.assertEquals(TimeWindow.newInstance(20000, 40000), shipment.getDeliveryTimeWindow()); - locationsPerShipmentElement.computeIfAbsent("ShipmentElement2_pickup", (k) -> new HashSet<>()) - .add(shipment.getFrom().toString()); - locationsPerShipmentElement.computeIfAbsent("ShipmentElement2_delivery", (k) -> new HashSet<>()) - .add(shipment.getTo().toString()); - } else - Assertions.fail("Shipment has an unexpected demand."); + } else { + if (shipment.getDemand() == 3) { + Assertions.assertEquals(600, shipment.getPickupServiceTime(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(600, shipment.getDeliveryServiceTime(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(TimeWindow.newInstance(11000, 44000), shipment.getPickupTimeWindow()); + Assertions.assertEquals(TimeWindow.newInstance(20000, 40000), shipment.getDeliveryTimeWindow()); + locationsPerShipmentElement.computeIfAbsent("ShipmentElement2_pickup", (k) -> new HashSet<>()) + .add(shipment.getFrom().toString()); + locationsPerShipmentElement.computeIfAbsent("ShipmentElement2_delivery", (k) -> new HashSet<>()) + .add(shipment.getTo().toString()); + } else + Assertions.fail("Shipment has an unexpected demand."); + } } Assertions.assertEquals(15, countDemand); Assertions.assertEquals(4, countShipmentsWithCertainDemand.getInt(0)); @@ -579,15 +583,15 @@ private static void checkCarrier1and2WithCombiningJobs(Scenario scenario, Networ Map> locationsPerServiceElement = new HashMap<>(); int countDemand = 0; for (CarrierService service : testCarrier1.getServices().values()) { - countServicesWithCertainDemand.merge((Integer) service.getCapacityDemand(), 1, Integer::sum); - countDemand = countDemand + service.getCapacityDemand(); - if (service.getCapacityDemand() == 0) { + countServicesWithCertainDemand.merge((Integer) service.getDemand(), 1, Integer::sum); + countDemand = countDemand + service.getDemand(); + if (service.getDemand() == 0) { Assertions.assertEquals(180, service.getServiceDuration(), MatsimTestUtils.EPSILON); Assertions.assertEquals(TimeWindow.newInstance(3000, 13000), service.getServiceStartTimeWindow()); locationsPerServiceElement.computeIfAbsent("serviceElement1", (k) -> new HashSet<>()) .add(service.getLocationLinkId().toString()); } else { - Assertions.assertEquals(service.getCapacityDemand() * 100, service.getServiceDuration(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(service.getDemand() * 100, service.getServiceDuration(), MatsimTestUtils.EPSILON); Assertions.assertEquals(TimeWindow.newInstance(5000, 20000), service.getServiceStartTimeWindow()); locationsPerServiceElement.computeIfAbsent("serviceElement2", (k) -> new HashSet<>()) .add(service.getLocationLinkId().toString()); @@ -617,9 +621,9 @@ private static void checkCarrier1and2WithCombiningJobs(Scenario scenario, Networ Map> locationsPerShipmentElement = new HashMap<>(); countDemand = 0; for (CarrierShipment shipment : testCarrier2.getShipments().values()) { - countShipmentsWithCertainDemand.merge((Integer) shipment.getSize(), 1, Integer::sum); - countDemand = countDemand + shipment.getSize(); - if (shipment.getSize() == 0) { + countShipmentsWithCertainDemand.merge((Integer) shipment.getDemand(), 1, Integer::sum); + countDemand = countDemand + shipment.getDemand(); + if (shipment.getDemand() == 0) { Assertions.assertEquals(300, shipment.getPickupServiceTime(), MatsimTestUtils.EPSILON); Assertions.assertEquals(350, shipment.getDeliveryServiceTime(), MatsimTestUtils.EPSILON); Assertions.assertEquals(TimeWindow.newInstance(10000, 45000), shipment.getPickupTimeWindow()); @@ -629,8 +633,8 @@ private static void checkCarrier1and2WithCombiningJobs(Scenario scenario, Networ locationsPerShipmentElement.computeIfAbsent("ShipmentElement1_delivery", (k) -> new HashSet<>()) .add(shipment.getTo().toString()); } else { - Assertions.assertEquals(shipment.getSize() * 200, shipment.getPickupServiceTime(), MatsimTestUtils.EPSILON); - Assertions.assertEquals(shipment.getSize() * 200, shipment.getDeliveryServiceTime(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(shipment.getDemand() * 200, shipment.getPickupServiceTime(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(shipment.getDemand() * 200, shipment.getDeliveryServiceTime(), MatsimTestUtils.EPSILON); Assertions.assertEquals(TimeWindow.newInstance(11000, 44000), shipment.getPickupTimeWindow()); Assertions.assertEquals(TimeWindow.newInstance(20000, 40000), shipment.getDeliveryTimeWindow()); locationsPerShipmentElement.computeIfAbsent("ShipmentElement2_pickup", (k) -> new HashSet<>()) diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierPlanXmlWriterV2_1.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierPlanXmlWriterV2_1.java index 6195fb3834f..421ef4b2754 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierPlanXmlWriterV2_1.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierPlanXmlWriterV2_1.java @@ -157,11 +157,11 @@ private void writeShipments(Carrier carrier, BufferedWriter writer) { } private void writeShipment(CarrierShipment s, Id shipmentId, boolean closeElement, boolean lineBreak) { - this.writeStartTag(SHIPMENT, List.of( + this.writeStartTag(SHIPMENT, List.of( createTuple(ID, shipmentId.toString()), createTuple(FROM, s.getFrom().toString()), createTuple(TO, s.getTo().toString()), - createTuple(SIZE, s.getSize()), + createTuple(SIZE, s.getDemand()), createTuple(START_PICKUP, getTime(s.getPickupTimeWindow().getStart())), createTuple(END_PICKUP, getTime(s.getPickupTimeWindow().getEnd())), createTuple(START_DELIVERY, getTime(s.getDeliveryTimeWindow().getStart())), @@ -191,7 +191,7 @@ private void writeService(CarrierService s, boolean closeElement, boolean lineBr this.writeStartTag(SERVICE, List.of( createTuple(ID, s.getId().toString()), createTuple(TO, s.getLocationLinkId().toString()), - createTuple(CAPACITY_DEMAND, s.getCapacityDemand()), + createTuple(CAPACITY_DEMAND, s.getDemand()), createTuple(EARLIEST_START, getTime(s.getServiceStartTimeWindow().getStart())), createTuple(LATEST_END, getTime(s.getServiceStartTimeWindow().getEnd())), createTuple(SERVICE_DURATION, getTime(s.getServiceDuration()))), closeElement, lineBreak diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarriersUtils.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarriersUtils.java index 1b6a270e65e..ed8267d89b0 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarriersUtils.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarriersUtils.java @@ -431,7 +431,7 @@ private static void createShipmentsFromServices(Carrier carrierWS, Carrier carri CarrierShipment carrierShipment = CarrierShipment.Builder .newInstance(Id.create(carrierService.getId().toString(), CarrierShipment.class), depotServiceIsDeliveredFrom.get(carrierService.getId()), carrierService.getLocationLinkId(), - carrierService.getCapacityDemand()) + carrierService.getDemand()) .setDeliveryServiceTime(carrierService.getServiceDuration()) // .setPickupServiceTime(pickupServiceTime) //Not set yet, because in service we // have now time for that. Maybe change it later, kmt sep18 diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/analysis/CarrierPlanAnalysis.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/analysis/CarrierPlanAnalysis.java index 362dfaf8793..7c73cb9b551 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/analysis/CarrierPlanAnalysis.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/analysis/CarrierPlanAnalysis.java @@ -101,16 +101,16 @@ public void runAnalysisAndWriteStats(String analysisOutputDirectory) throws IOEx int numberOfHandledDemandSize; int notHandledJobs; if (numberOfPlanedShipments > 0) { - numberOfPlanedDemandSize = carrier.getShipments().values().stream().mapToInt(CarrierShipment::getSize).sum(); + numberOfPlanedDemandSize = carrier.getShipments().values().stream().mapToInt(carrierShipment -> carrierShipment.getDemand()).sum(); numberOfHandledDemandSize = carrier.getSelectedPlan().getScheduledTours().stream().mapToInt( t -> t.getTour().getTourElements().stream().filter(te -> te instanceof Tour.Pickup).mapToInt( - te -> (((Tour.Pickup) te).getShipment().getSize())).sum()).sum(); + te -> ((Tour.Pickup) te).getShipment().getDemand()).sum()).sum(); notHandledJobs = numberOfPlanedShipments - numberOfHandledPickups; } else { - numberOfPlanedDemandSize = carrier.getServices().values().stream().mapToInt(CarrierService::getCapacityDemand).sum(); + numberOfPlanedDemandSize = carrier.getServices().values().stream().mapToInt(carrierService -> carrierService.getDemand()).sum(); numberOfHandledDemandSize = carrier.getSelectedPlan().getScheduledTours().stream().mapToInt( t -> t.getTour().getTourElements().stream().filter(te -> te instanceof Tour.ServiceActivity).mapToInt( - te -> ((Tour.ServiceActivity) te).getService().getCapacityDemand()).sum()).sum(); + te -> ((Tour.ServiceActivity) te).getService().getDemand()).sum()).sum(); notHandledJobs = numberOfPlanedServices - nuOfServiceHandled; } diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierServiceStartEvent.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierServiceStartEvent.java index d1b4d816ace..2bf7829807e 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierServiceStartEvent.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierServiceStartEvent.java @@ -47,7 +47,7 @@ public CarrierServiceStartEvent(double time, Id carrierId, CarrierServi super(time, carrierId, service.getLocationLinkId(), vehicleId); this.serviceId = service.getId(); this.serviceDuration = service.getServiceDuration(); - this.capacityDemand = service.getCapacityDemand(); + this.capacityDemand = service.getDemand(); } @Override diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentDeliveryEndEvent.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentDeliveryEndEvent.java index 8f60260a067..35fe77cdea6 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentDeliveryEndEvent.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentDeliveryEndEvent.java @@ -47,7 +47,7 @@ public CarrierShipmentDeliveryEndEvent(double time, Id carrierId, Carri super(time, carrierId, shipment.getTo(), vehicleId); this.shipmentId = shipment.getId(); this.deliveryDuration = shipment.getDeliveryServiceTime(); - this.capacityDemand = shipment.getSize(); + this.capacityDemand = shipment.getDemand(); } @Override diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentDeliveryStartEvent.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentDeliveryStartEvent.java index a30035968c0..300590482df 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentDeliveryStartEvent.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentDeliveryStartEvent.java @@ -48,7 +48,7 @@ public CarrierShipmentDeliveryStartEvent(double time, Id carrierId, Car super(time, carrierId, shipment.getTo(), vehicleId); this.shipmentId = shipment.getId(); this.deliveryDuration = shipment.getDeliveryServiceTime(); - this.capacityDemand = shipment.getSize(); + this.capacityDemand = shipment.getDemand(); } @Override diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentPickupEndEvent.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentPickupEndEvent.java index 4316e6f4dfe..1a80be89293 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentPickupEndEvent.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentPickupEndEvent.java @@ -49,7 +49,7 @@ public CarrierShipmentPickupEndEvent(double time, Id carrierId, Carrier super(time, carrierId, shipment.getFrom(), vehicleId); this.shipmentId = shipment.getId(); this.pickupDuration = shipment.getPickupServiceTime(); - this.capacityDemand = shipment.getSize(); + this.capacityDemand = shipment.getDemand(); } diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentPickupStartEvent.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentPickupStartEvent.java index fe851a10138..bbc912645fb 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentPickupStartEvent.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentPickupStartEvent.java @@ -47,7 +47,7 @@ public CarrierShipmentPickupStartEvent(double time, Id carrierId, Carri super(time, carrierId, shipment.getFrom(), vehicleId); this.shipmentId = shipment.getId(); this.pickupDuration = shipment.getPickupServiceTime(); - this.capacityDemand = shipment.getSize(); + this.capacityDemand = shipment.getDemand(); } diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/jsprit/MatsimJspritFactory.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/jsprit/MatsimJspritFactory.java index 00cf9347716..5ec272cc6c2 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/jsprit/MatsimJspritFactory.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/jsprit/MatsimJspritFactory.java @@ -118,7 +118,7 @@ static Shipment createJspritShipment(CarrierShipment carrierShipment) { .setPickupTimeWindow(com.graphhopper.jsprit.core.problem.solution.route.activity.TimeWindow.newInstance( carrierShipment.getPickupTimeWindow().getStart(), carrierShipment.getPickupTimeWindow().getEnd())) - .addSizeDimension(0, carrierShipment.getSize()); + .addSizeDimension(0, carrierShipment.getDemand()); for (String skill : CarriersUtils.getSkills(carrierShipment)) { shipmentBuilder.addRequiredSkill(skill); } @@ -149,7 +149,7 @@ static Shipment createJspritShipment(CarrierShipment carrierShipment, Coord from .setPickupTimeWindow(com.graphhopper.jsprit.core.problem.solution.route.activity.TimeWindow.newInstance( carrierShipment.getPickupTimeWindow().getStart(), carrierShipment.getPickupTimeWindow().getEnd())) - .addSizeDimension(0, carrierShipment.getSize()); + .addSizeDimension(0, carrierShipment.getDemand()); for (String skill : CarriersUtils.getSkills(carrierShipment)) { shipmentBuilder.addRequiredSkill(skill); } @@ -165,7 +165,7 @@ static Service createJspritService(CarrierService carrierService, Coord location Location location = locationBuilder.build(); Builder serviceBuilder = Builder.newInstance(carrierService.getId().toString()); - serviceBuilder.addSizeDimension(0, carrierService.getCapacityDemand()); + serviceBuilder.addSizeDimension(0, carrierService.getDemand()); serviceBuilder.setLocation(location).setServiceTime(carrierService.getServiceDuration()) .setTimeWindow(com.graphhopper.jsprit.core.problem.solution.route.activity.TimeWindow.newInstance( carrierService.getServiceStartTimeWindow().getStart(), diff --git a/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/multipleChains/MultipleChainsUtils.java b/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/multipleChains/MultipleChainsUtils.java index 30517805da5..cc19c5c2064 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/multipleChains/MultipleChainsUtils.java +++ b/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/multipleChains/MultipleChainsUtils.java @@ -59,7 +59,7 @@ public static Collection createLSPShipmentsFromCarrierShipments(Car LspShipmentUtils.LspShipmentBuilder builder = LspShipmentUtils.LspShipmentBuilder.newInstance( Id.create(shipment.getId().toString(), LspShipment.class)); - builder.setCapacityDemand(shipment.getSize()); + builder.setCapacityDemand(shipment.getDemand()); builder.setFromLinkId(shipment.getFrom()); builder.setToLinkId(shipment.getTo()); builder.setStartTimeWindow(shipment.getPickupTimeWindow()); diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarriersUtilsTest.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarriersUtilsTest.java index fe0428621e0..6f4ac797052 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarriersUtilsTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarriersUtilsTest.java @@ -105,7 +105,7 @@ void testAddAndGetShipmentToCarrier() { Assertions.assertEquals(shipmentId, carrierShipment1b.getId()); Assertions.assertEquals(service1.getId(), carrierShipment1b.getId()); Assertions.assertEquals(Id.createLinkId("link0"), carrierShipment1b.getFrom()); - Assertions.assertEquals(20, carrierShipment1b.getSize(), EPSILON); + Assertions.assertEquals(20, carrierShipment1b.getDemand(), EPSILON); } @Test diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/MatsimTransformerTest.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/MatsimTransformerTest.java index 5025334cc5e..08929c96408 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/MatsimTransformerTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/MatsimTransformerTest.java @@ -148,7 +148,7 @@ void whenTransforming_jspritService2matsimService_isMadeCorrectly() { assertNotNull(service); assertEquals("locationId", service.getLocationLinkId().toString()); assertEquals(30.0, service.getServiceDuration(), 0.01); - assertEquals(50, service.getCapacityDemand()); + assertEquals(50, service.getDemand()); assertEquals(10.0, service.getServiceStartTimeWindow().getStart(), 0.01); CarrierService service2 = MatsimJspritFactory.createCarrierService(carrierService); @@ -201,7 +201,7 @@ void whenTransforming_jspritShipment2matsimShipment_isMadeCorrectly() { assertEquals(40.0, carrierShipment.getDeliveryServiceTime(), 0.01); assertEquals(50.0, carrierShipment.getDeliveryTimeWindow().getStart(), 0.01); assertEquals(60.0, carrierShipment.getDeliveryTimeWindow().getEnd(), 0.01); - assertEquals(50, carrierShipment.getSize()); + assertEquals(50, carrierShipment.getDemand()); CarrierShipment carrierShipment2 = MatsimJspritFactory.createCarrierShipment(shipment); assertNotSame(carrierShipment, carrierShipment2); diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/utils/CarrierControllerUtilsTest.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/utils/CarrierControllerUtilsTest.java index 1896021e805..f6bb1b42ee0 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/utils/CarrierControllerUtilsTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/utils/CarrierControllerUtilsTest.java @@ -165,7 +165,7 @@ void numberOfInitialServicesIsCorrect() { int demandServices = 0; for (CarrierService carrierService : carrierWServices.getServices().values()) { - demandServices += carrierService.getCapacityDemand(); + demandServices += carrierService.getDemand(); } Assertions.assertEquals(4, demandServices); @@ -180,7 +180,7 @@ void numberOfInitialShipmentsIsCorrect() { Assertions.assertEquals(2, carrierWShipments.getShipments().size()); int demandShipments = 0; for (CarrierShipment carrierShipment : carrierWShipments.getShipments().values()) { - demandShipments += carrierShipment.getSize(); + demandShipments += carrierShipment.getDemand(); } Assertions.assertEquals(3, demandShipments); } @@ -192,7 +192,7 @@ void numberOfShipmentsFromCopiedShipmentsIsCorrect() { Assertions.assertEquals(2, carrierWShipmentsOnlyFromCarrierWShipments.getShipments().size()); int demandShipments = 0; for (CarrierShipment carrierShipment : carrierWShipmentsOnlyFromCarrierWServices.getShipments().values()) { - demandShipments += carrierShipment.getSize(); + demandShipments += carrierShipment.getDemand(); } Assertions.assertEquals(4, demandShipments); } @@ -204,7 +204,7 @@ void numberOfShipmentsFromConvertedServicesIsCorrect() { Assertions.assertEquals(2, carrierWShipmentsOnlyFromCarrierWServices.getShipments().size()); int demandShipments = 0; for (CarrierShipment carrierShipment : carrierWShipmentsOnlyFromCarrierWServices.getShipments().values()) { - demandShipments += carrierShipment.getSize(); + demandShipments += carrierShipment.getDemand(); } Assertions.assertEquals(4, demandShipments); } @@ -246,7 +246,7 @@ void copyingOfShipmentsIsDoneCorrectly() { foundShipment1 = true; Assertions.assertEquals(Id.createLinkId("i(1,0)"), carrierShipment1.getFrom()); Assertions.assertEquals(Id.createLinkId("i(7,6)R"), carrierShipment1.getTo()); - Assertions.assertEquals(1, carrierShipment1.getSize()); + Assertions.assertEquals(1, carrierShipment1.getDemand()); Assertions.assertEquals(30.0, carrierShipment1.getDeliveryServiceTime(), 0); Assertions.assertEquals(3600.0, carrierShipment1.getDeliveryTimeWindow().getStart(), 0); Assertions.assertEquals(36000.0, carrierShipment1.getDeliveryTimeWindow().getEnd(), 0); @@ -261,7 +261,7 @@ void copyingOfShipmentsIsDoneCorrectly() { foundShipment2 = true; Assertions.assertEquals(Id.createLinkId("i(3,0)"), carrierShipment2.getFrom()); Assertions.assertEquals(Id.createLinkId("i(3,7)"), carrierShipment2.getTo()); - Assertions.assertEquals(2, carrierShipment2.getSize()); + Assertions.assertEquals(2, carrierShipment2.getDemand()); Assertions.assertEquals(30.0, carrierShipment2.getDeliveryServiceTime(), 0); Assertions.assertEquals(3600.0, carrierShipment2.getDeliveryTimeWindow().getStart(), 0); Assertions.assertEquals(36000.0, carrierShipment2.getDeliveryTimeWindow().getEnd(), 0); @@ -284,7 +284,7 @@ void convertionOfServicesIsDoneCorrectly() { foundService1 = true; Assertions.assertEquals(Id.createLinkId("i(6,0)"), carrierShipment1.getFrom()); Assertions.assertEquals(Id.createLinkId("i(3,9)"), carrierShipment1.getTo()); - Assertions.assertEquals(2, carrierShipment1.getSize()); + Assertions.assertEquals(2, carrierShipment1.getDemand()); Assertions.assertEquals(31.0, carrierShipment1.getDeliveryServiceTime(), 0); Assertions.assertEquals(3601.0, carrierShipment1.getDeliveryTimeWindow().getStart(), 0); Assertions.assertEquals(36001.0, carrierShipment1.getDeliveryTimeWindow().getEnd(), 0); @@ -298,7 +298,7 @@ void convertionOfServicesIsDoneCorrectly() { foundService2 = true; Assertions.assertEquals(Id.createLinkId("i(6,0)"), carrierShipment2.getFrom()); Assertions.assertEquals(Id.createLinkId("i(4,9)"), carrierShipment2.getTo()); - Assertions.assertEquals(2, carrierShipment2.getSize()); + Assertions.assertEquals(2, carrierShipment2.getDemand()); Assertions.assertEquals(31.0, carrierShipment2.getDeliveryServiceTime(), 0); Assertions.assertEquals(3601.0, carrierShipment2.getDeliveryTimeWindow().getStart(), 0); Assertions.assertEquals(36001.0, carrierShipment2.getDeliveryTimeWindow().getEnd(), 0); diff --git a/contribs/freight/src/test/java/org/matsim/freight/logistics/examples/simulationTrackers/CollectionTrackerTest.java b/contribs/freight/src/test/java/org/matsim/freight/logistics/examples/simulationTrackers/CollectionTrackerTest.java index e72394b24ea..b1d60e9665a 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/logistics/examples/simulationTrackers/CollectionTrackerTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/logistics/examples/simulationTrackers/CollectionTrackerTest.java @@ -56,7 +56,6 @@ import org.matsim.freight.logistics.shipment.LspShipment; import org.matsim.freight.logistics.shipment.LspShipmentUtils; import org.matsim.testcases.MatsimTestUtils; -import org.matsim.vehicles.Vehicle; import org.matsim.vehicles.VehicleType; import org.matsim.vehicles.VehicleUtils; @@ -238,7 +237,7 @@ public void testCollectionTracker() { if (element instanceof ServiceActivity activity) { scheduledCosts += activity.getService().getServiceDuration() * scheduledTour.getVehicle().getType().getCostInformation().getCostsPerSecond(); totalScheduledCosts += scheduledCosts; - totalScheduledWeight += activity.getService().getCapacityDemand(); + totalScheduledWeight += activity.getService().getDemand(); totalNumberOfScheduledShipments++; } } diff --git a/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/CollectionLSPSchedulingTest.java b/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/CollectionLSPSchedulingTest.java index 5e071b894d4..d031c5f6d1d 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/CollectionLSPSchedulingTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/CollectionLSPSchedulingTest.java @@ -197,7 +197,7 @@ public void testCollectionLSPScheduling() { assertInstanceOf(LSPTourEndEventHandler.class, eventHandlers.getFirst()); LSPTourEndEventHandler endHandler = (LSPTourEndEventHandler) eventHandlers.getFirst(); assertSame(endHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); - assertEquals(endHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); + assertEquals(endHandler.getCarrierService().getDemand(), shipment.getSize()); assertEquals(endHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(endHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); assertEquals(endHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); @@ -212,7 +212,7 @@ public void testCollectionLSPScheduling() { assertInstanceOf(CollectionServiceEndEventHandler.class, eventHandlers.get(1)); CollectionServiceEndEventHandler serviceHandler = (CollectionServiceEndEventHandler) eventHandlers.get(1); assertSame(serviceHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); - assertEquals(serviceHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); + assertEquals(serviceHandler.getCarrierService().getDemand(), shipment.getSize()); assertEquals(serviceHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(serviceHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); assertEquals(serviceHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); diff --git a/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/CompleteLSPSchedulingTest.java b/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/CompleteLSPSchedulingTest.java index c4fd34c0fd3..3a6a13e629a 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/CompleteLSPSchedulingTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/CompleteLSPSchedulingTest.java @@ -434,7 +434,7 @@ public void testCompletedLSPScheduling() { LspShipment shipment = entry.getValue().lspShipment; LogisticChainElement element = entry.getValue().logisticChainElement; assertSame(service.getLocationLinkId(), shipment.getFrom()); - assertEquals(service.getCapacityDemand(), shipment.getSize()); + assertEquals(service.getDemand(), shipment.getSize()); assertEquals(service.getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); boolean handledByTranshipmentHub = false; for (LogisticChainElement clientElement : reloadEventHandler.getTranshipmentHub().getClientElements()) { @@ -461,7 +461,7 @@ public void testCompletedLSPScheduling() { LspShipment shipment = entry.getValue().lspShipment; LogisticChainElement element = entry.getValue().logisticChainElement; assertSame(service.getLocationLinkId(), toLinkId); - assertEquals(service.getCapacityDemand(), shipment.getSize()); + assertEquals(service.getDemand(), shipment.getSize()); assertEquals(service.getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); boolean handledByTranshipmentHub = false; for (LogisticChainElement clientElement : reloadEventHandler.getTranshipmentHub().getClientElements()) { @@ -485,7 +485,7 @@ public void testCompletedLSPScheduling() { assertInstanceOf(LSPTourEndEventHandler.class, eventHandlers.getFirst()); LSPTourEndEventHandler endHandler = (LSPTourEndEventHandler) eventHandlers.getFirst(); assertSame(endHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); - assertEquals(endHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); + assertEquals(endHandler.getCarrierService().getDemand(), shipment.getSize()); assertEquals(endHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(endHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); assertEquals(endHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); @@ -503,7 +503,7 @@ public void testCompletedLSPScheduling() { assertInstanceOf(CollectionServiceEndEventHandler.class, eventHandlers.get(1)); CollectionServiceEndEventHandler serviceHandler = (CollectionServiceEndEventHandler) eventHandlers.get(1); assertSame(serviceHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); - assertEquals(serviceHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); + assertEquals(serviceHandler.getCarrierService().getDemand(), shipment.getSize()); assertEquals(serviceHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(serviceHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); assertEquals(serviceHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); @@ -522,7 +522,7 @@ public void testCompletedLSPScheduling() { LSPTourStartEventHandler mainRunStartHandler = (LSPTourStartEventHandler) eventHandlers.get(2); assertSame(mainRunStartHandler.getCarrierService().getLocationLinkId(), toLinkId); assertEquals(mainRunStartHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); - assertEquals(mainRunStartHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); + assertEquals(mainRunStartHandler.getCarrierService().getDemand(), shipment.getSize()); assertEquals(0, mainRunStartHandler.getCarrierService().getServiceStartTimeWindow().getStart(), 0.0); assertEquals(Integer.MAX_VALUE, mainRunStartHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), 0.0); assertSame(mainRunStartHandler.getLogisticChainElement(), planElements.get(4).getLogisticChainElement()); @@ -540,7 +540,7 @@ public void testCompletedLSPScheduling() { LSPTourEndEventHandler mainRunEndHandler = (LSPTourEndEventHandler) eventHandlers.get(3); assertSame(mainRunEndHandler.getCarrierService().getLocationLinkId(), toLinkId); assertEquals(mainRunEndHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); - assertEquals(mainRunEndHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); + assertEquals(mainRunEndHandler.getCarrierService().getDemand(), shipment.getSize()); assertEquals(0, mainRunEndHandler.getCarrierService().getServiceStartTimeWindow().getStart(), 0.0); assertEquals(Integer.MAX_VALUE, mainRunEndHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), 0.0); assertSame(mainRunEndHandler.getLogisticChainElement(), planElements.get(4).getLogisticChainElement()); @@ -558,7 +558,7 @@ public void testCompletedLSPScheduling() { LSPTourStartEventHandler lspTourStartEventHandler = (LSPTourStartEventHandler) eventHandlers.get(4); assertSame(lspTourStartEventHandler.getCarrierService().getLocationLinkId(), shipment.getTo()); assertEquals(lspTourStartEventHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); - assertEquals(lspTourStartEventHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); + assertEquals(lspTourStartEventHandler.getCarrierService().getDemand(), shipment.getSize()); assertEquals(0, lspTourStartEventHandler.getCarrierService().getServiceStartTimeWindow().getStart(), 0.0); assertEquals(Integer.MAX_VALUE, lspTourStartEventHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), 0.0); assertSame(lspTourStartEventHandler.getLogisticChainElement(), planElements.get(8).getLogisticChainElement()); @@ -576,7 +576,7 @@ public void testCompletedLSPScheduling() { DistributionServiceStartEventHandler distributionServiceHandler = (DistributionServiceStartEventHandler) eventHandlers.get(5); assertSame(distributionServiceHandler.getCarrierService().getLocationLinkId(), shipment.getTo()); assertEquals(distributionServiceHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); - assertEquals(distributionServiceHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); + assertEquals(distributionServiceHandler.getCarrierService().getDemand(), shipment.getSize()); assertEquals(0, distributionServiceHandler.getCarrierService().getServiceStartTimeWindow().getStart(), 0.0); assertEquals(Integer.MAX_VALUE, distributionServiceHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), 0.0); assertSame(distributionServiceHandler.getLogisticChainElement(), planElements.get(8).getLogisticChainElement()); diff --git a/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/FirstReloadLSPSchedulingTest.java b/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/FirstReloadLSPSchedulingTest.java index 3cead4c873c..5b724cf6a80 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/FirstReloadLSPSchedulingTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/FirstReloadLSPSchedulingTest.java @@ -260,7 +260,7 @@ public void testFirstReloadLSPScheduling() { LspShipment shipment = entry.getValue().lspShipment; LogisticChainElement element = entry.getValue().logisticChainElement; assertSame(service.getLocationLinkId(), shipment.getFrom()); - assertEquals(service.getCapacityDemand(), shipment.getSize()); + assertEquals(service.getDemand(), shipment.getSize()); assertEquals(service.getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); boolean handledByTranshipmentHub = false; for (LogisticChainElement clientElement : reloadEventHandler.getTranshipmentHub().getClientElements()) { @@ -284,7 +284,7 @@ public void testFirstReloadLSPScheduling() { assertInstanceOf(LSPTourEndEventHandler.class, eventHandlers.getFirst()); LSPTourEndEventHandler endHandler = (LSPTourEndEventHandler) eventHandlers.getFirst(); assertSame(endHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); - assertEquals(endHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); + assertEquals(endHandler.getCarrierService().getDemand(), shipment.getSize()); assertEquals(endHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(endHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); assertEquals(endHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); @@ -297,7 +297,7 @@ public void testFirstReloadLSPScheduling() { assertInstanceOf(CollectionServiceEndEventHandler.class, eventHandlers.get(1)); CollectionServiceEndEventHandler serviceHandler = (CollectionServiceEndEventHandler) eventHandlers.get(1); assertSame(serviceHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); - assertEquals(serviceHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); + assertEquals(serviceHandler.getCarrierService().getDemand(), shipment.getSize()); assertEquals(serviceHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(serviceHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); assertEquals(serviceHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); diff --git a/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MainRunLSPSchedulingTest.java b/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MainRunLSPSchedulingTest.java index 4a39f6c6170..8d653d8e171 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MainRunLSPSchedulingTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MainRunLSPSchedulingTest.java @@ -325,7 +325,7 @@ public void testMainRunLSPScheduling() { LspShipment shipment = entry.getValue().lspShipment; LogisticChainElement element = entry.getValue().logisticChainElement; assertSame(service.getLocationLinkId(), shipment.getFrom()); - assertEquals(service.getCapacityDemand(), shipment.getSize()); + assertEquals(service.getDemand(), shipment.getSize()); assertEquals(service.getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); boolean handledByTranshipmentHub = false; for (LogisticChainElement clientElement : reloadEventHandler.getTranshipmentHub().getClientElements()) { @@ -351,7 +351,7 @@ public void testMainRunLSPScheduling() { assertInstanceOf(LSPTourEndEventHandler.class, eventHandlers.getFirst()); LSPTourEndEventHandler endHandler = (LSPTourEndEventHandler) eventHandlers.getFirst(); assertSame(endHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); - assertEquals(endHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); + assertEquals(endHandler.getCarrierService().getDemand(), shipment.getSize()); assertEquals(endHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(endHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); assertEquals(endHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); @@ -369,7 +369,7 @@ public void testMainRunLSPScheduling() { assertInstanceOf(CollectionServiceEndEventHandler.class, eventHandlers.get(1)); CollectionServiceEndEventHandler serviceHandler = (CollectionServiceEndEventHandler) eventHandlers.get(1); assertSame(serviceHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); - assertEquals(serviceHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); + assertEquals(serviceHandler.getCarrierService().getDemand(), shipment.getSize()); assertEquals(serviceHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(serviceHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); assertEquals(serviceHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); @@ -388,7 +388,7 @@ public void testMainRunLSPScheduling() { LSPTourStartEventHandler mainRunStartHandler = (LSPTourStartEventHandler) eventHandlers.get(2); assertSame(mainRunStartHandler.getCarrierService().getLocationLinkId(), toLinkId); assertEquals(mainRunStartHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); - assertEquals(mainRunStartHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); + assertEquals(mainRunStartHandler.getCarrierService().getDemand(), shipment.getSize()); assertEquals(0, mainRunStartHandler.getCarrierService().getServiceStartTimeWindow().getStart(), 0.0); assertEquals(Integer.MAX_VALUE, mainRunStartHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), 0.0); assertSame(mainRunStartHandler.getLogisticChainElement(), planElements.get(4).getLogisticChainElement()); @@ -406,7 +406,7 @@ public void testMainRunLSPScheduling() { LSPTourEndEventHandler mainRunEndHandler = (LSPTourEndEventHandler) eventHandlers.get(3); assertSame(mainRunEndHandler.getCarrierService().getLocationLinkId(), toLinkId); assertEquals(mainRunEndHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); - assertEquals(mainRunEndHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); + assertEquals(mainRunEndHandler.getCarrierService().getDemand(), shipment.getSize()); assertEquals(0, mainRunEndHandler.getCarrierService().getServiceStartTimeWindow().getStart(), 0.0); assertEquals(Integer.MAX_VALUE, mainRunEndHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), 0.0); assertSame(mainRunEndHandler.getLogisticChainElement(), planElements.get(4).getLogisticChainElement()); diff --git a/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsCollectionLSPSchedulingTest.java b/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsCollectionLSPSchedulingTest.java index d30d608f985..dd51e2d4e4a 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsCollectionLSPSchedulingTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsCollectionLSPSchedulingTest.java @@ -199,7 +199,7 @@ public void testCollectionLSPScheduling() { assertInstanceOf(LSPTourEndEventHandler.class, eventHandlers.getFirst()); LSPTourEndEventHandler endHandler = (LSPTourEndEventHandler) eventHandlers.getFirst(); assertSame(endHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); - assertEquals(endHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); + assertEquals(endHandler.getCarrierService().getDemand(), shipment.getSize()); assertEquals(endHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(endHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); assertEquals(endHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); @@ -212,7 +212,7 @@ public void testCollectionLSPScheduling() { assertInstanceOf(CollectionServiceEndEventHandler.class, eventHandlers.get(1)); CollectionServiceEndEventHandler serviceHandler = (CollectionServiceEndEventHandler) eventHandlers.get(1); assertSame(serviceHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); - assertEquals(serviceHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); + assertEquals(serviceHandler.getCarrierService().getDemand(), shipment.getSize()); assertEquals(serviceHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(serviceHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); assertEquals(serviceHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); diff --git a/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsCompleteLSPSchedulingTest.java b/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsCompleteLSPSchedulingTest.java index f27a1e08219..481c48ec6ba 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsCompleteLSPSchedulingTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsCompleteLSPSchedulingTest.java @@ -437,7 +437,7 @@ public void testCompletedLSPScheduling() { LspShipment shipment = entry.getValue().lspShipment; LogisticChainElement element = entry.getValue().logisticChainElement; assertSame(service.getLocationLinkId(), shipment.getFrom()); - assertEquals(service.getCapacityDemand(), shipment.getSize()); + assertEquals(service.getDemand(), shipment.getSize()); assertEquals(service.getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); boolean handledByTranshipmentHub = false; for (LogisticChainElement clientElement : reloadEventHandler.getTranshipmentHub().getClientElements()) { @@ -464,7 +464,7 @@ public void testCompletedLSPScheduling() { LspShipment shipment = entry.getValue().lspShipment; LogisticChainElement element = entry.getValue().logisticChainElement; assertSame(service.getLocationLinkId(), toLinkId); - assertEquals(service.getCapacityDemand(), shipment.getSize()); + assertEquals(service.getDemand(), shipment.getSize()); assertEquals(service.getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); boolean handledByTranshipmentHub = false; for (LogisticChainElement clientElement : reloadEventHandler.getTranshipmentHub().getClientElements()) { @@ -488,7 +488,7 @@ public void testCompletedLSPScheduling() { assertInstanceOf(LSPTourEndEventHandler.class, eventHandlers.getFirst()); LSPTourEndEventHandler endHandler = (LSPTourEndEventHandler) eventHandlers.getFirst(); assertSame(endHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); - assertEquals(endHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); + assertEquals(endHandler.getCarrierService().getDemand(), shipment.getSize()); assertEquals(endHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(endHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); assertEquals(endHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); @@ -506,7 +506,7 @@ public void testCompletedLSPScheduling() { assertInstanceOf(CollectionServiceEndEventHandler.class, eventHandlers.get(1)); CollectionServiceEndEventHandler serviceHandler = (CollectionServiceEndEventHandler) eventHandlers.get(1); assertSame(serviceHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); - assertEquals(serviceHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); + assertEquals(serviceHandler.getCarrierService().getDemand(), shipment.getSize()); assertEquals(serviceHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(serviceHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); assertEquals(serviceHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); @@ -525,7 +525,7 @@ public void testCompletedLSPScheduling() { LSPTourStartEventHandler mainRunStartHandler = (LSPTourStartEventHandler) eventHandlers.get(2); assertSame(mainRunStartHandler.getCarrierService().getLocationLinkId(), toLinkId); assertEquals(mainRunStartHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); - assertEquals(mainRunStartHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); + assertEquals(mainRunStartHandler.getCarrierService().getDemand(), shipment.getSize()); assertEquals(0, mainRunStartHandler.getCarrierService().getServiceStartTimeWindow().getStart(), 0.0); assertEquals(Integer.MAX_VALUE, mainRunStartHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), 0.0); assertSame(mainRunStartHandler.getLogisticChainElement(), planElements.get(4).getLogisticChainElement()); @@ -543,7 +543,7 @@ public void testCompletedLSPScheduling() { LSPTourEndEventHandler mainRunEndHandler = (LSPTourEndEventHandler) eventHandlers.get(3); assertSame(mainRunEndHandler.getCarrierService().getLocationLinkId(), toLinkId); assertEquals(mainRunEndHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); - assertEquals(mainRunEndHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); + assertEquals(mainRunEndHandler.getCarrierService().getDemand(), shipment.getSize()); assertEquals(0, mainRunEndHandler.getCarrierService().getServiceStartTimeWindow().getStart(), 0.0); assertEquals(Integer.MAX_VALUE, mainRunEndHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), 0.0); assertSame(mainRunEndHandler.getLogisticChainElement(), planElements.get(4).getLogisticChainElement()); @@ -561,7 +561,7 @@ public void testCompletedLSPScheduling() { LSPTourStartEventHandler lspTourStartEventHandler = (LSPTourStartEventHandler) eventHandlers.get(4); assertSame(lspTourStartEventHandler.getCarrierService().getLocationLinkId(), shipment.getTo()); assertEquals(lspTourStartEventHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); - assertEquals(lspTourStartEventHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); + assertEquals(lspTourStartEventHandler.getCarrierService().getDemand(), shipment.getSize()); assertEquals(0, lspTourStartEventHandler.getCarrierService().getServiceStartTimeWindow().getStart(), 0.0); assertEquals(Integer.MAX_VALUE, lspTourStartEventHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), 0.0); assertSame(lspTourStartEventHandler.getLogisticChainElement(), planElements.get(8).getLogisticChainElement()); @@ -579,7 +579,7 @@ public void testCompletedLSPScheduling() { DistributionServiceStartEventHandler distributionServiceHandler = (DistributionServiceStartEventHandler) eventHandlers.get(5); assertSame(distributionServiceHandler.getCarrierService().getLocationLinkId(), shipment.getTo()); assertEquals(distributionServiceHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); - assertEquals(distributionServiceHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); + assertEquals(distributionServiceHandler.getCarrierService().getDemand(), shipment.getSize()); assertEquals(0, distributionServiceHandler.getCarrierService().getServiceStartTimeWindow().getStart(), 0.0); assertEquals(Integer.MAX_VALUE, distributionServiceHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), 0.0); assertSame(distributionServiceHandler.getLogisticChainElement(), planElements.get(8).getLogisticChainElement()); diff --git a/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsFirstReloadLSPSchedulingTest.java b/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsFirstReloadLSPSchedulingTest.java index e1661887039..eb6af700893 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsFirstReloadLSPSchedulingTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsFirstReloadLSPSchedulingTest.java @@ -259,7 +259,7 @@ public void testFirstReloadLSPScheduling() { LspShipment shipment = entry.getValue().lspShipment; LogisticChainElement element = entry.getValue().logisticChainElement; assertSame(service.getLocationLinkId(), shipment.getFrom()); - assertEquals(service.getCapacityDemand(), shipment.getSize()); + assertEquals(service.getDemand(), shipment.getSize()); assertEquals(service.getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); boolean handledByTranshipmentHub = false; for (LogisticChainElement clientElement : reloadEventHandler.getTranshipmentHub().getClientElements()) { @@ -283,7 +283,7 @@ public void testFirstReloadLSPScheduling() { assertInstanceOf(LSPTourEndEventHandler.class, eventHandlers.getFirst()); LSPTourEndEventHandler endHandler = (LSPTourEndEventHandler) eventHandlers.getFirst(); assertSame(endHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); - assertEquals(endHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); + assertEquals(endHandler.getCarrierService().getDemand(), shipment.getSize()); assertEquals(endHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(endHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); assertEquals(endHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); @@ -296,7 +296,7 @@ public void testFirstReloadLSPScheduling() { assertInstanceOf(CollectionServiceEndEventHandler.class, eventHandlers.get(1)); CollectionServiceEndEventHandler serviceHandler = (CollectionServiceEndEventHandler) eventHandlers.get(1); assertSame(serviceHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); - assertEquals(serviceHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); + assertEquals(serviceHandler.getCarrierService().getDemand(), shipment.getSize()); assertEquals(serviceHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(serviceHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); assertEquals(serviceHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); diff --git a/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsMainRunLSPSchedulingTest.java b/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsMainRunLSPSchedulingTest.java index c9811f9e03d..f82bde886c8 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsMainRunLSPSchedulingTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsMainRunLSPSchedulingTest.java @@ -222,16 +222,16 @@ public void initialize() { @Test public void testMainRunLSPScheduling() { - + /*for(LSPShipment shipment : lsp.getShipments()) { ArrayList scheduleElements = new ArrayList(shipment.getSchedule().getPlanElements().values()); Collections.sort(scheduleElements, new AbstractShipmentPlanElementComparator()); - + System.out.println(); for(int i = 0; i < shipment.getSchedule().getPlanElements().size(); i++) { System.out.println("Scheduled: " + scheduleElements.get(i).getSolutionElement().getId() + " " + scheduleElements.get(i).getResourceId() +" "+ scheduleElements.get(i).getElementType() + " Start: " + scheduleElements.get(i).getStartTime() + " End: " + scheduleElements.get(i).getEndTime()); } - System.out.println(); + System.out.println(); }*/ @@ -325,7 +325,7 @@ public void testMainRunLSPScheduling() { LspShipment shipment = entry.getValue().lspShipment; LogisticChainElement element = entry.getValue().logisticChainElement; assertSame(service.getLocationLinkId(), shipment.getFrom()); - assertEquals(service.getCapacityDemand(), shipment.getSize()); + assertEquals(service.getDemand(), shipment.getSize()); assertEquals(service.getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); boolean handledByTranshipmentHub = false; for (LogisticChainElement clientElement : reloadEventHandler.getTranshipmentHub().getClientElements()) { @@ -351,7 +351,7 @@ public void testMainRunLSPScheduling() { assertInstanceOf(LSPTourEndEventHandler.class, eventHandlers.getFirst()); LSPTourEndEventHandler endHandler = (LSPTourEndEventHandler) eventHandlers.getFirst(); assertSame(endHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); - assertEquals(endHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); + assertEquals(endHandler.getCarrierService().getDemand(), shipment.getSize()); assertEquals(endHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(endHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); assertEquals(endHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); @@ -369,7 +369,7 @@ public void testMainRunLSPScheduling() { assertInstanceOf(CollectionServiceEndEventHandler.class, eventHandlers.get(1)); CollectionServiceEndEventHandler serviceHandler = (CollectionServiceEndEventHandler) eventHandlers.get(1); assertSame(serviceHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); - assertEquals(serviceHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); + assertEquals(serviceHandler.getCarrierService().getDemand(), shipment.getSize()); assertEquals(serviceHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(serviceHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); assertEquals(serviceHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); @@ -388,7 +388,7 @@ public void testMainRunLSPScheduling() { LSPTourStartEventHandler mainRunStartHandler = (LSPTourStartEventHandler) eventHandlers.get(2); assertSame(mainRunStartHandler.getCarrierService().getLocationLinkId(), toLinkId); assertEquals(mainRunStartHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); - assertEquals(mainRunStartHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); + assertEquals(mainRunStartHandler.getCarrierService().getDemand(), shipment.getSize()); assertEquals(0, mainRunStartHandler.getCarrierService().getServiceStartTimeWindow().getStart(), 0.0); assertEquals(Integer.MAX_VALUE, mainRunStartHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), 0.0); assertSame(mainRunStartHandler.getLogisticChainElement(), planElements.get(4).getLogisticChainElement()); @@ -406,7 +406,7 @@ public void testMainRunLSPScheduling() { LSPTourEndEventHandler mainRunEndHandler = (LSPTourEndEventHandler) eventHandlers.get(3); assertSame(mainRunEndHandler.getCarrierService().getLocationLinkId(), toLinkId); assertEquals(mainRunEndHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); - assertEquals(mainRunEndHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); + assertEquals(mainRunEndHandler.getCarrierService().getDemand(), shipment.getSize()); assertEquals(0, mainRunEndHandler.getCarrierService().getServiceStartTimeWindow().getStart(), 0.0); assertEquals(Integer.MAX_VALUE, mainRunEndHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), 0.0); assertSame(mainRunEndHandler.getLogisticChainElement(), planElements.get(4).getLogisticChainElement()); diff --git a/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsSecondReloadLSPSchedulingTest.java b/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsSecondReloadLSPSchedulingTest.java index 23ee9f61e86..403bf619d90 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsSecondReloadLSPSchedulingTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsSecondReloadLSPSchedulingTest.java @@ -251,14 +251,14 @@ public void initialize() { @Test public void testSecondReloadLSPScheduling() { - + /*for(LSPShipment shipment : lsp.getShipments()) { ArrayList elementList = new ArrayList(shipment.getSchedule().getPlanElements().values()); Collections.sort(elementList, new AbstractShipmentPlanElementComparator()); System.out.println(); for(AbstractShipmentPlanElement element : elementList) { - System.out.println(element.getSolutionElement().getId() + " " + element.getResourceId() + " " + element.getElementType() + " " + element.getStartTime() + " " + element.getEndTime()); - } + System.out.println(element.getSolutionElement().getId() + " " + element.getResourceId() + " " + element.getElementType() + " " + element.getStartTime() + " " + element.getEndTime()); + } System.out.println(); }*/ @@ -369,7 +369,7 @@ public void testSecondReloadLSPScheduling() { LspShipment shipment = entry.getValue().lspShipment; LogisticChainElement element = entry.getValue().logisticChainElement; assertSame(service.getLocationLinkId(), shipment.getFrom()); - assertEquals(service.getCapacityDemand(), shipment.getSize()); + assertEquals(service.getDemand(), shipment.getSize()); assertEquals(service.getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); boolean handledByTranshipmentHub = false; for (LogisticChainElement clientElement : @@ -401,7 +401,7 @@ public void testSecondReloadLSPScheduling() { LspShipment shipment = entry.getValue().lspShipment; LogisticChainElement element = entry.getValue().logisticChainElement; assertSame(service.getLocationLinkId(), toLinkId); - assertEquals(service.getCapacityDemand(), shipment.getSize()); + assertEquals(service.getDemand(), shipment.getSize()); assertEquals(service.getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); boolean handledByTranshipmentHub = false; for (LogisticChainElement clientElement : reloadEventHandler.getTranshipmentHub().getClientElements()) { @@ -431,7 +431,7 @@ public void testSecondReloadLSPScheduling() { assertInstanceOf(LSPTourEndEventHandler.class, eventHandlers.getFirst()); LSPTourEndEventHandler collectionEndHandler = (LSPTourEndEventHandler) eventHandlers.getFirst(); assertSame(collectionEndHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); - assertEquals(collectionEndHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); + assertEquals(collectionEndHandler.getCarrierService().getDemand(), shipment.getSize()); assertEquals(collectionEndHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(collectionEndHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); assertEquals(collectionEndHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); @@ -450,7 +450,7 @@ public void testSecondReloadLSPScheduling() { assertInstanceOf(CollectionServiceEndEventHandler.class, eventHandlers.get(1)); CollectionServiceEndEventHandler collectionServiceHandler = (CollectionServiceEndEventHandler) eventHandlers.get(1); assertSame(collectionServiceHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); - assertEquals(collectionServiceHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); + assertEquals(collectionServiceHandler.getCarrierService().getDemand(), shipment.getSize()); assertEquals(collectionServiceHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(collectionServiceHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); assertEquals(collectionServiceHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); @@ -470,7 +470,7 @@ public void testSecondReloadLSPScheduling() { LSPTourStartEventHandler mainRunStartHandler = (LSPTourStartEventHandler) eventHandlers.get(2); assertSame(mainRunStartHandler.getCarrierService().getLocationLinkId(), toLinkId); assertEquals(mainRunStartHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); - assertEquals(mainRunStartHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); + assertEquals(mainRunStartHandler.getCarrierService().getDemand(), shipment.getSize()); assertEquals(0, mainRunStartHandler.getCarrierService().getServiceStartTimeWindow().getStart(), 0.0); assertEquals(Integer.MAX_VALUE, mainRunStartHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), 0.0); assertSame(mainRunStartHandler.getLogisticChainElement(), planElements.get(4).getLogisticChainElement()); @@ -489,7 +489,7 @@ public void testSecondReloadLSPScheduling() { LSPTourEndEventHandler mainRunEndHandler = (LSPTourEndEventHandler) eventHandlers.get(3); assertSame(mainRunEndHandler.getCarrierService().getLocationLinkId(), toLinkId); assertEquals(mainRunEndHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); - assertEquals(mainRunEndHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); + assertEquals(mainRunEndHandler.getCarrierService().getDemand(), shipment.getSize()); assertEquals(0, mainRunEndHandler.getCarrierService().getServiceStartTimeWindow().getStart(), 0.0); assertEquals(Integer.MAX_VALUE, mainRunEndHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), 0.0); assertSame(mainRunEndHandler.getLogisticChainElement(), planElements.get(4).getLogisticChainElement()); diff --git a/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/SecondReloadLSPSchedulingTest.java b/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/SecondReloadLSPSchedulingTest.java index 6a37cd65697..08dbac36e8b 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/SecondReloadLSPSchedulingTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/SecondReloadLSPSchedulingTest.java @@ -369,7 +369,7 @@ public void testSecondReloadLSPScheduling() { LspShipment shipment = entry.getValue().lspShipment; LogisticChainElement element = entry.getValue().logisticChainElement; assertSame(service.getLocationLinkId(), shipment.getFrom()); - assertEquals(service.getCapacityDemand(), shipment.getSize()); + assertEquals(service.getDemand(), shipment.getSize()); assertEquals(service.getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); boolean handledByTranshipmentHub = false; for (LogisticChainElement clientElement : @@ -407,7 +407,7 @@ public void testSecondReloadLSPScheduling() { LspShipment shipment = entry.getValue().lspShipment; LogisticChainElement element = entry.getValue().logisticChainElement; assertSame(service.getLocationLinkId(), toLinkId); - assertEquals(service.getCapacityDemand(), shipment.getSize()); + assertEquals(service.getDemand(), shipment.getSize()); assertEquals(service.getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); boolean handledByTranshipmentHub = false; for (LogisticChainElement clientElement : @@ -438,7 +438,7 @@ public void testSecondReloadLSPScheduling() { assertInstanceOf(LSPTourEndEventHandler.class, eventHandlers.getFirst()); LSPTourEndEventHandler collectionEndHandler = (LSPTourEndEventHandler) eventHandlers.getFirst(); assertSame(collectionEndHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); - assertEquals(collectionEndHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); + assertEquals(collectionEndHandler.getCarrierService().getDemand(), shipment.getSize()); assertEquals(collectionEndHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(collectionEndHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); assertEquals(collectionEndHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); @@ -457,7 +457,7 @@ public void testSecondReloadLSPScheduling() { assertInstanceOf(CollectionServiceEndEventHandler.class, eventHandlers.get(1)); CollectionServiceEndEventHandler collectionServiceHandler = (CollectionServiceEndEventHandler) eventHandlers.get(1); assertSame(collectionServiceHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); - assertEquals(collectionServiceHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); + assertEquals(collectionServiceHandler.getCarrierService().getDemand(), shipment.getSize()); assertEquals(collectionServiceHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(collectionServiceHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); assertEquals(collectionServiceHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); @@ -477,7 +477,7 @@ public void testSecondReloadLSPScheduling() { LSPTourStartEventHandler mainRunStartHandler = (LSPTourStartEventHandler) eventHandlers.get(2); assertSame(mainRunStartHandler.getCarrierService().getLocationLinkId(), toLinkId); assertEquals(mainRunStartHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); - assertEquals(mainRunStartHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); + assertEquals(mainRunStartHandler.getCarrierService().getDemand(), shipment.getSize()); assertEquals(0, mainRunStartHandler.getCarrierService().getServiceStartTimeWindow().getStart(), 0.0); assertEquals(Integer.MAX_VALUE, mainRunStartHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), 0.0); assertSame(mainRunStartHandler.getLogisticChainElement(), planElements.get(4).getLogisticChainElement()); @@ -496,7 +496,7 @@ public void testSecondReloadLSPScheduling() { LSPTourEndEventHandler mainRunEndHandler = (LSPTourEndEventHandler) eventHandlers.get(3); assertSame(mainRunEndHandler.getCarrierService().getLocationLinkId(), toLinkId); assertEquals(mainRunEndHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); - assertEquals(mainRunEndHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); + assertEquals(mainRunEndHandler.getCarrierService().getDemand(), shipment.getSize()); assertEquals(0, mainRunEndHandler.getCarrierService().getServiceStartTimeWindow().getStart(), 0.0); assertEquals(Integer.MAX_VALUE, mainRunEndHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), 0.0); assertSame(mainRunEndHandler.getLogisticChainElement(), planElements.get(4).getLogisticChainElement()); diff --git a/contribs/freightreceiver/src/main/java/org/matsim/freight/receiver/ReceiverTriggersCarrierReplanningListener.java b/contribs/freightreceiver/src/main/java/org/matsim/freight/receiver/ReceiverTriggersCarrierReplanningListener.java index 2b8c4a6dfb9..cf7b07dd8bd 100644 --- a/contribs/freightreceiver/src/main/java/org/matsim/freight/receiver/ReceiverTriggersCarrierReplanningListener.java +++ b/contribs/freightreceiver/src/main/java/org/matsim/freight/receiver/ReceiverTriggersCarrierReplanningListener.java @@ -86,7 +86,7 @@ public void notifyIterationStarts(IterationStartsEvent event) { // TODO This only looks at the FIRST time window. This may need revision once we handle multiple // time windows. .build(); - if (newShipment.getSize() != 0) { + if (newShipment.getDemand() != 0) { receiverOrder.getCarrier().getShipments().put(newShipment.getId(), newShipment ); } } From 91a19fb404f8bfdaff398ff350178e13f0dd0504 Mon Sep 17 00:00:00 2001 From: Kai Martins-Turner Date: Fri, 20 Dec 2024 12:51:09 +0100 Subject: [PATCH 05/18] remove field name from CarrierService, incl. Builder --- .../org/matsim/freight/carriers/CarrierService.java | 13 ------------- .../main/java/org/matsim/freight/carriers/Tour.java | 2 +- .../matsim/freight/carriers/CarriersUtilsTest.java | 2 +- 3 files changed, 2 insertions(+), 15 deletions(-) diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierService.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierService.java index 244c95dd409..94cd241d2b1 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierService.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierService.java @@ -36,7 +36,6 @@ public static Builder newInstance(Id id, Id locationLinkId private final Id id; private final Id locationLinkId; - private String name = "service"; private double serviceTime = 0.0; private TimeWindow timeWindow = TimeWindow.newInstance(0.0, Integer.MAX_VALUE); @@ -48,10 +47,6 @@ private Builder(Id id, Id locationLinkId) { this.locationLinkId = locationLinkId; } - public Builder setName(String name){ - this.name = name; - return this; - } /** * By default, it is [0.0,Integer.MaxValue]. @@ -92,7 +87,6 @@ public Builder setCapacityDemand(int value) { private final Id id; private final Id locationId; - private final String name; private final double serviceDuration; private final TimeWindow timeWindow; private final int demand; @@ -104,7 +98,6 @@ private CarrierService(Builder builder){ serviceDuration = builder.serviceTime; timeWindow = builder.timeWindow; demand = builder.demand; - name = builder.name; } @Override @@ -148,12 +141,6 @@ public Attributes getAttributes() { return attributes; } - /** - * @return the name - */ - public String getType() { - return name; - } @Override public String toString() { diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/Tour.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/Tour.java index 55f72325237..aaf05ebbecc 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/Tour.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/Tour.java @@ -374,7 +374,7 @@ public CarrierService getService(){ @Override public String getActivityType() { - return service.getType(); + return CarrierConstants.SERVICE; } @Override diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarriersUtilsTest.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarriersUtilsTest.java index 6f4ac797052..9353d4d4034 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarriersUtilsTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarriersUtilsTest.java @@ -68,7 +68,7 @@ void testAddAndGetServiceToCarrier() { Carrier carrier = new CarrierImpl(Id.create("carrier", Carrier.class)); Id serviceId = Id.create("testVehicle", CarrierService.class); CarrierService service1 = CarrierService.Builder.newInstance(serviceId,Id.createLinkId("link0") ) - .setName("service1").setCapacityDemand(15).setServiceDuration(30).build(); + .setCapacityDemand(15).setServiceDuration(30).build(); //add Service CarriersUtils.addService(carrier, service1); From 701b615f6e995ec5d5331b81d8ff893dad4a508a Mon Sep 17 00:00:00 2001 From: Kai Martins-Turner Date: Fri, 20 Dec 2024 12:54:55 +0100 Subject: [PATCH 06/18] reorder variables --- .../freight/carriers/CarrierService.java | 12 +++++++----- .../freight/carriers/CarrierShipment.java | 19 +++++++++++-------- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierService.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierService.java index 94cd241d2b1..3b66fbfb657 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierService.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierService.java @@ -35,11 +35,11 @@ public static Builder newInstance(Id id, Id locationLinkId } private final Id id; - private final Id locationLinkId; + private int demand = 0; - private double serviceTime = 0.0; + private final Id locationLinkId; private TimeWindow timeWindow = TimeWindow.newInstance(0.0, Integer.MAX_VALUE); - private int demand = 0; + private double serviceTime = 0.0; private Builder(Id id, Id locationLinkId) { super(); @@ -86,10 +86,12 @@ public Builder setCapacityDemand(int value) { private final Id id; + private final int demand; + private final Id locationId; - private final double serviceDuration; private final TimeWindow timeWindow; - private final int demand; + private final double serviceDuration; + private final Attributes attributes = new AttributesImpl(); private CarrierService(Builder builder){ diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierShipment.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierShipment.java index 3cb62a59182..22d11824e3f 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierShipment.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierShipment.java @@ -49,7 +49,6 @@ public static class Builder { * @deprecated Please use Builder newInstance(Id id, Id from, Id to, int size) instead. *

* Returns a new shipment builder. - * *

The builder is init with the shipment's origin (from), destination (to) and with the shipment's size. * The default-value for serviceTime is 0.0. The default-value for a timeWindow is [start=0.0, end=Double.maxValue()]. * @@ -65,7 +64,6 @@ public static Builder newInstance(Id from, Id to, int size){ /** * Returns a new shipment builder. - * *

The builder is init with the shipment's origin (from), destination (to) and with the shipment's size. * The default-value for serviceTime is 0.0. The default-value for a timeWindow is [start=0.0, end=Double.maxValue()]. * @@ -80,12 +78,14 @@ public static Builder newInstance(Id id, Id from, Id id; - final Id from; - final Id to; final int size; + + final Id from; TimeWindow pickTW = TimeWindow.newInstance(0.0, Integer.MAX_VALUE); - TimeWindow delTW = TimeWindow.newInstance(0.0, Integer.MAX_VALUE); double pickServiceTime = 0.0; + + final Id to; + TimeWindow delTW = TimeWindow.newInstance(0.0, Integer.MAX_VALUE); double delServiceTime = 0.0; /** @@ -133,13 +133,16 @@ public CarrierShipment build(){ } private final Id id; - private final Id from; - private final Id to; private final int demand; + + private final Id from; private final TimeWindow pickupTimeWindow; - private final TimeWindow deliveryTimeWindow; private double pickupServiceTime; + + private final Id to; + private final TimeWindow deliveryTimeWindow; private double deliveryServiceTime; + private final Attributes attributes = new AttributesImpl(); From e700fea5075f89a5fbe577fdcaf4cbc9635569b7 Mon Sep 17 00:00:00 2001 From: Kai Martins-Turner Date: Fri, 20 Dec 2024 12:59:14 +0100 Subject: [PATCH 07/18] rename internal variables --- .../freight/carriers/CarrierService.java | 40 ++++---- .../freight/carriers/CarrierShipment.java | 97 ++++++++++--------- 2 files changed, 68 insertions(+), 69 deletions(-) diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierService.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierService.java index 3b66fbfb657..aeb26ce729f 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierService.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierService.java @@ -30,21 +30,21 @@ public final class CarrierService implements CarrierJob { public static class Builder { - public static Builder newInstance(Id id, Id locationLinkId){ - return new Builder(id,locationLinkId); - } - private final Id id; private int demand = 0; - private final Id locationLinkId; - private TimeWindow timeWindow = TimeWindow.newInstance(0.0, Integer.MAX_VALUE); - private double serviceTime = 0.0; + private final Id serviceLinkId; + private TimeWindow serviceStartsTimeWindow = TimeWindow.newInstance(0.0, Integer.MAX_VALUE); + private double serviceDuration = 0.0; + + public static Builder newInstance(Id id, Id locationLinkId){ + return new Builder(id,locationLinkId); + } - private Builder(Id id, Id locationLinkId) { + private Builder(Id id, Id serviceLinkId) { super(); this.id = id; - this.locationLinkId = locationLinkId; + this.serviceLinkId = serviceLinkId; } @@ -55,7 +55,7 @@ private Builder(Id id, Id locationLinkId) { * @return the builder */ public Builder setServiceDuration(double serviceDuration){ - this.serviceTime = serviceDuration; + this.serviceDuration = serviceDuration; return this; } @@ -69,7 +69,7 @@ public Builder setServiceDuration(double serviceDuration){ * @return the builder */ public Builder setServiceStartTimeWindow(TimeWindow startTimeWindow){ - this.timeWindow = startTimeWindow; + this.serviceStartsTimeWindow = startTimeWindow; return this; } @@ -88,17 +88,17 @@ public Builder setCapacityDemand(int value) { private final Id id; private final int demand; - private final Id locationId; - private final TimeWindow timeWindow; + private final Id serviceLinkId; + private final TimeWindow serviceStartsTimeWindow; private final double serviceDuration; private final Attributes attributes = new AttributesImpl(); private CarrierService(Builder builder){ id = builder.id; - locationId = builder.locationLinkId; - serviceDuration = builder.serviceTime; - timeWindow = builder.timeWindow; + serviceLinkId = builder.serviceLinkId; + serviceDuration = builder.serviceDuration; + serviceStartsTimeWindow = builder.serviceStartsTimeWindow; demand = builder.demand; } @@ -107,10 +107,8 @@ public Id getId() { return id; } - - public Id getLocationLinkId() { - return locationId; + return serviceLinkId; } public double getServiceDuration() { @@ -118,7 +116,7 @@ public double getServiceDuration() { } public TimeWindow getServiceStartTimeWindow(){ - return timeWindow; + return serviceStartsTimeWindow; } /** @@ -146,7 +144,7 @@ public Attributes getAttributes() { @Override public String toString() { - return "[id=" + id + "][locationId=" + locationId + "][capacityDemand=" + demand + "][serviceDuration=" + serviceDuration + "][startTimeWindow=" + timeWindow + "]"; + return "[id=" + id + "][locationId=" + serviceLinkId + "][capacityDemand=" + demand + "][serviceDuration=" + serviceDuration + "][startTimeWindow=" + serviceStartsTimeWindow + "]"; } /* (non-Javadoc) diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierShipment.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierShipment.java index 22d11824e3f..a9975bd7213 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierShipment.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierShipment.java @@ -45,6 +45,18 @@ public final class CarrierShipment implements CarrierJob { */ public static class Builder { + Id id; + final int demand; + + final Id pickupLinkId; + TimeWindow pickupStartsTimeWindow = TimeWindow.newInstance(0.0, Integer.MAX_VALUE); + double pickupDuration = 0.0; + + final Id deliveryLinkId; + TimeWindow deliveryStartsTimeWindow = TimeWindow.newInstance(0.0, Integer.MAX_VALUE); + double deliveryDuration = 0.0; + + /** * @deprecated Please use Builder newInstance(Id id, Id from, Id to, int size) instead. *

@@ -77,53 +89,42 @@ public static Builder newInstance(Id id, Id from, Id id; - final int size; - - final Id from; - TimeWindow pickTW = TimeWindow.newInstance(0.0, Integer.MAX_VALUE); - double pickServiceTime = 0.0; - - final Id to; - TimeWindow delTW = TimeWindow.newInstance(0.0, Integer.MAX_VALUE); - double delServiceTime = 0.0; - /** * @deprecated Please use Builder (Id id, Id from, Id to, int size) instead. */ @Deprecated - public Builder(Id from, Id to, int size) { + public Builder(Id pickupLinkId, Id deliveryLinkId, int demand) { super(); - this.from = from; - this.to = to; - this.size = size; + this.pickupLinkId = pickupLinkId; + this.deliveryLinkId = deliveryLinkId; + this.demand = demand; } - public Builder(Id id, Id from, Id to, int size) { + public Builder(Id id, Id pickupLinkId, Id deliveryLinkId, int demand) { super(); this.id = id; - this.from = from; - this.to = to; - this.size = size; + this.pickupLinkId = pickupLinkId; + this.deliveryLinkId = deliveryLinkId; + this.demand = demand; } public Builder setPickupTimeWindow(TimeWindow pickupTW){ - this.pickTW = pickupTW; + this.pickupStartsTimeWindow = pickupTW; return this; } public Builder setDeliveryTimeWindow(TimeWindow deliveryTW){ - this.delTW = deliveryTW; + this.deliveryStartsTimeWindow = deliveryTW; return this; } public Builder setPickupServiceTime(double pickupServiceTime){ - this.pickServiceTime = pickupServiceTime; + this.pickupDuration = pickupServiceTime; return this; } public Builder setDeliveryServiceTime(double deliveryServiceTime){ - this.delServiceTime = deliveryServiceTime; + this.deliveryDuration = deliveryServiceTime; return this; } @@ -135,42 +136,42 @@ public CarrierShipment build(){ private final Id id; private final int demand; - private final Id from; - private final TimeWindow pickupTimeWindow; - private double pickupServiceTime; + private final Id pickupLinkId; + private final TimeWindow pickupStartsTimeWindow; + private double pickupDuration; - private final Id to; - private final TimeWindow deliveryTimeWindow; - private double deliveryServiceTime; + private final Id deliveryLinkId; + private final TimeWindow deliveryStartsTimeWindow; + private double deliveryDuration; private final Attributes attributes = new AttributesImpl(); private CarrierShipment(Builder builder) { id = builder.id; - from = builder.from; - to = builder.to; - demand = builder.size; - pickupServiceTime = builder.pickServiceTime; - deliveryServiceTime = builder.delServiceTime; - pickupTimeWindow = builder.pickTW; - deliveryTimeWindow = builder.delTW; + pickupLinkId = builder.pickupLinkId; + deliveryLinkId = builder.deliveryLinkId; + demand = builder.demand; + pickupDuration = builder.pickupDuration; + deliveryDuration = builder.deliveryDuration; + pickupStartsTimeWindow = builder.pickupStartsTimeWindow; + deliveryStartsTimeWindow = builder.deliveryStartsTimeWindow; } public double getPickupServiceTime() { - return pickupServiceTime; + return pickupDuration; } - public void setPickupServiceTime(double pickupServiceTime) { - this.pickupServiceTime = pickupServiceTime; + public void setPickupServiceTime(double pickupDuration) { + this.pickupDuration = pickupDuration; } public double getDeliveryServiceTime() { - return deliveryServiceTime; + return deliveryDuration; } - public void setDeliveryServiceTime(double deliveryServiceTime) { - this.deliveryServiceTime = deliveryServiceTime; + public void setDeliveryServiceTime(double deliveryDuration) { + this.deliveryDuration = deliveryDuration; } @Override @@ -179,11 +180,11 @@ public Id getId() { } public Id getFrom() { - return from; + return pickupLinkId; } public Id getTo() { - return to; + return deliveryLinkId; } /** @@ -203,11 +204,11 @@ public int getDemand() { } public TimeWindow getPickupTimeWindow() { - return pickupTimeWindow; + return pickupStartsTimeWindow; } public TimeWindow getDeliveryTimeWindow() { - return deliveryTimeWindow; + return deliveryStartsTimeWindow; } @Override @@ -217,8 +218,8 @@ public Attributes getAttributes() { @Override public String toString() { - return "[id= "+ id.toString() + "][hash=" + this.hashCode() + "][from=" + from.toString() + "][to=" + to.toString() + "][size=" + demand + "][pickupServiceTime=" + pickupServiceTime + "]" + - "[deliveryServiceTime="+deliveryServiceTime+"][pickupTimeWindow="+pickupTimeWindow+"][deliveryTimeWindow="+deliveryTimeWindow+"]"; + return "[id= "+ id.toString() + "][hash=" + this.hashCode() + "][from=" + pickupLinkId.toString() + "][to=" + deliveryLinkId.toString() + "][size=" + demand + "][pickupServiceTime=" + pickupDuration + "]" + + "[deliveryServiceTime="+ deliveryDuration +"][pickupTimeWindow="+ pickupStartsTimeWindow +"][deliveryTimeWindow="+ deliveryStartsTimeWindow +"]"; } /* (non-Javadoc) From 27984fad5eb186a2db2ff38a542367e7c5523fd7 Mon Sep 17 00:00:00 2001 From: Kai Martins-Turner Date: Fri, 20 Dec 2024 13:04:34 +0100 Subject: [PATCH 08/18] make vars in Builder private --- .../matsim/freight/carriers/CarrierShipment.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierShipment.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierShipment.java index a9975bd7213..dd12b8957b8 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierShipment.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierShipment.java @@ -45,16 +45,16 @@ public final class CarrierShipment implements CarrierJob { */ public static class Builder { - Id id; - final int demand; + private Id id; + private final int demand; - final Id pickupLinkId; - TimeWindow pickupStartsTimeWindow = TimeWindow.newInstance(0.0, Integer.MAX_VALUE); - double pickupDuration = 0.0; + private final Id pickupLinkId; + private TimeWindow pickupStartsTimeWindow = TimeWindow.newInstance(0.0, Integer.MAX_VALUE); + private double pickupDuration = 0.0; - final Id deliveryLinkId; - TimeWindow deliveryStartsTimeWindow = TimeWindow.newInstance(0.0, Integer.MAX_VALUE); - double deliveryDuration = 0.0; + private final Id deliveryLinkId; + private TimeWindow deliveryStartsTimeWindow = TimeWindow.newInstance(0.0, Integer.MAX_VALUE); + private double deliveryDuration = 0.0; /** From 5d71e55677941b55c7307e3aada600845fcf0b14 Mon Sep 17 00:00:00 2001 From: Kai Martins-Turner Date: Fri, 20 Dec 2024 13:09:44 +0100 Subject: [PATCH 09/18] make id final --- .../java/org/matsim/freight/carriers/CarrierShipment.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierShipment.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierShipment.java index dd12b8957b8..93e9dc590fe 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierShipment.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierShipment.java @@ -45,7 +45,7 @@ public final class CarrierShipment implements CarrierJob { */ public static class Builder { - private Id id; + private final Id id; private final int demand; private final Id pickupLinkId; @@ -71,7 +71,8 @@ public static class Builder { */ @Deprecated public static Builder newInstance(Id from, Id to, int size){ - return new Builder(from,to,size); + var id = Id.create(CarrierConstants.SHIPMENT +"_" + from.toString() + "_" + to.toString(), CarrierShipment.class); + return new Builder(id, from,to,size); } /** @@ -95,6 +96,7 @@ public static Builder newInstance(Id id, Id from, Id pickupLinkId, Id deliveryLinkId, int demand) { super(); + this.id = Id.create(CarrierConstants.SHIPMENT +"_" + pickupLinkId.toString() + "_" + deliveryLinkId.toString(), CarrierShipment.class); this.pickupLinkId = pickupLinkId; this.deliveryLinkId = deliveryLinkId; this.demand = demand; From da488beb20239c73efbf4c4bc80f1d2dccbf448e Mon Sep 17 00:00:00 2001 From: Kai Martins-Turner Date: Fri, 20 Dec 2024 13:11:14 +0100 Subject: [PATCH 10/18] make Builder constructor private, use available Builder.newInstance method instead --- .../main/java/org/matsim/freight/carriers/CarrierShipment.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierShipment.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierShipment.java index 93e9dc590fe..3955d7b1756 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierShipment.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierShipment.java @@ -102,7 +102,7 @@ public Builder(Id pickupLinkId, Id deliveryLinkId, int demand) { this.demand = demand; } - public Builder(Id id, Id pickupLinkId, Id deliveryLinkId, int demand) { + private Builder(Id id, Id pickupLinkId, Id deliveryLinkId, int demand) { super(); this.id = id; this.pickupLinkId = pickupLinkId; From 10071dbd742eb80ccc5d80e0e94fea8e4686c8a4 Mon Sep 17 00:00:00 2001 From: Kai Martins-Turner Date: Fri, 20 Dec 2024 13:29:16 +0100 Subject: [PATCH 11/18] rename setters in Builder to make it more consistent. old setters remain as deprecated --- .../freight/carriers/CarrierService.java | 33 ++++--- .../freight/carriers/CarrierShipment.java | 96 ++++++++++++++++--- 2 files changed, 103 insertions(+), 26 deletions(-) diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierService.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierService.java index aeb26ce729f..a8f59daad9e 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierService.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierService.java @@ -47,35 +47,40 @@ private Builder(Id id, Id serviceLinkId) { this.serviceLinkId = serviceLinkId; } + public CarrierService build(){ + return new CarrierService(this); + } + /** - * By default, it is [0.0,Integer.MaxValue]. + * Sets a time-window for the beginning of the service + * When not set, it is by default [0.0., Integer.MAX_VALUE]. + *

+ * Note that the time-window restricts the start-time of the service (i.e. serviceActivity). If one works with hard time-windows (which means that + * time-windows must be met) than the service is allowed to start between startTimeWindow.getStart() and startTimeWindow.getEnd(). * - * @param serviceDuration duration of the service + * @param startTimeWindow time-window for the beginning of the service acti * @return the builder */ - public Builder setServiceDuration(double serviceDuration){ - this.serviceDuration = serviceDuration; + public Builder setServiceStartTimeWindow(TimeWindow startTimeWindow){ + this.serviceStartsTimeWindow = startTimeWindow; return this; } /** - * Sets a time-window for the service. - * - *

Note that the time-window restricts the start-time of the service (i.e. serviceActivity). If one works with hard time-windows (which means that - * time-windows must be met) than the service is allowed to start between startTimeWindow.getStart() and startTimeWindow.getEnd(). + * Sets the duration for the pickup activity. + * When not set, it is by default 0.0. * - * @param startTimeWindow time-window for the service + * @param serviceDuration duration of the service * @return the builder */ - public Builder setServiceStartTimeWindow(TimeWindow startTimeWindow){ - this.serviceStartsTimeWindow = startTimeWindow; + public Builder setServiceDuration(double serviceDuration){ + this.serviceDuration = serviceDuration; return this; } - public CarrierService build(){ - return new CarrierService(this); - } + + public Builder setCapacityDemand(int value) { this.demand = value; diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierShipment.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierShipment.java index 3955d7b1756..f6af6a28d55 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierShipment.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierShipment.java @@ -77,17 +77,17 @@ public static Builder newInstance(Id from, Id to, int size){ /** * Returns a new shipment builder. - *

The builder is init with the shipment's origin (from), destination (to) and with the shipment's size. + *

The builder is init with the shipment's origin (from), destination (to) and with the shipment's demand. * The default-value for serviceTime is 0.0. The default-value for a timeWindow is [start=0.0, end=Double.maxValue()]. * * @param id the id of the shipment * @param from the origin * @param to the destination - * @param size size of the shipment + * @param demand demand of the shipment * @return the builder */ - public static Builder newInstance(Id id, Id from, Id to, int size){ - return new Builder(id, from,to,size); + public static Builder newInstance(Id id, Id from, Id to, int demand){ + return new Builder(id, from, to, demand); } /** @@ -110,29 +110,101 @@ private Builder(Id id, Id pickupLinkId, Id delivery this.demand = demand; } - public Builder setPickupTimeWindow(TimeWindow pickupTW){ - this.pickupStartsTimeWindow = pickupTW; + /** + * Sets a time-window for the beginning of the pickup + * When not set, it is by default [0.0., Integer.MAX_VALUE]. + *

+ * Note that the time-window restricts the start-time of the shipment's pickup . If one works with hard time-windows (which means that + * time-windows must be met) than the pickup is allowed to start between startTimeWindow.getStart() and startTimeWindow.getEnd(). + * + * @param pickupStartsTimeWindow time-window for the beginning of the pickup activity + * @return the builder + */ + public Builder setPickupStartsTimeWindow(TimeWindow pickupStartsTimeWindow){ + this.pickupStartsTimeWindow = pickupStartsTimeWindow; return this; } - public Builder setDeliveryTimeWindow(TimeWindow deliveryTW){ - this.deliveryStartsTimeWindow = deliveryTW; + /** + * Sets the duration for the pickup activity. + * When not set, it is by default 0.0. + * + * @param pickupDuration Duration of the pickup activity (in seconds). + * @return the Builder + */ + public Builder setPickupDuration(double pickupDuration){ + this.pickupDuration = pickupDuration; return this; } - public Builder setPickupServiceTime(double pickupServiceTime){ - this.pickupDuration = pickupServiceTime; + /** + * Sets a time-window for the beginning of the delivery + * When not set, it is by default [0.0., Integer.MAX_VALUE]. + *

+ * Note that the time-window restricts the start-time of the shipment's delivery . If one works with hard time-windows (which means that + * time-windows must be met) than the delivery is allowed to start between startTimeWindow.getStart() and startTimeWindow.getEnd(). + * + * @param deliveryStartsTimeWindow time-window for the beginning of the delivery activity + * @return the builder + */ + public Builder setDeliveryStartsTimeWindow(TimeWindow deliveryStartsTimeWindow){ + this.deliveryStartsTimeWindow = deliveryStartsTimeWindow; return this; } - public Builder setDeliveryServiceTime(double deliveryServiceTime){ - this.deliveryDuration = deliveryServiceTime; + /** + * Sets the duration for the delivery activity. + * When not set, it is by default 0.0. + * + * @param deliveryDuration Duration of the delivery activity (in seconds). + * @return the Builder + */ + public Builder setDeliveryDuration(double deliveryDuration){ + this.deliveryDuration = deliveryDuration; return this; } public CarrierShipment build(){ return new CarrierShipment(this); } + + //*** deprecated methods *** + + + /** + * @deprecated please inline and use {@link #setPickupStartsTimeWindow(TimeWindow)} instead + */ + @Deprecated(since = "dez 2024") + public Builder setPickupTimeWindow(TimeWindow pickupTW){ + return setPickupStartsTimeWindow(pickupTW); + } + + /** + * @deprecated please inline and use {@link #setPickupDuration(double)} instead + */ + @Deprecated(since = "dez 2024") + public Builder setPickupServiceTime(double pickupServiceTime){ + return setPickupDuration(pickupServiceTime); + } + + /** + * @deprecated please inline and use {@link #setDeliveryStartsTimeWindow(TimeWindow)} instead + */ + @Deprecated(since = "dez 2024") + public Builder setDeliveryTimeWindow(TimeWindow deliveryTW){ + return setDeliveryStartsTimeWindow(deliveryTW); + } + + /** + * @deprecated please inline and use {@link #setDeliveryDuration(double)} instead + */ + @Deprecated(since = "dez 2024") + public Builder setDeliveryServiceTime(double deliveryServiceTime){ + return setDeliveryDuration(deliveryServiceTime); + } + + + } private final Id id; From cbe5a12d92c35542f04022518866f05e246f18d7 Mon Sep 17 00:00:00 2001 From: Kai Martins-Turner Date: Fri, 20 Dec 2024 13:42:37 +0100 Subject: [PATCH 12/18] comments and javadoc --- .../freight/carriers/CarrierService.java | 22 ++++++++++++---- .../freight/carriers/CarrierShipment.java | 25 +++++++++++++------ 2 files changed, 34 insertions(+), 13 deletions(-) diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierService.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierService.java index a8f59daad9e..016b16638e2 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierService.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierService.java @@ -33,6 +33,9 @@ public static class Builder { private final Id id; private int demand = 0; + //IMO we could build a general class (CarrierActivity ???), containing the location, StartTimeWindow and Duration. + //This could be used for both, CarrierService and CarrierShipment (Pickup and Delivery). + //kturner dec'24 private final Id serviceLinkId; private TimeWindow serviceStartsTimeWindow = TimeWindow.newInstance(0.0, Integer.MAX_VALUE); private double serviceDuration = 0.0; @@ -59,7 +62,7 @@ public CarrierService build(){ * Note that the time-window restricts the start-time of the service (i.e. serviceActivity). If one works with hard time-windows (which means that * time-windows must be met) than the service is allowed to start between startTimeWindow.getStart() and startTimeWindow.getEnd(). * - * @param startTimeWindow time-window for the beginning of the service acti + * @param startTimeWindow time-window for the beginning of the service activity * @return the builder */ public Builder setServiceStartTimeWindow(TimeWindow startTimeWindow){ @@ -79,9 +82,15 @@ public Builder setServiceDuration(double serviceDuration){ return this; } - - - + /** + * Sets the demand (size; capacity needed) of the service. + * When not set, it is by default 0. + *

+ * IMO we can put this into the Builder directly instead of a separate method? kturner dec'24 + * + * @param value the demand (size; capacity needed) of the service + * @return the builder + */ public Builder setCapacityDemand(int value) { this.demand = value; return this; @@ -93,6 +102,9 @@ public Builder setCapacityDemand(int value) { private final Id id; private final int demand; + //IMO we could build a general class (CarrierActivity ???), containing the location, StartTimeWindow and Duration. + //This could be used for both, CarrierService and CarrierShipment (Pickup and Delivery). + //kturner dec'24 private final Id serviceLinkId; private final TimeWindow serviceStartsTimeWindow; private final double serviceDuration; @@ -127,7 +139,7 @@ public TimeWindow getServiceStartTimeWindow(){ /** * @deprecated please inline and use {@link #getDemand()} instead */ - @Deprecated(since = "dez 2024") + @Deprecated(since = "dec'24") public int getCapacityDemand() { return getDemand(); } diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierShipment.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierShipment.java index f6af6a28d55..e39b82afa5a 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierShipment.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierShipment.java @@ -48,10 +48,16 @@ public static class Builder { private final Id id; private final int demand; + //IMO we could build a general class (CarrierActivity ???), containing the location, StartTimeWindow and Duration. + //This could be used for both, CarrierService and CarrierShipment (Pickup and Delivery). + //kturner dec'24 private final Id pickupLinkId; private TimeWindow pickupStartsTimeWindow = TimeWindow.newInstance(0.0, Integer.MAX_VALUE); private double pickupDuration = 0.0; + //IMO we could build a general class (CarrierActivity ???), containing the location, StartTimeWindow and Duration. + //This could be used for both, CarrierService and CarrierShipment (Pickup and Delivery). + //kturner dec'24 private final Id deliveryLinkId; private TimeWindow deliveryStartsTimeWindow = TimeWindow.newInstance(0.0, Integer.MAX_VALUE); private double deliveryDuration = 0.0; @@ -174,7 +180,7 @@ public CarrierShipment build(){ /** * @deprecated please inline and use {@link #setPickupStartsTimeWindow(TimeWindow)} instead */ - @Deprecated(since = "dez 2024") + @Deprecated(since = "dec'24") public Builder setPickupTimeWindow(TimeWindow pickupTW){ return setPickupStartsTimeWindow(pickupTW); } @@ -182,7 +188,7 @@ public Builder setPickupTimeWindow(TimeWindow pickupTW){ /** * @deprecated please inline and use {@link #setPickupDuration(double)} instead */ - @Deprecated(since = "dez 2024") + @Deprecated(since = "dec'24") public Builder setPickupServiceTime(double pickupServiceTime){ return setPickupDuration(pickupServiceTime); } @@ -190,7 +196,7 @@ public Builder setPickupServiceTime(double pickupServiceTime){ /** * @deprecated please inline and use {@link #setDeliveryStartsTimeWindow(TimeWindow)} instead */ - @Deprecated(since = "dez 2024") + @Deprecated(since = "dec'24") public Builder setDeliveryTimeWindow(TimeWindow deliveryTW){ return setDeliveryStartsTimeWindow(deliveryTW); } @@ -198,22 +204,25 @@ public Builder setDeliveryTimeWindow(TimeWindow deliveryTW){ /** * @deprecated please inline and use {@link #setDeliveryDuration(double)} instead */ - @Deprecated(since = "dez 2024") + @Deprecated(since = "dec'24") public Builder setDeliveryServiceTime(double deliveryServiceTime){ return setDeliveryDuration(deliveryServiceTime); } - - - } private final Id id; private final int demand; + //IMO we could build a general class (CarrierActivity ???), containing the location, StartTimeWindow and Duration. + //This could be used for both, CarrierService and CarrierShipment (Pickup and Delivery). + //kturner dec'24 private final Id pickupLinkId; private final TimeWindow pickupStartsTimeWindow; private double pickupDuration; + //IMO we could build a general class (CarrierActivity ???), containing the location, StartTimeWindow and Duration. + //This could be used for both, CarrierService and CarrierShipment (Pickup and Delivery). + //kturner dec'24 private final Id deliveryLinkId; private final TimeWindow deliveryStartsTimeWindow; private double deliveryDuration; @@ -264,7 +273,7 @@ public Id getTo() { /** * @deprecated please inline and use {@link #getDemand()} instead */ - @Deprecated(since = "dez 2024") + @Deprecated(since = "dec'24") public int getSize() { return getDemand(); } From b8c6da6dbb8679cbc2eea3044e6c3f3a03f40774 Mon Sep 17 00:00:00 2001 From: Kai Martins-Turner Date: Fri, 20 Dec 2024 13:45:58 +0100 Subject: [PATCH 13/18] rename setter in Builder to make it more consistent. old setter remain as deprecated --- .../freight/carriers/CarrierService.java | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierService.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierService.java index 016b16638e2..7a140a5b386 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierService.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierService.java @@ -82,18 +82,35 @@ public Builder setServiceDuration(double serviceDuration){ return this; } + /** + * Sets the demand (size; capacity needed) of the service. + * When not set, it is by default 0. + *

+ * IMO we can put this into the Builder directly instead of a separate method? kturner dec'24 + * + * @param demand the demand (size; capacity needed) of the service + * @return the builder + */ + public Builder setDemand(int demand) { + this.demand = demand; + return this; + } + + /** * Sets the demand (size; capacity needed) of the service. * When not set, it is by default 0. *

* IMO we can put this into the Builder directly instead of a separate method? kturner dec'24 * + * @deprecated please use {@link #setDemand(int)} instead + * * @param value the demand (size; capacity needed) of the service * @return the builder */ + @Deprecated(since = "dec'24") public Builder setCapacityDemand(int value) { - this.demand = value; - return this; + return setDemand(value); } } From 80cc5df4e395411d5742f322e5975b406dd0862c Mon Sep 17 00:00:00 2001 From: Kai Martins-Turner Date: Fri, 20 Dec 2024 14:23:00 +0100 Subject: [PATCH 14/18] use new method names --- .../DemandReaderFromCSV.java | 20 ++++++------ .../DefaultCommercialJobGenerator.java | 2 +- .../freight/carriers/CarrierPlanReaderV1.java | 10 +++--- .../carriers/CarrierPlanXmlParserV2.java | 10 +++--- .../carriers/CarrierPlanXmlParserV2_1.java | 10 +++--- .../freight/carriers/CarriersUtils.java | 6 ++-- .../events/CarrierServiceStartEvent.java | 2 +- .../CarrierShipmentDeliveryEndEvent.java | 2 +- .../CarrierShipmentDeliveryStartEvent.java | 2 +- .../events/CarrierShipmentPickupEndEvent.java | 2 +- .../CarrierShipmentPickupStartEvent.java | 2 +- .../carriers/jsprit/MatsimJspritFactory.java | 10 +++--- .../chessboard/FreightScenarioCreator.java | 2 +- .../CollectionCarrierScheduler.java | 2 +- .../DistributionCarrierScheduler.java | 4 +-- .../MainRunCarrierScheduler.java | 2 +- .../freight/carriers/CarriersUtilsTest.java | 2 +- ...istanceConstraintFromVehiclesFileTest.java | 6 ++-- .../jsprit/DistanceConstraintTest.java | 10 +++--- .../carriers/jsprit/FixedCostsTest.java | 2 +- .../jsprit/MatsimTransformerTest.java | 18 +++++------ .../freight/carriers/jsprit/SkillsIT.java | 32 +++++++++---------- .../utils/CarrierControllerUtilsIT.java | 11 +++---- .../utils/CarrierControllerUtilsTest.java | 10 +++--- ...iverTriggersCarrierReplanningListener.java | 4 +-- .../ReceiverChessboardScenario.java | 4 +-- 26 files changed, 93 insertions(+), 94 deletions(-) diff --git a/contribs/application/src/main/java/org/matsim/freightDemandGeneration/DemandReaderFromCSV.java b/contribs/application/src/main/java/org/matsim/freightDemandGeneration/DemandReaderFromCSV.java index 3f7c9c242e0..4355e7b938b 100644 --- a/contribs/application/src/main/java/org/matsim/freightDemandGeneration/DemandReaderFromCSV.java +++ b/contribs/application/src/main/java/org/matsim/freightDemandGeneration/DemandReaderFromCSV.java @@ -655,7 +655,7 @@ else if (samplingOption.equals("changeNumberOfLocationsWithDemand")) { createJobId(scenario, newDemandInformationElement, link.getId(), null), CarrierService.class); CarrierService thisService = CarrierService.Builder.newInstance(idNewService, link.getId()) - .setCapacityDemand(demandForThisLink).setServiceDuration(serviceTime) + .setDemand(demandForThisLink).setServiceDuration(serviceTime) .setServiceStartTimeWindow(newDemandInformationElement.getFirstJobElementTimeWindow()) .build(); CarriersUtils.getCarriers(scenario).getCarriers() @@ -696,7 +696,7 @@ else if (samplingOption.equals("changeNumberOfLocationsWithDemand")) { CarrierService.class); if (demandToDistribute > 0 && singleDemandForThisLink > 0) { CarrierService thisService = CarrierService.Builder.newInstance(idNewService, link.getId()) - .setCapacityDemand(singleDemandForThisLink).setServiceDuration(serviceTime) + .setDemand(singleDemandForThisLink).setServiceDuration(serviceTime) .setServiceStartTimeWindow(newDemandInformationElement.getFirstJobElementTimeWindow()) .build(); thisCarrier.getServices().put(thisService.getId(), thisService); @@ -747,7 +747,7 @@ else if (samplingOption.equals("changeNumberOfLocationsWithDemand")) { createJobId(scenario, newDemandInformationElement, link.getId(), null), CarrierService.class); if ((demandToDistribute > 0 && singleDemandForThisLink > 0) || demandToDistribute == 0) { CarrierService thisService = CarrierService.Builder.newInstance(idNewService, link.getId()) - .setCapacityDemand(singleDemandForThisLink).setServiceDuration(serviceTime) + .setDemand(singleDemandForThisLink).setServiceDuration(serviceTime) .setServiceStartTimeWindow(newDemandInformationElement.getFirstJobElementTimeWindow()) .build(); CarriersUtils.getCarriers(scenario).getCarriers() @@ -1051,8 +1051,8 @@ private static void createSingleShipment(Scenario scenario, DemandInformationEle CarrierShipment thisShipment = CarrierShipment.Builder .newInstance(idNewShipment, linkPickup.getId(), linkDelivery.getId(), singleDemandForThisLink) - .setPickupServiceTime(serviceTimePickup).setPickupTimeWindow(timeWindowPickup) - .setDeliveryServiceTime(serviceTimeDelivery).setDeliveryTimeWindow(timeWindowDelivery) + .setPickupDuration(serviceTimePickup).setPickupStartsTimeWindow(timeWindowPickup) + .setDeliveryDuration(serviceTimeDelivery).setDeliveryStartsTimeWindow(timeWindowDelivery) .build(); thisCarrier.getShipments().put(thisShipment.getId(), thisShipment); if (demandForThisLink == 0) @@ -1207,10 +1207,10 @@ private static void combineSimilarJobs(Scenario scenario) { } CarrierShipment newShipment = CarrierShipment.Builder .newInstance(idNewShipment, baseShipment.getFrom(), baseShipment.getTo(), demandForThisLink) - .setPickupServiceTime(serviceTimePickup) - .setPickupTimeWindow(baseShipment.getPickupTimeWindow()) - .setDeliveryServiceTime(serviceTimeDelivery) - .setDeliveryTimeWindow(baseShipment.getDeliveryTimeWindow()).build(); + .setPickupDuration(serviceTimePickup) + .setPickupStartsTimeWindow(baseShipment.getPickupTimeWindow()) + .setDeliveryDuration(serviceTimeDelivery) + .setDeliveryStartsTimeWindow(baseShipment.getDeliveryTimeWindow()).build(); shipmentsToAdd.add(newShipment); } } @@ -1253,7 +1253,7 @@ private static void combineSimilarJobs(Scenario scenario) { .newInstance(idNewService, baseService.getLocationLinkId()) .setServiceDuration(serviceTimeService) .setServiceStartTimeWindow(baseService.getServiceStartTimeWindow()) - .setCapacityDemand(demandForThisLink).build(); + .setDemand(demandForThisLink).build(); servicesToAdd.add(newService); } } 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 3327f46292c..2891b802294 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 @@ -329,7 +329,7 @@ public void generateIterationServices(Carriers carriers, Population population) double latestStart = Double.parseDouble(commercialJobProperties.get(COMMERCIALJOB_ATTRIBUTE_END_IDX)); CarrierService.Builder serviceBuilder = CarrierService.Builder.newInstance(serviceId, PopulationUtils.decideOnLinkIdForActivity(activity,scenario)); - serviceBuilder.setCapacityDemand(Integer.parseInt(commercialJobProperties.get(COMMERCIALJOB_ATTRIBUTE_AMOUNT_IDX))); + serviceBuilder.setDemand(Integer.parseInt(commercialJobProperties.get(COMMERCIALJOB_ATTRIBUTE_AMOUNT_IDX))); serviceBuilder.setServiceDuration(Double.parseDouble(commercialJobProperties.get(COMMERCIALJOB_ATTRIBUTE_DURATION_IDX))); serviceBuilder.setServiceStartTimeWindow(TimeWindow.newInstance(earliestStart,latestStart)); diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierPlanReaderV1.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierPlanReaderV1.java index 4bb90047d86..42b2317a6cb 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierPlanReaderV1.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierPlanReaderV1.java @@ -116,19 +116,19 @@ public void startTag(String name, Attributes attributes, Stack context) CarrierShipment.Builder shipmentBuilder = CarrierShipment.Builder.newInstance( Id.create( id, CarrierShipment.class ), Id.create( from, Link.class ), Id.create( to, Link.class ), size ); if( startPickup == null ){ - shipmentBuilder.setPickupTimeWindow( TimeWindow.newInstance( 0.0, Integer.MAX_VALUE ) ).setDeliveryTimeWindow( + shipmentBuilder.setPickupStartsTimeWindow( TimeWindow.newInstance( 0.0, Integer.MAX_VALUE ) ).setDeliveryStartsTimeWindow( TimeWindow.newInstance( 0.0, Integer.MAX_VALUE ) ); } else{ - shipmentBuilder.setPickupTimeWindow( TimeWindow.newInstance( getDouble( startPickup ), getDouble( endPickup ) ) ). - setDeliveryTimeWindow( + shipmentBuilder.setPickupStartsTimeWindow( TimeWindow.newInstance( getDouble( startPickup ), getDouble( endPickup ) ) ). + setDeliveryStartsTimeWindow( TimeWindow.newInstance( getDouble( startDelivery ), getDouble( endDelivery ) ) ); } - if( pickupServiceTime != null ) shipmentBuilder.setPickupServiceTime( getDouble( pickupServiceTime ) ); - if( deliveryServiceTime != null ) shipmentBuilder.setDeliveryServiceTime( getDouble( deliveryServiceTime ) ); + if( pickupServiceTime != null ) shipmentBuilder.setPickupDuration( getDouble( pickupServiceTime ) ); + if( deliveryServiceTime != null ) shipmentBuilder.setDeliveryDuration( getDouble( deliveryServiceTime ) ); CarrierShipment shipment = shipmentBuilder.build(); currentShipments.put( attributes.getValue( ID ), shipment ); CarriersUtils.addShipment(currentCarrier, shipment); diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierPlanXmlParserV2.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierPlanXmlParserV2.java index 271871b0970..599c48a3886 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierPlanXmlParserV2.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierPlanXmlParserV2.java @@ -117,7 +117,7 @@ public void startTag(String name, Attributes atts, Stack context) { Id to = Id.create(toLocation, Link.class); CarrierService.Builder serviceBuilder = CarrierService.Builder.newInstance(id, to); String capDemandString = atts.getValue("capacityDemand"); - if (capDemandString != null) serviceBuilder.setCapacityDemand(getInt(capDemandString)); + if (capDemandString != null) serviceBuilder.setDemand(getInt(capDemandString)); String startString = atts.getValue("earliestStart"); double start = parseTimeToDouble(startString); double end; @@ -157,13 +157,13 @@ public void startTag(String name, Attributes atts, Stack context) { String deliveryServiceTime = atts.getValue("deliveryServiceTime"); if (startPickup != null && endPickup != null) - shipmentBuilder.setPickupTimeWindow(TimeWindow.newInstance(parseTimeToDouble(startPickup), parseTimeToDouble(endPickup))); + shipmentBuilder.setPickupStartsTimeWindow(TimeWindow.newInstance(parseTimeToDouble(startPickup), parseTimeToDouble(endPickup))); if (startDelivery != null && endDelivery != null) - shipmentBuilder.setDeliveryTimeWindow(TimeWindow.newInstance(parseTimeToDouble(startDelivery), parseTimeToDouble(endDelivery))); + shipmentBuilder.setDeliveryStartsTimeWindow(TimeWindow.newInstance(parseTimeToDouble(startDelivery), parseTimeToDouble(endDelivery))); if (pickupServiceTime != null) - shipmentBuilder.setPickupServiceTime(parseTimeToDouble(pickupServiceTime)); + shipmentBuilder.setPickupDuration(parseTimeToDouble(pickupServiceTime)); if (deliveryServiceTime != null) - shipmentBuilder.setDeliveryServiceTime(parseTimeToDouble(deliveryServiceTime)); + shipmentBuilder.setDeliveryDuration(parseTimeToDouble(deliveryServiceTime)); currentShipment = shipmentBuilder.build(); currentShipments.put(atts.getValue(ID), currentShipment); diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierPlanXmlParserV2_1.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierPlanXmlParserV2_1.java index 9c3f2b7a1e6..a9f06abb1f4 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierPlanXmlParserV2_1.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierPlanXmlParserV2_1.java @@ -115,7 +115,7 @@ public void startTag(String name, Attributes atts, Stack context) { Id to = Id.create(toLocation, Link.class); CarrierService.Builder serviceBuilder = CarrierService.Builder.newInstance(id, to); String capDemandString = atts.getValue("capacityDemand"); - if (capDemandString != null) serviceBuilder.setCapacityDemand(getInt(capDemandString)); + if (capDemandString != null) serviceBuilder.setDemand(getInt(capDemandString)); String startString = atts.getValue("earliestStart"); double start = parseTimeToDouble(startString); double end; @@ -155,13 +155,13 @@ public void startTag(String name, Attributes atts, Stack context) { String deliveryServiceTime = atts.getValue("deliveryServiceTime"); if (startPickup != null && endPickup != null) - shipmentBuilder.setPickupTimeWindow(TimeWindow.newInstance(parseTimeToDouble(startPickup), parseTimeToDouble(endPickup))); + shipmentBuilder.setPickupStartsTimeWindow(TimeWindow.newInstance(parseTimeToDouble(startPickup), parseTimeToDouble(endPickup))); if (startDelivery != null && endDelivery != null) - shipmentBuilder.setDeliveryTimeWindow(TimeWindow.newInstance(parseTimeToDouble(startDelivery), parseTimeToDouble(endDelivery))); + shipmentBuilder.setDeliveryStartsTimeWindow(TimeWindow.newInstance(parseTimeToDouble(startDelivery), parseTimeToDouble(endDelivery))); if (pickupServiceTime != null) - shipmentBuilder.setPickupServiceTime(parseTimeToDouble(pickupServiceTime)); + shipmentBuilder.setPickupDuration(parseTimeToDouble(pickupServiceTime)); if (deliveryServiceTime != null) - shipmentBuilder.setDeliveryServiceTime(parseTimeToDouble(deliveryServiceTime)); + shipmentBuilder.setDeliveryDuration(parseTimeToDouble(deliveryServiceTime)); currentShipment = shipmentBuilder.build(); currentShipments.put(atts.getValue(ID), currentShipment); diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarriersUtils.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarriersUtils.java index ed8267d89b0..61a7ff0c27b 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarriersUtils.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarriersUtils.java @@ -432,12 +432,12 @@ private static void createShipmentsFromServices(Carrier carrierWS, Carrier carri .newInstance(Id.create(carrierService.getId().toString(), CarrierShipment.class), depotServiceIsDeliveredFrom.get(carrierService.getId()), carrierService.getLocationLinkId(), carrierService.getDemand()) - .setDeliveryServiceTime(carrierService.getServiceDuration()) + .setDeliveryDuration(carrierService.getServiceDuration()) // .setPickupServiceTime(pickupServiceTime) //Not set yet, because in service we // have now time for that. Maybe change it later, kmt sep18 - .setDeliveryTimeWindow(carrierService.getServiceStartTimeWindow()) + .setDeliveryStartsTimeWindow(carrierService.getServiceStartTimeWindow()) // Limited to end of delivery timeWindow (pickup later than the latest delivery is not useful). - .setPickupTimeWindow(TimeWindow.newInstance(0.0, carrierService.getServiceStartTimeWindow().getEnd())) + .setPickupStartsTimeWindow(TimeWindow.newInstance(0.0, carrierService.getServiceStartTimeWindow().getEnd())) .build(); addShipment(carrierWS, carrierShipment); } diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierServiceStartEvent.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierServiceStartEvent.java index 2bf7829807e..02b24c5d56c 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierServiceStartEvent.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierServiceStartEvent.java @@ -85,7 +85,7 @@ public static CarrierServiceStartEvent convert(GenericEvent event) { Id locationLinkId = Id.createLinkId(attributes.get(ATTRIBUTE_LINK)); CarrierService service = CarrierService.Builder.newInstance(carrierServiceId, locationLinkId) .setServiceDuration(Double.parseDouble(attributes.get(CarrierEventAttributes.ATTRIBUTE_SERVICE_DURATION))) - .setCapacityDemand(Integer.parseInt(attributes.get(CarrierEventAttributes.ATTRIBUTE_CAPACITYDEMAND))) + .setDemand(Integer.parseInt(attributes.get(CarrierEventAttributes.ATTRIBUTE_CAPACITYDEMAND))) .build(); Id vehicleId = Id.create(attributes.get(ATTRIBUTE_VEHICLE), Vehicle.class); return new CarrierServiceStartEvent(time, carrierId, service, vehicleId); diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentDeliveryEndEvent.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentDeliveryEndEvent.java index 35fe77cdea6..672d959dc36 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentDeliveryEndEvent.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentDeliveryEndEvent.java @@ -83,7 +83,7 @@ public static CarrierShipmentDeliveryEndEvent convert(GenericEvent event) { Id shipmentTo = Id.createLinkId(attributes.get(ATTRIBUTE_LINK)); int size = Integer.parseInt(attributes.get(CarrierEventAttributes.ATTRIBUTE_CAPACITYDEMAND)); CarrierShipment shipment = CarrierShipment.Builder.newInstance(shipmentId, null, shipmentTo, size) - .setDeliveryServiceTime(Double.parseDouble(attributes.get(CarrierEventAttributes.ATTRIBUTE_DROPOFF_DURATION))) + .setDeliveryDuration(Double.parseDouble(attributes.get(CarrierEventAttributes.ATTRIBUTE_DROPOFF_DURATION))) .build(); Id vehicleId = Id.createVehicleId(attributes.get(ATTRIBUTE_VEHICLE)); return new CarrierShipmentDeliveryEndEvent(time, carrierId, shipment, vehicleId); diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentDeliveryStartEvent.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentDeliveryStartEvent.java index 300590482df..4635c159d5d 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentDeliveryStartEvent.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentDeliveryStartEvent.java @@ -84,7 +84,7 @@ public static CarrierShipmentDeliveryStartEvent convert(GenericEvent event) { Id shipmentTo = Id.createLinkId(attributes.get(ATTRIBUTE_LINK)); int size = Integer.parseInt(attributes.get(ATTRIBUTE_CAPACITYDEMAND)); CarrierShipment shipment = CarrierShipment.Builder.newInstance(shipmentId, null, shipmentTo, size) - .setDeliveryServiceTime(Double.parseDouble(attributes.get(ATTRIBUTE_DROPOFF_DURATION))) + .setDeliveryDuration(Double.parseDouble(attributes.get(ATTRIBUTE_DROPOFF_DURATION))) .build(); Id vehicleId = Id.createVehicleId(attributes.get(ATTRIBUTE_VEHICLE)); return new CarrierShipmentDeliveryStartEvent(time, carrierId, shipment, vehicleId); diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentPickupEndEvent.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentPickupEndEvent.java index 1a80be89293..601b39bbd37 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentPickupEndEvent.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentPickupEndEvent.java @@ -79,7 +79,7 @@ public static CarrierShipmentPickupEndEvent convert(GenericEvent event) { Id shipmentFrom = Id.createLinkId(attributes.get(ATTRIBUTE_LINK)); int shipmentSize = Integer.parseInt(attributes.get(ATTRIBUTE_CAPACITYDEMAND)); CarrierShipment shipment = CarrierShipment.Builder.newInstance(shipmentId, shipmentFrom, null, shipmentSize) - .setPickupServiceTime(Double.parseDouble(attributes.get(ATTRIBUTE_PICKUP_DURATION))) + .setPickupDuration(Double.parseDouble(attributes.get(ATTRIBUTE_PICKUP_DURATION))) .build(); Id vehicleId = Id.createVehicleId(attributes.get(ATTRIBUTE_VEHICLE)); return new CarrierShipmentPickupEndEvent(time, carrierId, shipment, vehicleId); diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentPickupStartEvent.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentPickupStartEvent.java index bbc912645fb..7154e2dba12 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentPickupStartEvent.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentPickupStartEvent.java @@ -77,7 +77,7 @@ public static CarrierShipmentPickupStartEvent convert(GenericEvent event) { Id shipmentFrom = Id.createLinkId(attributes.get(ATTRIBUTE_LINK)); int shipmentSize = Integer.parseInt(attributes.get(CarrierEventAttributes.ATTRIBUTE_CAPACITYDEMAND)); CarrierShipment shipment = CarrierShipment.Builder.newInstance(shipmentId, shipmentFrom, null, shipmentSize) - .setPickupServiceTime(Double.parseDouble(attributes.get(CarrierEventAttributes.ATTRIBUTE_PICKUP_DURATION))) + .setPickupDuration(Double.parseDouble(attributes.get(CarrierEventAttributes.ATTRIBUTE_PICKUP_DURATION))) .build(); Id vehicleId = Id.createVehicleId(attributes.get(ATTRIBUTE_VEHICLE)); return new CarrierShipmentPickupStartEvent(time, carrierId, shipment, vehicleId); diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/jsprit/MatsimJspritFactory.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/jsprit/MatsimJspritFactory.java index 5ec272cc6c2..0a056523f88 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/jsprit/MatsimJspritFactory.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/jsprit/MatsimJspritFactory.java @@ -88,11 +88,11 @@ static CarrierShipment createCarrierShipment(Shipment jspritShipment) { .newInstance(Id.create(jspritShipment.getId(), CarrierShipment.class), Id.createLinkId(jspritShipment.getPickupLocation().getId()), Id.createLinkId(jspritShipment.getDeliveryLocation().getId()), jspritShipment.getSize().get(0)) - .setDeliveryServiceTime(jspritShipment.getDeliveryServiceTime()) - .setDeliveryTimeWindow(org.matsim.freight.carriers.TimeWindow.newInstance(jspritShipment.getDeliveryTimeWindow().getStart(), + .setDeliveryDuration(jspritShipment.getDeliveryServiceTime()) + .setDeliveryStartsTimeWindow(org.matsim.freight.carriers.TimeWindow.newInstance(jspritShipment.getDeliveryTimeWindow().getStart(), jspritShipment.getDeliveryTimeWindow().getEnd())) - .setPickupServiceTime(jspritShipment.getPickupServiceTime()) - .setPickupTimeWindow(org.matsim.freight.carriers.TimeWindow.newInstance(jspritShipment.getPickupTimeWindow().getStart(), + .setPickupDuration(jspritShipment.getPickupServiceTime()) + .setPickupStartsTimeWindow(org.matsim.freight.carriers.TimeWindow.newInstance(jspritShipment.getPickupTimeWindow().getStart(), jspritShipment.getPickupTimeWindow().getEnd())) .build(); CarriersUtils.setSkills(carrierShipment, jspritShipment.getRequiredSkills().values()); @@ -184,7 +184,7 @@ static Service createJspritService(CarrierService carrierService, Coord location static CarrierService createCarrierService(Service jspritService) { CarrierService.Builder serviceBuilder = CarrierService.Builder.newInstance( Id.create(jspritService.getId(), CarrierService.class), Id.create(jspritService.getLocation().getId(), Link.class)); - serviceBuilder.setCapacityDemand(jspritService.getSize().get(0)); + serviceBuilder.setDemand(jspritService.getSize().get(0)); serviceBuilder.setServiceDuration(jspritService.getServiceDuration()); serviceBuilder.setServiceStartTimeWindow( org.matsim.freight.carriers.TimeWindow.newInstance(jspritService.getTimeWindow().getStart(), jspritService.getTimeWindow().getEnd())); diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/usecases/chessboard/FreightScenarioCreator.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/usecases/chessboard/FreightScenarioCreator.java index 3d291829b77..44a4dda7a5f 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/usecases/chessboard/FreightScenarioCreator.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/usecases/chessboard/FreightScenarioCreator.java @@ -101,7 +101,7 @@ private static void createCustomers(Carrier carrier, Network network) { for(int i=0;i<20;i++){ CarrierService.Builder serviceBuilder = CarrierService.Builder.newInstance(Id.create((i + 1),CarrierService.class), drawLocationLinkId(innerCityLinks, outerCityLinks)); - serviceBuilder.setCapacityDemand(1); + serviceBuilder.setDemand(1); serviceBuilder.setServiceDuration(5*60); serviceBuilder.setServiceStartTimeWindow(TimeWindow.newInstance(6*60*60, 15*60*60)); CarrierService carrierService = serviceBuilder.build(); diff --git a/contribs/freight/src/main/java/org/matsim/freight/logistics/resourceImplementations/CollectionCarrierScheduler.java b/contribs/freight/src/main/java/org/matsim/freight/logistics/resourceImplementations/CollectionCarrierScheduler.java index d91bf1c94f5..f6473a6fcad 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/logistics/resourceImplementations/CollectionCarrierScheduler.java +++ b/contribs/freight/src/main/java/org/matsim/freight/logistics/resourceImplementations/CollectionCarrierScheduler.java @@ -84,7 +84,7 @@ private CarrierService convertToCarrierService(LspShipment lspShipment) { Id serviceId = Id.create(lspShipment.getId().toString(), CarrierService.class); CarrierService carrierService = CarrierService.Builder.newInstance(serviceId, lspShipment.getFrom()) .setServiceStartTimeWindow(TimeWindow.newInstance(lspShipment.getPickupTimeWindow().getStart(), lspShipment.getPickupTimeWindow().getEnd())) - .setCapacityDemand(lspShipment.getSize()) + .setDemand(lspShipment.getSize()) .setServiceDuration(lspShipment.getDeliveryServiceTime()) .build(); //ensure that the ids of the lspShipment and the carrierService are the same. This is needed for updating the LSPShipmentPlan diff --git a/contribs/freight/src/main/java/org/matsim/freight/logistics/resourceImplementations/DistributionCarrierScheduler.java b/contribs/freight/src/main/java/org/matsim/freight/logistics/resourceImplementations/DistributionCarrierScheduler.java index 90abf00ea67..f3814a036e6 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/logistics/resourceImplementations/DistributionCarrierScheduler.java +++ b/contribs/freight/src/main/java/org/matsim/freight/logistics/resourceImplementations/DistributionCarrierScheduler.java @@ -184,7 +184,7 @@ private CarrierService convertToCarrierService(LspShipment lspShipment) { CarrierService carrierService = CarrierService.Builder.newInstance(serviceId, lspShipment.getTo()) //TODO TimeWindows are not set. This seems to be a problem. KMT'Aug'24 //If added here, we also need to decide what happens, if the vehicles StartTime (plus TT) is > TimeWindowEnd .... - .setCapacityDemand(lspShipment.getSize()) + .setDemand(lspShipment.getSize()) .setServiceDuration(lspShipment.getDeliveryServiceTime()) .build(); //ensure that the ids of the lspShipment and the carrierService are the same. This is needed for updating the LSPShipmentPlan @@ -207,7 +207,7 @@ private CarrierShipment convertToCarrierShipment(LspShipment lspShipment) { CarrierShipment carrierShipment = CarrierShipment.Builder.newInstance(serviceId, lspShipment.getFrom(), lspShipment.getTo(), lspShipment.getSize()) //TODO TimeWindows are not set. This seems to be a problem. KMT'Aug'24 //If added here, we also need to decide what happens, if the vehicles StartTime (plus TT) is > TimeWindowEnd .... - .setDeliveryServiceTime(lspShipment.getDeliveryServiceTime()) + .setDeliveryDuration(lspShipment.getDeliveryServiceTime()) .build(); //ensure that the ids of the lspShipment and the carrierShipment are the same. This is needed for updating the LSPShipmentPlan if (! Objects.equals(lspShipment.getId().toString(), carrierShipment.getId().toString())) { diff --git a/contribs/freight/src/main/java/org/matsim/freight/logistics/resourceImplementations/MainRunCarrierScheduler.java b/contribs/freight/src/main/java/org/matsim/freight/logistics/resourceImplementations/MainRunCarrierScheduler.java index 99f49186e11..abcc023fa20 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/logistics/resourceImplementations/MainRunCarrierScheduler.java +++ b/contribs/freight/src/main/java/org/matsim/freight/logistics/resourceImplementations/MainRunCarrierScheduler.java @@ -229,7 +229,7 @@ private CarrierService convertToCarrierService(LspShipment lspShipment) { Id.create(lspShipment.getId().toString(), CarrierService.class); CarrierService.Builder builder = CarrierService.Builder.newInstance(serviceId, resource.getEndLinkId()); - builder.setCapacityDemand(lspShipment.getSize()); + builder.setDemand(lspShipment.getSize()); builder.setServiceDuration(lspShipment.getDeliveryServiceTime()); return builder.build(); } diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarriersUtilsTest.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarriersUtilsTest.java index 9353d4d4034..7a784b4351d 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarriersUtilsTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarriersUtilsTest.java @@ -68,7 +68,7 @@ void testAddAndGetServiceToCarrier() { Carrier carrier = new CarrierImpl(Id.create("carrier", Carrier.class)); Id serviceId = Id.create("testVehicle", CarrierService.class); CarrierService service1 = CarrierService.Builder.newInstance(serviceId,Id.createLinkId("link0") ) - .setCapacityDemand(15).setServiceDuration(30).build(); + .setDemand(15).setServiceDuration(30).build(); //add Service CarriersUtils.addService(carrier, service1); diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/DistanceConstraintFromVehiclesFileTest.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/DistanceConstraintFromVehiclesFileTest.java index 43557b37a2a..e729e5360d6 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/DistanceConstraintFromVehiclesFileTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/DistanceConstraintFromVehiclesFileTest.java @@ -421,14 +421,14 @@ private static Carrier addTwoServicesToCarrier(Carrier carrier) { CarrierService service1 = CarrierService.Builder .newInstance(Id.create("Service1", CarrierService.class), Id.createLinkId("j(3,8)")) .setServiceDuration(20).setServiceStartTimeWindow(TimeWindow.newInstance(8 * 3600, 10 * 3600)) - .setCapacityDemand(40).build(); + .setDemand(40).build(); CarriersUtils.addService(carrier, service1); // Service 2 CarrierService service2 = CarrierService.Builder .newInstance(Id.create("Service2", CarrierService.class), Id.createLinkId("j(0,3)R")) .setServiceDuration(20).setServiceStartTimeWindow(TimeWindow.newInstance(8 * 3600, 10 * 3600)) - .setCapacityDemand(40).build(); + .setDemand(40).build(); CarriersUtils.addService(carrier, service2); return carrier; @@ -442,7 +442,7 @@ private static Carrier addThreeServicesToCarrier(Carrier carrier) { CarrierService service3 = CarrierService.Builder .newInstance(Id.create("Service3", CarrierService.class), Id.createLinkId("j(9,2)")) .setServiceDuration(20).setServiceStartTimeWindow(TimeWindow.newInstance(8 * 3600, 10 * 3600)) - .setCapacityDemand(40).build(); + .setDemand(40).build(); CarriersUtils.addService(carrier, service3); return carrier; diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/DistanceConstraintTest.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/DistanceConstraintTest.java index a375cceac46..3747a98a882 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/DistanceConstraintTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/DistanceConstraintTest.java @@ -614,14 +614,14 @@ private static Carrier addTwoServicesToCarrier(Carrier carrier) { CarrierService service1 = CarrierService.Builder .newInstance(Id.create("Service1", CarrierService.class), Id.createLinkId("j(3,8)")) .setServiceDuration(20).setServiceStartTimeWindow(TimeWindow.newInstance(8 * 3600, 10 * 3600)) - .setCapacityDemand(40).build(); + .setDemand(40).build(); CarriersUtils.addService(carrier, service1); // Service 2 CarrierService service2 = CarrierService.Builder .newInstance(Id.create("Service2", CarrierService.class), Id.createLinkId("j(0,3)R")) .setServiceDuration(20).setServiceStartTimeWindow(TimeWindow.newInstance(8 * 3600, 10 * 3600)) - .setCapacityDemand(40).build(); + .setDemand(40).build(); CarriersUtils.addService(carrier, service2); return carrier; @@ -631,14 +631,14 @@ private static Carrier addTwoShipmentsToCarrier(Carrier carrier) { // Shipment 1 CarrierShipment shipment1 = CarrierShipment.Builder .newInstance(Id.create("Shipment1", CarrierShipment.class), Id.createLinkId("i(1,8)"), Id.createLinkId("j(3,8)"), 40) - .setDeliveryServiceTime(20).setDeliveryTimeWindow(TimeWindow.newInstance(8 * 3600, 12 * 3600)) + .setDeliveryDuration(20).setDeliveryStartsTimeWindow(TimeWindow.newInstance(8 * 3600, 12 * 3600)) .build(); CarriersUtils.addShipment(carrier, shipment1); // Shipment 2 CarrierShipment shipment2 = CarrierShipment.Builder .newInstance(Id.create("Shipment2", CarrierShipment.class),Id.createLinkId("i(1,8)"), Id.createLinkId("j(0,3)R"), 40) - .setDeliveryServiceTime(20).setDeliveryTimeWindow(TimeWindow.newInstance(8 * 3600, 12 * 3600)) + .setDeliveryDuration(20).setDeliveryStartsTimeWindow(TimeWindow.newInstance(8 * 3600, 12 * 3600)) .build(); CarriersUtils.addShipment(carrier, shipment2); @@ -653,7 +653,7 @@ private static Carrier addThreeServicesToCarrier(Carrier carrier) { CarrierService service3 = CarrierService.Builder .newInstance(Id.create("Service3", CarrierService.class), Id.createLinkId("j(9,2)")) .setServiceDuration(20).setServiceStartTimeWindow(TimeWindow.newInstance(8 * 3600, 10 * 3600)) - .setCapacityDemand(40).build(); + .setDemand(40).build(); CarriersUtils.addService(carrier, service3); return carrier; diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/FixedCostsTest.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/FixedCostsTest.java index cf5060bf772..494c9f106e6 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/FixedCostsTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/FixedCostsTest.java @@ -200,7 +200,7 @@ final void test_carrier3CostsAreCorrectly() { private static CarrierService createMatsimService(String id, String to, int size) { return CarrierService.Builder.newInstance(Id.create(id, CarrierService.class), Id.create(to, Link.class)) - .setCapacityDemand(size) + .setDemand(size) .setServiceDuration(31.0) .setServiceStartTimeWindow(TimeWindow.newInstance(3601.0, 36001.0)) .build(); diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/MatsimTransformerTest.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/MatsimTransformerTest.java index 08929c96408..a2f8130db57 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/MatsimTransformerTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/MatsimTransformerTest.java @@ -122,7 +122,7 @@ void whenTransforming_matsimVehicle2jspritVehicle_itIsMadeCorrectly() { void whenTransforming_matsimService2jspritService_isMadeCorrectly() { CarrierService carrierService = CarrierService.Builder .newInstance(Id.create("serviceId", CarrierService.class), Id.create("locationId", Link.class)) - .setCapacityDemand(50).setServiceDuration(30.0) + .setDemand(50).setServiceDuration(30.0) .setServiceStartTimeWindow(TimeWindow.newInstance(10.0, 20.0)).build(); Service service = MatsimJspritFactory.createJspritService(carrierService, null); assertNotNull(service); @@ -161,8 +161,8 @@ void whenTransforming_matsimShipment2jspritShipment_isMadeCorrectly() { CarrierShipment carrierShipment = CarrierShipment.Builder .newInstance(Id.create("ShipmentId", CarrierShipment.class), Id.createLinkId("PickupLocationId"), Id.createLinkId("DeliveryLocationId"), 50) - .setPickupServiceTime(30.0).setPickupTimeWindow(TimeWindow.newInstance(10.0, 20.0)) - .setDeliveryServiceTime(40.0).setDeliveryTimeWindow(TimeWindow.newInstance(50.0, 60.0)).build(); + .setPickupDuration(30.0).setPickupStartsTimeWindow(TimeWindow.newInstance(10.0, 20.0)) + .setDeliveryDuration(40.0).setDeliveryStartsTimeWindow(TimeWindow.newInstance(50.0, 60.0)).build(); Shipment shipment = MatsimJspritFactory.createJspritShipment(carrierShipment); assertNotNull(shipment); assertEquals("PickupLocationId", shipment.getPickupLocation().getId()); @@ -333,10 +333,10 @@ void whenTransforming_matsimPlan2vehicleRouteSolution_itIsMadeCorrectly() { private ScheduledTour getMatsimServiceTour() { CarrierService s1 = CarrierService.Builder .newInstance(Id.create("serviceId", CarrierService.class), Id.create("to1", Link.class)) - .setCapacityDemand(20).build(); + .setDemand(20).build(); CarrierService s2 = CarrierService.Builder .newInstance(Id.create("serviceId2", CarrierService.class), Id.create("to2", Link.class)) - .setCapacityDemand(10).build(); + .setDemand(10).build(); CarrierVehicle matsimVehicle = getMatsimVehicle("matsimVehicle", "loc", getMatsimVehicleType()); double startTime = 15.0; Tour.Builder sTourBuilder = Tour.Builder.newInstance(Id.create("testTour", Tour.class)); @@ -391,8 +391,8 @@ private CarrierShipment getMatsimShipment(String id, String from, String to, int return CarrierShipment.Builder .newInstance(Id.create(id, CarrierShipment.class), Id.create(from, Link.class), Id.create(to, Link.class), size) - .setDeliveryServiceTime(30.0).setDeliveryTimeWindow(TimeWindow.newInstance(10.0, 20.0)) - .setPickupServiceTime(15.0).setPickupTimeWindow(TimeWindow.newInstance(1.0, 5.0)).build(); + .setDeliveryDuration(30.0).setDeliveryStartsTimeWindow(TimeWindow.newInstance(10.0, 20.0)) + .setPickupDuration(15.0).setPickupStartsTimeWindow(TimeWindow.newInstance(1.0, 5.0)).build(); } @Test @@ -503,11 +503,11 @@ private Carrier createCarrierWithServices() { carrier.setCarrierCapabilities(ccBuilder.build()); CarrierService carrierService1 = CarrierService.Builder .newInstance(Id.create("serviceId", CarrierService.class), Id.create("i(7,4)R", Link.class)) - .setCapacityDemand(20).setServiceDuration(10.0).build(); + .setDemand(20).setServiceDuration(10.0).build(); CarriersUtils.addService(carrier, carrierService1); CarrierService carrierService2 = CarrierService.Builder .newInstance(Id.create("serviceId2", CarrierService.class), Id.create("i(3,9)", Link.class)) - .setCapacityDemand(10).setServiceDuration(20.0).build(); + .setDemand(10).setServiceDuration(20.0).build(); CarriersUtils.addService(carrier, carrierService2); return carrier; } diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/SkillsIT.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/SkillsIT.java index 7da556872c2..379fb15486c 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/SkillsIT.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/SkillsIT.java @@ -161,10 +161,10 @@ private void addShipmentsRequiringDifferentSkills(Scenario scenario) { carrierLocation, Id.createLinkId("i(10,10)R"), 1) - .setPickupTimeWindow(TimeWindow.newInstance(0.0, Time.parseTime("24:00:00"))) - .setPickupServiceTime(Time.parseTime("00:05:00")) - .setDeliveryTimeWindow(TimeWindow.newInstance(0.0, Time.parseTime("24:00:00"))) - .setDeliveryServiceTime(Time.parseTime("00:05:00")) + .setPickupStartsTimeWindow(TimeWindow.newInstance(0.0, Time.parseTime("24:00:00"))) + .setPickupDuration(Time.parseTime("00:05:00")) + .setDeliveryStartsTimeWindow(TimeWindow.newInstance(0.0, Time.parseTime("24:00:00"))) + .setDeliveryDuration(Time.parseTime("00:05:00")) .build(); CarriersUtils.addSkill(shipmentOne, "skill 1"); CarriersUtils.addShipment(carrier, shipmentOne); @@ -174,10 +174,10 @@ private void addShipmentsRequiringDifferentSkills(Scenario scenario) { carrierLocation, Id.createLinkId("i(10,10)R"), 1) - .setPickupTimeWindow(TimeWindow.newInstance(0.0, Time.parseTime("24:00:00"))) - .setPickupServiceTime(Time.parseTime("00:05:00")) - .setDeliveryTimeWindow(TimeWindow.newInstance(0.0, Time.parseTime("24:00:00"))) - .setDeliveryServiceTime(Time.parseTime("00:05:00")) + .setPickupStartsTimeWindow(TimeWindow.newInstance(0.0, Time.parseTime("24:00:00"))) + .setPickupDuration(Time.parseTime("00:05:00")) + .setDeliveryStartsTimeWindow(TimeWindow.newInstance(0.0, Time.parseTime("24:00:00"))) + .setDeliveryDuration(Time.parseTime("00:05:00")) .build(); CarriersUtils.addSkill(shipmentTwo, "skill 2"); CarriersUtils.addShipment(carrier, shipmentTwo); @@ -190,10 +190,10 @@ private void addShipmentsRequiringSameSkills(Scenario scenario) { carrierLocation, Id.createLinkId("i(10,10)R"), 1) - .setPickupTimeWindow(TimeWindow.newInstance(0.0, Time.parseTime("24:00:00"))) - .setPickupServiceTime(Time.parseTime("00:05:00")) - .setDeliveryTimeWindow(TimeWindow.newInstance(0.0, Time.parseTime("24:00:00"))) - .setDeliveryServiceTime(Time.parseTime("00:05:00")) + .setPickupStartsTimeWindow(TimeWindow.newInstance(0.0, Time.parseTime("24:00:00"))) + .setPickupDuration(Time.parseTime("00:05:00")) + .setDeliveryStartsTimeWindow(TimeWindow.newInstance(0.0, Time.parseTime("24:00:00"))) + .setDeliveryDuration(Time.parseTime("00:05:00")) .build(); CarriersUtils.addSkill(shipmentOne, "skill 1"); CarriersUtils.addShipment(carrier, shipmentOne); @@ -203,10 +203,10 @@ private void addShipmentsRequiringSameSkills(Scenario scenario) { carrierLocation, Id.createLinkId("i(10,10)R"), 1) - .setPickupTimeWindow(TimeWindow.newInstance(0.0, Time.parseTime("24:00:00"))) - .setPickupServiceTime(Time.parseTime("00:05:00")) - .setDeliveryTimeWindow(TimeWindow.newInstance(0.0, Time.parseTime("24:00:00"))) - .setDeliveryServiceTime(Time.parseTime("00:05:00")) + .setPickupStartsTimeWindow(TimeWindow.newInstance(0.0, Time.parseTime("24:00:00"))) + .setPickupDuration(Time.parseTime("00:05:00")) + .setDeliveryStartsTimeWindow(TimeWindow.newInstance(0.0, Time.parseTime("24:00:00"))) + .setDeliveryDuration(Time.parseTime("00:05:00")) .build(); CarriersUtils.addSkill(shipmentTwo, "skill 1"); CarriersUtils.addShipment(carrier, shipmentTwo); diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/utils/CarrierControllerUtilsIT.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/utils/CarrierControllerUtilsIT.java index d7127bc80bf..249da6bf44b 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/utils/CarrierControllerUtilsIT.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/utils/CarrierControllerUtilsIT.java @@ -44,7 +44,6 @@ import org.matsim.freight.carriers.jsprit.NetworkRouter; import org.matsim.testcases.MatsimTestUtils; import org.matsim.vehicles.*; -import org.matsim.vehicles.EngineInformation.FuelType; //TODO: length of routes (legs) AND end time of route are missing. /** @@ -286,16 +285,16 @@ private static CarrierShipment createMatsimShipment(String id, String from, Stri } return CarrierShipment.Builder.newInstance(shipmentId, fromLinkId, toLinkId, size) - .setDeliveryServiceTime(30.0) - .setDeliveryTimeWindow(TimeWindow.newInstance(0.0, 36000.0)) - .setPickupServiceTime(5.0) - .setPickupTimeWindow(TimeWindow.newInstance(0.0, 7200.0)) + .setDeliveryDuration(30.0) + .setDeliveryStartsTimeWindow(TimeWindow.newInstance(0.0, 36000.0)) + .setPickupDuration(5.0) + .setPickupStartsTimeWindow(TimeWindow.newInstance(0.0, 7200.0)) .build(); } private static CarrierService createMatsimService(String id, String to, int size) { return CarrierService.Builder.newInstance(Id.create(id, CarrierService.class), Id.create(to, Link.class)) - .setCapacityDemand(size) + .setDemand(size) .setServiceDuration(31.0) .setServiceStartTimeWindow(TimeWindow.newInstance(0.0, 36001.0)) .build(); diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/utils/CarrierControllerUtilsTest.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/utils/CarrierControllerUtilsTest.java index f6bb1b42ee0..46c783e197c 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/utils/CarrierControllerUtilsTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/utils/CarrierControllerUtilsTest.java @@ -343,16 +343,16 @@ private static CarrierShipment createMatsimShipment(String id, String from, Stri } return CarrierShipment.Builder.newInstance(shipmentId, fromLinkId, toLinkId, size) - .setDeliveryServiceTime(30.0) - .setDeliveryTimeWindow(TimeWindow.newInstance(3600.0, 36000.0)) - .setPickupServiceTime(5.0) - .setPickupTimeWindow(TimeWindow.newInstance(0.0, 7200.0)) + .setDeliveryDuration(30.0) + .setDeliveryStartsTimeWindow(TimeWindow.newInstance(3600.0, 36000.0)) + .setPickupDuration(5.0) + .setPickupStartsTimeWindow(TimeWindow.newInstance(0.0, 7200.0)) .build(); } private static CarrierService createMatsimService(String id, String to, int size) { return CarrierService.Builder.newInstance(Id.create(id, CarrierService.class), Id.create(to, Link.class)) - .setCapacityDemand(size) + .setDemand(size) .setServiceDuration(31.0) .setServiceStartTimeWindow(TimeWindow.newInstance(3601.0, 36001.0)) .build(); diff --git a/contribs/freightreceiver/src/main/java/org/matsim/freight/receiver/ReceiverTriggersCarrierReplanningListener.java b/contribs/freightreceiver/src/main/java/org/matsim/freight/receiver/ReceiverTriggersCarrierReplanningListener.java index cf7b07dd8bd..28820157125 100644 --- a/contribs/freightreceiver/src/main/java/org/matsim/freight/receiver/ReceiverTriggersCarrierReplanningListener.java +++ b/contribs/freightreceiver/src/main/java/org/matsim/freight/receiver/ReceiverTriggersCarrierReplanningListener.java @@ -81,8 +81,8 @@ public void notifyIterationStarts(IterationStartsEvent event) { order.getReceiver().getLinkId(), (int) (Math.round(order.getDailyOrderQuantity()*order.getProduct().getProductType().getRequiredCapacity())) ); CarrierShipment newShipment = builder - .setDeliveryServiceTime( order.getServiceDuration() ) - .setDeliveryTimeWindow( receiverPlan.getTimeWindows().get( 0 ) ) + .setDeliveryDuration( order.getServiceDuration() ) + .setDeliveryStartsTimeWindow( receiverPlan.getTimeWindows().get( 0 ) ) // TODO This only looks at the FIRST time window. This may need revision once we handle multiple // time windows. .build(); diff --git a/contribs/freightreceiver/src/main/java/org/matsim/freight/receiver/run/chessboard/ReceiverChessboardScenario.java b/contribs/freightreceiver/src/main/java/org/matsim/freight/receiver/run/chessboard/ReceiverChessboardScenario.java index fd036695370..34b74c242d4 100644 --- a/contribs/freightreceiver/src/main/java/org/matsim/freight/receiver/run/chessboard/ReceiverChessboardScenario.java +++ b/contribs/freightreceiver/src/main/java/org/matsim/freight/receiver/run/chessboard/ReceiverChessboardScenario.java @@ -228,8 +228,8 @@ public static void convertReceiverOrdersToInitialCarrierShipments(Carriers carri LOG.warn("Multiple time windows set. Only the first is used"); } - CarrierShipment shipment = shpBuilder.setDeliveryServiceTime(order.getServiceDuration()) - .setDeliveryTimeWindow(receiverPlan.getTimeWindows().get(0)) + CarrierShipment shipment = shpBuilder.setDeliveryDuration(order.getServiceDuration()) + .setDeliveryStartsTimeWindow(receiverPlan.getTimeWindows().get(0)) .build(); carriers.getCarriers().get(receiverOrder.getCarrierId()).getShipments().put(shipment.getId(), shipment); } From 8c5e2aacb1c9175f82c05ab1bfd4e58e93c99667 Mon Sep 17 00:00:00 2001 From: Kai Martins-Turner Date: Fri, 20 Dec 2024 14:51:31 +0100 Subject: [PATCH 15/18] rename getters and setters to make it more consistent. old setters remain as deprecated --- .../DemandReaderFromCSV.java | 17 +-- .../DemandReaderFromCSVTest.java | 72 ++++++------- .../carriers/CarrierPlanXmlWriterV2_1.java | 14 +-- .../freight/carriers/CarrierShipment.java | 101 +++++++++++++++--- .../org/matsim/freight/carriers/Tour.java | 8 +- .../CarrierShipmentDeliveryEndEvent.java | 2 +- .../CarrierShipmentDeliveryStartEvent.java | 2 +- .../events/CarrierShipmentPickupEndEvent.java | 2 +- .../CarrierShipmentPickupStartEvent.java | 2 +- .../carriers/jsprit/MatsimJspritFactory.java | 24 ++--- .../multipleChains/MultipleChainsUtils.java | 8 +- .../jsprit/MatsimTransformerTest.java | 12 +-- .../utils/CarrierControllerUtilsTest.java | 48 ++++----- .../FreightAnalysisShipmentTracking.java | 20 ++-- 14 files changed, 203 insertions(+), 129 deletions(-) diff --git a/contribs/application/src/main/java/org/matsim/freightDemandGeneration/DemandReaderFromCSV.java b/contribs/application/src/main/java/org/matsim/freightDemandGeneration/DemandReaderFromCSV.java index 4355e7b938b..2ebf3060e2e 100644 --- a/contribs/application/src/main/java/org/matsim/freightDemandGeneration/DemandReaderFromCSV.java +++ b/contribs/application/src/main/java/org/matsim/freightDemandGeneration/DemandReaderFromCSV.java @@ -1189,10 +1189,11 @@ private static void combineSimilarJobs(Scenario scenario) { CarrierShipment thisShipment = thisCarrier.getShipments().get(thisShipmentId); if (baseShipment.getId() != thisShipment.getId() && baseShipment.getFrom() == thisShipment.getFrom() - && baseShipment.getTo() == thisShipment.getTo() - && baseShipment.getPickupTimeWindow() == thisShipment.getPickupTimeWindow() - && baseShipment.getDeliveryTimeWindow() == thisShipment.getDeliveryTimeWindow()) - shipmentsToConnect.put(thisShipmentId, thisShipment); + && baseShipment.getTo() == thisShipment.getTo()) { + if (baseShipment.getPickupStartsTimeWindow() == thisShipment.getPickupStartsTimeWindow()) { + if (baseShipment.getDeliveryStartsTimeWindow() == thisShipment.getDeliveryStartsTimeWindow()) shipmentsToConnect.put(thisShipmentId, thisShipment); + } + } } } Id idNewShipment = baseShipment.getId(); @@ -1201,16 +1202,16 @@ private static void combineSimilarJobs(Scenario scenario) { double serviceTimeDelivery = 0; for (CarrierShipment carrierShipment : shipmentsToConnect.values()) { demandForThisLink = demandForThisLink + carrierShipment.getDemand(); - serviceTimePickup = serviceTimePickup + carrierShipment.getPickupServiceTime(); - serviceTimeDelivery = serviceTimeDelivery + carrierShipment.getDeliveryServiceTime(); + serviceTimePickup = serviceTimePickup + carrierShipment.getPickupDuration(); + serviceTimeDelivery = serviceTimeDelivery + carrierShipment.getDeliveryDuration(); shipmentsToRemove.put(carrierShipment.getId(), carrierShipment); } CarrierShipment newShipment = CarrierShipment.Builder .newInstance(idNewShipment, baseShipment.getFrom(), baseShipment.getTo(), demandForThisLink) .setPickupDuration(serviceTimePickup) - .setPickupStartsTimeWindow(baseShipment.getPickupTimeWindow()) + .setPickupStartsTimeWindow(baseShipment.getPickupStartsTimeWindow()) .setDeliveryDuration(serviceTimeDelivery) - .setDeliveryStartsTimeWindow(baseShipment.getDeliveryTimeWindow()).build(); + .setDeliveryStartsTimeWindow(baseShipment.getDeliveryStartsTimeWindow()).build(); shipmentsToAdd.add(newShipment); } } diff --git a/contribs/application/src/test/java/org/matsim/freightDemandGeneration/DemandReaderFromCSVTest.java b/contribs/application/src/test/java/org/matsim/freightDemandGeneration/DemandReaderFromCSVTest.java index 0658741aacd..d27e5d5a202 100644 --- a/contribs/application/src/test/java/org/matsim/freightDemandGeneration/DemandReaderFromCSVTest.java +++ b/contribs/application/src/test/java/org/matsim/freightDemandGeneration/DemandReaderFromCSVTest.java @@ -104,10 +104,10 @@ void demandCreationWithSampleWithChangeNumberOfLocations() throws IOException { countShipmentsWithCertainDemand.merge((Integer) shipment.getDemand(), 1, Integer::sum); countDemand = countDemand + shipment.getDemand(); Assertions.assertEquals(5, shipment.getDemand()); - Assertions.assertEquals(2000, shipment.getPickupServiceTime(), MatsimTestUtils.EPSILON); - Assertions.assertEquals(1250, shipment.getDeliveryServiceTime(), MatsimTestUtils.EPSILON); - Assertions.assertEquals(TimeWindow.newInstance(8000, 50000), shipment.getPickupTimeWindow()); - Assertions.assertEquals(TimeWindow.newInstance(10000, 60000), shipment.getDeliveryTimeWindow()); + Assertions.assertEquals(2000, shipment.getPickupDuration(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(1250, shipment.getDeliveryDuration(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(TimeWindow.newInstance(8000, 50000), shipment.getPickupStartsTimeWindow()); + Assertions.assertEquals(TimeWindow.newInstance(10000, 60000), shipment.getDeliveryStartsTimeWindow()); locationsPerShipmentElement.computeIfAbsent("ShipmentElement1_pickup", (k) -> new HashSet<>()) .add(shipment.getFrom().toString()); locationsPerShipmentElement.computeIfAbsent("ShipmentElement1_delivery", (k) -> new HashSet<>()) @@ -171,10 +171,10 @@ void demandCreationWithSampleWithDemandOnLocation() throws IOException { countShipmentsWithCertainDemand.merge((Integer) shipment.getDemand(), 1, Integer::sum); countDemand = countDemand + shipment.getDemand(); Assertions.assertEquals(10, shipment.getDemand()); - Assertions.assertEquals(4000, shipment.getPickupServiceTime(), MatsimTestUtils.EPSILON); - Assertions.assertEquals(2500, shipment.getDeliveryServiceTime(), MatsimTestUtils.EPSILON); - Assertions.assertEquals(TimeWindow.newInstance(8000, 50000), shipment.getPickupTimeWindow()); - Assertions.assertEquals(TimeWindow.newInstance(10000, 60000), shipment.getDeliveryTimeWindow()); + Assertions.assertEquals(4000, shipment.getPickupDuration(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(2500, shipment.getDeliveryDuration(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(TimeWindow.newInstance(8000, 50000), shipment.getPickupStartsTimeWindow()); + Assertions.assertEquals(TimeWindow.newInstance(10000, 60000), shipment.getDeliveryStartsTimeWindow()); locationsPerShipmentElement.computeIfAbsent("ShipmentElement1_pickup", (k) -> new HashSet<>()) .add(shipment.getFrom().toString()); locationsPerShipmentElement.computeIfAbsent("ShipmentElement1_delivery", (k) -> new HashSet<>()) @@ -238,10 +238,10 @@ void demandCreationWithSampleWithDemandOnLocationWithCombiningJobs() throws IOEx countShipmentsWithCertainDemand.merge((Integer) shipment.getDemand(), 1, Integer::sum); countDemand = countDemand + shipment.getDemand(); Assertions.assertEquals(10, shipment.getDemand()); - Assertions.assertEquals(4000, shipment.getPickupServiceTime(), MatsimTestUtils.EPSILON); - Assertions.assertEquals(2500, shipment.getDeliveryServiceTime(), MatsimTestUtils.EPSILON); - Assertions.assertEquals(TimeWindow.newInstance(8000, 50000), shipment.getPickupTimeWindow()); - Assertions.assertEquals(TimeWindow.newInstance(10000, 60000), shipment.getDeliveryTimeWindow()); + Assertions.assertEquals(4000, shipment.getPickupDuration(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(2500, shipment.getDeliveryDuration(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(TimeWindow.newInstance(8000, 50000), shipment.getPickupStartsTimeWindow()); + Assertions.assertEquals(TimeWindow.newInstance(10000, 60000), shipment.getDeliveryStartsTimeWindow()); locationsPerShipmentElement.computeIfAbsent("ShipmentElement1_pickup", (k) -> new HashSet<>()) .add(shipment.getFrom().toString()); locationsPerShipmentElement.computeIfAbsent("ShipmentElement1_delivery", (k) -> new HashSet<>()) @@ -308,10 +308,10 @@ void demandCreationNoSampling() throws IOException { countShipmentsWithCertainDemand.merge((Integer) shipment.getDemand(), 1, Integer::sum); countDemand = countDemand + shipment.getDemand(); Assertions.assertEquals(10, shipment.getDemand()); - Assertions.assertEquals(4000, shipment.getPickupServiceTime(), MatsimTestUtils.EPSILON); - Assertions.assertEquals(2500, shipment.getDeliveryServiceTime(), MatsimTestUtils.EPSILON); - Assertions.assertEquals(TimeWindow.newInstance(8000, 50000), shipment.getPickupTimeWindow()); - Assertions.assertEquals(TimeWindow.newInstance(10000, 60000), shipment.getDeliveryTimeWindow()); + Assertions.assertEquals(4000, shipment.getPickupDuration(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(2500, shipment.getDeliveryDuration(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(TimeWindow.newInstance(8000, 50000), shipment.getPickupStartsTimeWindow()); + Assertions.assertEquals(TimeWindow.newInstance(10000, 60000), shipment.getDeliveryStartsTimeWindow()); locationsPerShipmentElement.computeIfAbsent("ShipmentElement1_pickup", (k) -> new HashSet<>()) .add(shipment.getFrom().toString()); locationsPerShipmentElement.computeIfAbsent("ShipmentElement1_delivery", (k) -> new HashSet<>()) @@ -525,29 +525,29 @@ private static void checkCarrier1and2(Scenario scenario, Network network, ShpOpt countShipmentsWithCertainDemand.merge((Integer) shipment.getDemand(), 1, Integer::sum); countDemand = countDemand + shipment.getDemand(); if (shipment.getDemand() == 0) { - Assertions.assertEquals(300, shipment.getPickupServiceTime(), MatsimTestUtils.EPSILON); - Assertions.assertEquals(350, shipment.getDeliveryServiceTime(), MatsimTestUtils.EPSILON); - Assertions.assertEquals(TimeWindow.newInstance(10000, 45000), shipment.getPickupTimeWindow()); - Assertions.assertEquals(TimeWindow.newInstance(11000, 44000), shipment.getDeliveryTimeWindow()); + Assertions.assertEquals(300, shipment.getPickupDuration(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(350, shipment.getDeliveryDuration(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(TimeWindow.newInstance(10000, 45000), shipment.getPickupStartsTimeWindow()); + Assertions.assertEquals(TimeWindow.newInstance(11000, 44000), shipment.getDeliveryStartsTimeWindow()); locationsPerShipmentElement.computeIfAbsent("ShipmentElement1_pickup", (k) -> new HashSet<>()) .add(shipment.getFrom().toString()); locationsPerShipmentElement.computeIfAbsent("ShipmentElement1_delivery", (k) -> new HashSet<>()) .add(shipment.getTo().toString()); } else if (shipment.getDemand() == 2) { - Assertions.assertEquals(400, shipment.getPickupServiceTime(), MatsimTestUtils.EPSILON); - Assertions.assertEquals(400, shipment.getDeliveryServiceTime(), MatsimTestUtils.EPSILON); - Assertions.assertEquals(TimeWindow.newInstance(11000, 44000), shipment.getPickupTimeWindow()); - Assertions.assertEquals(TimeWindow.newInstance(20000, 40000), shipment.getDeliveryTimeWindow()); + Assertions.assertEquals(400, shipment.getPickupDuration(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(400, shipment.getDeliveryDuration(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(TimeWindow.newInstance(11000, 44000), shipment.getPickupStartsTimeWindow()); + Assertions.assertEquals(TimeWindow.newInstance(20000, 40000), shipment.getDeliveryStartsTimeWindow()); locationsPerShipmentElement.computeIfAbsent("ShipmentElement2_pickup", (k) -> new HashSet<>()) .add(shipment.getFrom().toString()); locationsPerShipmentElement.computeIfAbsent("ShipmentElement2_delivery", (k) -> new HashSet<>()) .add(shipment.getTo().toString()); } else { if (shipment.getDemand() == 3) { - Assertions.assertEquals(600, shipment.getPickupServiceTime(), MatsimTestUtils.EPSILON); - Assertions.assertEquals(600, shipment.getDeliveryServiceTime(), MatsimTestUtils.EPSILON); - Assertions.assertEquals(TimeWindow.newInstance(11000, 44000), shipment.getPickupTimeWindow()); - Assertions.assertEquals(TimeWindow.newInstance(20000, 40000), shipment.getDeliveryTimeWindow()); + Assertions.assertEquals(600, shipment.getPickupDuration(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(600, shipment.getDeliveryDuration(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(TimeWindow.newInstance(11000, 44000), shipment.getPickupStartsTimeWindow()); + Assertions.assertEquals(TimeWindow.newInstance(20000, 40000), shipment.getDeliveryStartsTimeWindow()); locationsPerShipmentElement.computeIfAbsent("ShipmentElement2_pickup", (k) -> new HashSet<>()) .add(shipment.getFrom().toString()); locationsPerShipmentElement.computeIfAbsent("ShipmentElement2_delivery", (k) -> new HashSet<>()) @@ -624,19 +624,19 @@ private static void checkCarrier1and2WithCombiningJobs(Scenario scenario, Networ countShipmentsWithCertainDemand.merge((Integer) shipment.getDemand(), 1, Integer::sum); countDemand = countDemand + shipment.getDemand(); if (shipment.getDemand() == 0) { - Assertions.assertEquals(300, shipment.getPickupServiceTime(), MatsimTestUtils.EPSILON); - Assertions.assertEquals(350, shipment.getDeliveryServiceTime(), MatsimTestUtils.EPSILON); - Assertions.assertEquals(TimeWindow.newInstance(10000, 45000), shipment.getPickupTimeWindow()); - Assertions.assertEquals(TimeWindow.newInstance(11000, 44000), shipment.getDeliveryTimeWindow()); + Assertions.assertEquals(300, shipment.getPickupDuration(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(350, shipment.getDeliveryDuration(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(TimeWindow.newInstance(10000, 45000), shipment.getPickupStartsTimeWindow()); + Assertions.assertEquals(TimeWindow.newInstance(11000, 44000), shipment.getDeliveryStartsTimeWindow()); locationsPerShipmentElement.computeIfAbsent("ShipmentElement1_pickup", (k) -> new HashSet<>()) .add(shipment.getFrom().toString()); locationsPerShipmentElement.computeIfAbsent("ShipmentElement1_delivery", (k) -> new HashSet<>()) .add(shipment.getTo().toString()); } else { - Assertions.assertEquals(shipment.getDemand() * 200, shipment.getPickupServiceTime(), MatsimTestUtils.EPSILON); - Assertions.assertEquals(shipment.getDemand() * 200, shipment.getDeliveryServiceTime(), MatsimTestUtils.EPSILON); - Assertions.assertEquals(TimeWindow.newInstance(11000, 44000), shipment.getPickupTimeWindow()); - Assertions.assertEquals(TimeWindow.newInstance(20000, 40000), shipment.getDeliveryTimeWindow()); + Assertions.assertEquals(shipment.getDemand() * 200, shipment.getPickupDuration(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(shipment.getDemand() * 200, shipment.getDeliveryDuration(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(TimeWindow.newInstance(11000, 44000), shipment.getPickupStartsTimeWindow()); + Assertions.assertEquals(TimeWindow.newInstance(20000, 40000), shipment.getDeliveryStartsTimeWindow()); locationsPerShipmentElement.computeIfAbsent("ShipmentElement2_pickup", (k) -> new HashSet<>()) .add(shipment.getFrom().toString()); locationsPerShipmentElement.computeIfAbsent("ShipmentElement2_delivery", (k) -> new HashSet<>()) diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierPlanXmlWriterV2_1.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierPlanXmlWriterV2_1.java index 421ef4b2754..5641fbc85f9 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierPlanXmlWriterV2_1.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierPlanXmlWriterV2_1.java @@ -157,17 +157,17 @@ private void writeShipments(Carrier carrier, BufferedWriter writer) { } private void writeShipment(CarrierShipment s, Id shipmentId, boolean closeElement, boolean lineBreak) { - this.writeStartTag(SHIPMENT, List.of( + this.writeStartTag(SHIPMENT, List.of( createTuple(ID, shipmentId.toString()), createTuple(FROM, s.getFrom().toString()), createTuple(TO, s.getTo().toString()), createTuple(SIZE, s.getDemand()), - createTuple(START_PICKUP, getTime(s.getPickupTimeWindow().getStart())), - createTuple(END_PICKUP, getTime(s.getPickupTimeWindow().getEnd())), - createTuple(START_DELIVERY, getTime(s.getDeliveryTimeWindow().getStart())), - createTuple(END_DELIVERY, getTime(s.getDeliveryTimeWindow().getEnd())), - createTuple(PICKUP_SERVICE_TIME, getTime(s.getPickupServiceTime())), - createTuple(DELIVERY_SERVICE_TIME, getTime(s.getDeliveryServiceTime()))), closeElement, lineBreak + createTuple(START_PICKUP, getTime(s.getPickupStartsTimeWindow().getStart())), + createTuple(END_PICKUP, getTime(s.getPickupStartsTimeWindow().getEnd())), + createTuple(START_DELIVERY, getTime(s.getDeliveryStartsTimeWindow().getStart())), + createTuple(END_DELIVERY, getTime(s.getDeliveryStartsTimeWindow().getEnd())), + createTuple(PICKUP_SERVICE_TIME, getTime(s.getPickupDuration())), + createTuple(DELIVERY_SERVICE_TIME, getTime(s.getDeliveryDuration()))), closeElement, lineBreak ); } diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierShipment.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierShipment.java index e39b82afa5a..1bdb0d390e2 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierShipment.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierShipment.java @@ -241,19 +241,35 @@ private CarrierShipment(Builder builder) { deliveryStartsTimeWindow = builder.deliveryStartsTimeWindow; } - public double getPickupServiceTime() { + //* getters and setters + + public double getPickupDuration() { return pickupDuration; } - public void setPickupServiceTime(double pickupDuration) { - this.pickupDuration = pickupDuration; + public double getDeliveryDuration() { + return deliveryDuration; } - public double getDeliveryServiceTime() { - return deliveryDuration; + /** + * Do we really need the setter? We do have it in the builder. + * I do not see, why we should be able to update it, since most of the values are immutable. + * @deprecated Consider setting it using the Builder. This will maybe be removed and the field gets immutable.. + * kturner, dec'24 + */ + @Deprecated(since = "dec'24") + public void setPickupDuration(double pickupDuration) { + this.pickupDuration = pickupDuration; } - public void setDeliveryServiceTime(double deliveryDuration) { + /** + * Do we really need the setter? We do have it in the builder. + * I do not see, why we should be able to update it, since most of the values are immutable. + * @deprecated Consider setting it using the Builder. This will maybe be removed and the field gets immutable.. + * kturner, dec'24 + */ + @Deprecated(since = "dec'24") + public void setDeliveryDuration(double deliveryDuration) { this.deliveryDuration = deliveryDuration; } @@ -270,14 +286,6 @@ public Id getTo() { return deliveryLinkId; } - /** - * @deprecated please inline and use {@link #getDemand()} instead - */ - @Deprecated(since = "dec'24") - public int getSize() { - return getDemand(); - } - /** * @return the demand (size; capacity needed) of the shipment. */ @@ -286,11 +294,11 @@ public int getDemand() { return demand; } - public TimeWindow getPickupTimeWindow() { + public TimeWindow getPickupStartsTimeWindow() { return pickupStartsTimeWindow; } - public TimeWindow getDeliveryTimeWindow() { + public TimeWindow getDeliveryStartsTimeWindow() { return deliveryStartsTimeWindow; } @@ -299,6 +307,67 @@ public Attributes getAttributes() { return attributes; } + //*** deprecated methods *** + + /** + * @deprecated please inline and use {@link #getDemand()} instead + */ + @Deprecated(since = "dec'24") + public int getSize() { + return getDemand(); + } + + /** + * @deprecated please inline and use {@link #getPickupStartsTimeWindow()} instead + */ + @Deprecated(since = "dec'24") + public TimeWindow getPickupTimeWindow() { + return getPickupStartsTimeWindow(); + } + + + /** + * @deprecated please inline and use {@link #getDeliveryStartsTimeWindow()} instead + */ + @Deprecated(since = "dec'24") + public TimeWindow getDeliveryTimeWindow() { + return getDeliveryStartsTimeWindow(); + } + + /** + * @deprecated please inline and use {@link #getPickupDuration()} instead + */ + @Deprecated(since = "dec'24") + public double getPickupServiceTime() { + return getPickupDuration(); + } + + /** + * @deprecated please inline and use {@link #setPickupDuration(double)} instead + */ + @Deprecated(since = "dec'24") + public void setPickupServiceTime(double pickupDuration) { + setPickupDuration(pickupDuration); + } + + /** + * @deprecated please inline and use {@link #getDeliveryDuration()} instead + */ + @Deprecated(since = "dec'24") + public double getDeliveryServiceTime() { + return getDeliveryDuration(); + } + + /** + * @deprecated please inline and use {@link #setDeliveryDuration(double)} instead + */ + @Deprecated(since = "dec'24") + public void setDeliveryServiceTime(double deliveryDuration) { + setDeliveryDuration(deliveryDuration); + } + + // *** general methods *** + @Override public String toString() { return "[id= "+ id.toString() + "][hash=" + this.hashCode() + "][from=" + pickupLinkId.toString() + "][to=" + deliveryLinkId.toString() + "][size=" + demand + "][pickupServiceTime=" + pickupDuration + "]" + diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/Tour.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/Tour.java index aaf05ebbecc..41325eb3920 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/Tour.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/Tour.java @@ -539,7 +539,7 @@ public String getActivityType() { @Override public TimeWindow getTimeWindow() { - return shipment.getPickupTimeWindow(); + return shipment.getPickupStartsTimeWindow(); } @Override @@ -549,7 +549,7 @@ public Id getLocation() { @Override public double getDuration() { - return shipment.getPickupServiceTime(); + return shipment.getPickupDuration(); } @Override @@ -592,7 +592,7 @@ public Delivery(CarrierShipment shipment) { @Override public TimeWindow getTimeWindow() { - return shipment.getDeliveryTimeWindow(); + return shipment.getDeliveryStartsTimeWindow(); } @Override @@ -607,7 +607,7 @@ public Id getLocation() { @Override public double getDuration() { - return shipment.getDeliveryServiceTime(); + return shipment.getDeliveryDuration(); } @Override diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentDeliveryEndEvent.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentDeliveryEndEvent.java index 672d959dc36..fbd9e4ddff8 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentDeliveryEndEvent.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentDeliveryEndEvent.java @@ -46,7 +46,7 @@ public class CarrierShipmentDeliveryEndEvent extends AbstractCarrierEvent { public CarrierShipmentDeliveryEndEvent(double time, Id carrierId, CarrierShipment shipment, Id vehicleId) { super(time, carrierId, shipment.getTo(), vehicleId); this.shipmentId = shipment.getId(); - this.deliveryDuration = shipment.getDeliveryServiceTime(); + this.deliveryDuration = shipment.getDeliveryDuration(); this.capacityDemand = shipment.getDemand(); } diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentDeliveryStartEvent.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentDeliveryStartEvent.java index 4635c159d5d..355b76782b0 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentDeliveryStartEvent.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentDeliveryStartEvent.java @@ -47,7 +47,7 @@ public class CarrierShipmentDeliveryStartEvent extends AbstractCarrierEvent { public CarrierShipmentDeliveryStartEvent(double time, Id carrierId, CarrierShipment shipment, Id vehicleId) { super(time, carrierId, shipment.getTo(), vehicleId); this.shipmentId = shipment.getId(); - this.deliveryDuration = shipment.getDeliveryServiceTime(); + this.deliveryDuration = shipment.getDeliveryDuration(); this.capacityDemand = shipment.getDemand(); } diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentPickupEndEvent.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentPickupEndEvent.java index 601b39bbd37..1f669809087 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentPickupEndEvent.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentPickupEndEvent.java @@ -48,7 +48,7 @@ public class CarrierShipmentPickupEndEvent extends AbstractCarrierEvent { public CarrierShipmentPickupEndEvent(double time, Id carrierId, CarrierShipment shipment, Id vehicleId) { super(time, carrierId, shipment.getFrom(), vehicleId); this.shipmentId = shipment.getId(); - this.pickupDuration = shipment.getPickupServiceTime(); + this.pickupDuration = shipment.getPickupDuration(); this.capacityDemand = shipment.getDemand(); } diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentPickupStartEvent.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentPickupStartEvent.java index 7154e2dba12..9e9bb519ae1 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentPickupStartEvent.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentPickupStartEvent.java @@ -46,7 +46,7 @@ public class CarrierShipmentPickupStartEvent extends AbstractCarrierEvent { public CarrierShipmentPickupStartEvent(double time, Id carrierId, CarrierShipment shipment, Id vehicleId) { super(time, carrierId, shipment.getFrom(), vehicleId); this.shipmentId = shipment.getId(); - this.pickupDuration = shipment.getPickupServiceTime(); + this.pickupDuration = shipment.getPickupDuration(); this.capacityDemand = shipment.getDemand(); } diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/jsprit/MatsimJspritFactory.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/jsprit/MatsimJspritFactory.java index 0a056523f88..986eb953391 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/jsprit/MatsimJspritFactory.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/jsprit/MatsimJspritFactory.java @@ -109,15 +109,15 @@ static CarrierShipment createCarrierShipment(Shipment jspritShipment) { static Shipment createJspritShipment(CarrierShipment carrierShipment) { Shipment.Builder shipmentBuilder = Shipment.Builder.newInstance(carrierShipment.getId().toString()) .setDeliveryLocation(Location.newInstance(carrierShipment.getTo().toString())) - .setDeliveryServiceTime(carrierShipment.getDeliveryServiceTime()) + .setDeliveryServiceTime(carrierShipment.getDeliveryDuration()) .setDeliveryTimeWindow(com.graphhopper.jsprit.core.problem.solution.route.activity.TimeWindow - .newInstance(carrierShipment.getDeliveryTimeWindow().getStart(), - carrierShipment.getDeliveryTimeWindow().getEnd())) - .setPickupServiceTime(carrierShipment.getPickupServiceTime()) + .newInstance(carrierShipment.getDeliveryStartsTimeWindow().getStart(), + carrierShipment.getDeliveryStartsTimeWindow().getEnd())) + .setPickupServiceTime(carrierShipment.getPickupDuration()) .setPickupLocation(Location.newInstance(carrierShipment.getFrom().toString())) .setPickupTimeWindow(com.graphhopper.jsprit.core.problem.solution.route.activity.TimeWindow.newInstance( - carrierShipment.getPickupTimeWindow().getStart(), - carrierShipment.getPickupTimeWindow().getEnd())) + carrierShipment.getPickupStartsTimeWindow().getStart(), + carrierShipment.getPickupStartsTimeWindow().getEnd())) .addSizeDimension(0, carrierShipment.getDemand()); for (String skill : CarriersUtils.getSkills(carrierShipment)) { shipmentBuilder.addRequiredSkill(skill); @@ -141,14 +141,14 @@ static Shipment createJspritShipment(CarrierShipment carrierShipment, Coord from Location toLocation = toLocationBuilder.build(); Shipment.Builder shipmentBuilder = Shipment.Builder.newInstance(carrierShipment.getId().toString()) - .setDeliveryLocation(toLocation).setDeliveryServiceTime(carrierShipment.getDeliveryServiceTime()) + .setDeliveryLocation(toLocation).setDeliveryServiceTime(carrierShipment.getDeliveryDuration()) .setDeliveryTimeWindow(com.graphhopper.jsprit.core.problem.solution.route.activity.TimeWindow - .newInstance(carrierShipment.getDeliveryTimeWindow().getStart(), - carrierShipment.getDeliveryTimeWindow().getEnd())) - .setPickupServiceTime(carrierShipment.getPickupServiceTime()).setPickupLocation(fromLocation) + .newInstance(carrierShipment.getDeliveryStartsTimeWindow().getStart(), + carrierShipment.getDeliveryStartsTimeWindow().getEnd())) + .setPickupServiceTime(carrierShipment.getPickupDuration()).setPickupLocation(fromLocation) .setPickupTimeWindow(com.graphhopper.jsprit.core.problem.solution.route.activity.TimeWindow.newInstance( - carrierShipment.getPickupTimeWindow().getStart(), - carrierShipment.getPickupTimeWindow().getEnd())) + carrierShipment.getPickupStartsTimeWindow().getStart(), + carrierShipment.getPickupStartsTimeWindow().getEnd())) .addSizeDimension(0, carrierShipment.getDemand()); for (String skill : CarriersUtils.getSkills(carrierShipment)) { shipmentBuilder.addRequiredSkill(skill); diff --git a/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/multipleChains/MultipleChainsUtils.java b/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/multipleChains/MultipleChainsUtils.java index cc19c5c2064..70abe3fedd8 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/multipleChains/MultipleChainsUtils.java +++ b/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/multipleChains/MultipleChainsUtils.java @@ -62,10 +62,10 @@ public static Collection createLSPShipmentsFromCarrierShipments(Car builder.setCapacityDemand(shipment.getDemand()); builder.setFromLinkId(shipment.getFrom()); builder.setToLinkId(shipment.getTo()); - builder.setStartTimeWindow(shipment.getPickupTimeWindow()); - builder.setEndTimeWindow(shipment.getDeliveryTimeWindow()); - builder.setPickupServiceTime(shipment.getPickupServiceTime()); - builder.setDeliveryServiceTime(shipment.getDeliveryServiceTime()); + builder.setStartTimeWindow(shipment.getPickupStartsTimeWindow()); + builder.setEndTimeWindow(shipment.getDeliveryStartsTimeWindow()); + builder.setPickupServiceTime(shipment.getPickupDuration()); + builder.setDeliveryServiceTime(shipment.getDeliveryDuration()); shipmentList.add(builder.build()); } return shipmentList; diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/MatsimTransformerTest.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/MatsimTransformerTest.java index a2f8130db57..705f4290980 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/MatsimTransformerTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/MatsimTransformerTest.java @@ -194,13 +194,13 @@ void whenTransforming_jspritShipment2matsimShipment_isMadeCorrectly() { CarrierShipment carrierShipment = MatsimJspritFactory.createCarrierShipment(shipment); assertNotNull(carrierShipment); assertEquals("PickupLocationId", carrierShipment.getFrom().toString()); - assertEquals(30.0, carrierShipment.getPickupServiceTime(), 0.01); - assertEquals(10.0, carrierShipment.getPickupTimeWindow().getStart(), 0.01); - assertEquals(20.0, carrierShipment.getPickupTimeWindow().getEnd(), 0.01); + assertEquals(30.0, carrierShipment.getPickupDuration(), 0.01); + assertEquals(10.0, carrierShipment.getPickupStartsTimeWindow().getStart(), 0.01); + assertEquals(20.0, carrierShipment.getPickupStartsTimeWindow().getEnd(), 0.01); assertEquals("DeliveryLocationId", carrierShipment.getTo().toString()); - assertEquals(40.0, carrierShipment.getDeliveryServiceTime(), 0.01); - assertEquals(50.0, carrierShipment.getDeliveryTimeWindow().getStart(), 0.01); - assertEquals(60.0, carrierShipment.getDeliveryTimeWindow().getEnd(), 0.01); + assertEquals(40.0, carrierShipment.getDeliveryDuration(), 0.01); + assertEquals(50.0, carrierShipment.getDeliveryStartsTimeWindow().getStart(), 0.01); + assertEquals(60.0, carrierShipment.getDeliveryStartsTimeWindow().getEnd(), 0.01); assertEquals(50, carrierShipment.getDemand()); CarrierShipment carrierShipment2 = MatsimJspritFactory.createCarrierShipment(shipment); diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/utils/CarrierControllerUtilsTest.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/utils/CarrierControllerUtilsTest.java index 46c783e197c..110ed45f27e 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/utils/CarrierControllerUtilsTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/utils/CarrierControllerUtilsTest.java @@ -247,12 +247,12 @@ void copyingOfShipmentsIsDoneCorrectly() { Assertions.assertEquals(Id.createLinkId("i(1,0)"), carrierShipment1.getFrom()); Assertions.assertEquals(Id.createLinkId("i(7,6)R"), carrierShipment1.getTo()); Assertions.assertEquals(1, carrierShipment1.getDemand()); - Assertions.assertEquals(30.0, carrierShipment1.getDeliveryServiceTime(), 0); - Assertions.assertEquals(3600.0, carrierShipment1.getDeliveryTimeWindow().getStart(), 0); - Assertions.assertEquals(36000.0, carrierShipment1.getDeliveryTimeWindow().getEnd(), 0); - Assertions.assertEquals(5.0, carrierShipment1.getPickupServiceTime(), 0); - Assertions.assertEquals(0.0, carrierShipment1.getPickupTimeWindow().getStart(), 0); - Assertions.assertEquals(7200.0, carrierShipment1.getPickupTimeWindow().getEnd(), 0); + Assertions.assertEquals(30.0, carrierShipment1.getDeliveryDuration(), 0); + Assertions.assertEquals(3600.0, carrierShipment1.getDeliveryStartsTimeWindow().getStart(), 0); + Assertions.assertEquals(36000.0, carrierShipment1.getDeliveryStartsTimeWindow().getEnd(), 0); + Assertions.assertEquals(5.0, carrierShipment1.getPickupDuration(), 0); + Assertions.assertEquals(0.0, carrierShipment1.getPickupStartsTimeWindow().getStart(), 0); + Assertions.assertEquals(7200.0, carrierShipment1.getPickupStartsTimeWindow().getEnd(), 0); } CarrierShipment carrierShipment2 = CarriersUtils.getShipment(carrierWShipmentsOnlyFromCarrierWShipments, Id.create("shipment2", CarrierShipment.class)); assert carrierShipment2 != null; @@ -262,12 +262,12 @@ void copyingOfShipmentsIsDoneCorrectly() { Assertions.assertEquals(Id.createLinkId("i(3,0)"), carrierShipment2.getFrom()); Assertions.assertEquals(Id.createLinkId("i(3,7)"), carrierShipment2.getTo()); Assertions.assertEquals(2, carrierShipment2.getDemand()); - Assertions.assertEquals(30.0, carrierShipment2.getDeliveryServiceTime(), 0); - Assertions.assertEquals(3600.0, carrierShipment2.getDeliveryTimeWindow().getStart(), 0); - Assertions.assertEquals(36000.0, carrierShipment2.getDeliveryTimeWindow().getEnd(), 0); - Assertions.assertEquals(5.0, carrierShipment2.getPickupServiceTime(), 0); - Assertions.assertEquals(0.0, carrierShipment2.getPickupTimeWindow().getStart(), 0); - Assertions.assertEquals(7200.0, carrierShipment2.getPickupTimeWindow().getEnd(), 0); + Assertions.assertEquals(30.0, carrierShipment2.getDeliveryDuration(), 0); + Assertions.assertEquals(3600.0, carrierShipment2.getDeliveryStartsTimeWindow().getStart(), 0); + Assertions.assertEquals(36000.0, carrierShipment2.getDeliveryStartsTimeWindow().getEnd(), 0); + Assertions.assertEquals(5.0, carrierShipment2.getPickupDuration(), 0); + Assertions.assertEquals(0.0, carrierShipment2.getPickupStartsTimeWindow().getStart(), 0); + Assertions.assertEquals(7200.0, carrierShipment2.getPickupStartsTimeWindow().getEnd(), 0); } Assertions.assertTrue(foundShipment1, "Not found Shipment1 after copying"); Assertions.assertTrue(foundShipment2, "Not found Shipment2 after copying"); @@ -285,12 +285,12 @@ void convertionOfServicesIsDoneCorrectly() { Assertions.assertEquals(Id.createLinkId("i(6,0)"), carrierShipment1.getFrom()); Assertions.assertEquals(Id.createLinkId("i(3,9)"), carrierShipment1.getTo()); Assertions.assertEquals(2, carrierShipment1.getDemand()); - Assertions.assertEquals(31.0, carrierShipment1.getDeliveryServiceTime(), 0); - Assertions.assertEquals(3601.0, carrierShipment1.getDeliveryTimeWindow().getStart(), 0); - Assertions.assertEquals(36001.0, carrierShipment1.getDeliveryTimeWindow().getEnd(), 0); - Assertions.assertEquals(0.0, carrierShipment1.getPickupServiceTime(), 0); - Assertions.assertEquals(0.0, carrierShipment1.getPickupTimeWindow().getStart(), 0); - Assertions.assertEquals(36001.0, carrierShipment1.getPickupTimeWindow().getEnd(), 0); + Assertions.assertEquals(31.0, carrierShipment1.getDeliveryDuration(), 0); + Assertions.assertEquals(3601.0, carrierShipment1.getDeliveryStartsTimeWindow().getStart(), 0); + Assertions.assertEquals(36001.0, carrierShipment1.getDeliveryStartsTimeWindow().getEnd(), 0); + Assertions.assertEquals(0.0, carrierShipment1.getPickupDuration(), 0); + Assertions.assertEquals(0.0, carrierShipment1.getPickupStartsTimeWindow().getStart(), 0); + Assertions.assertEquals(36001.0, carrierShipment1.getPickupStartsTimeWindow().getEnd(), 0); } CarrierShipment carrierShipment2 = CarriersUtils.getShipment(carrierWShipmentsOnlyFromCarrierWServices, Id.create("Service2", CarrierShipment.class)); assert carrierShipment2 != null; @@ -299,12 +299,12 @@ void convertionOfServicesIsDoneCorrectly() { Assertions.assertEquals(Id.createLinkId("i(6,0)"), carrierShipment2.getFrom()); Assertions.assertEquals(Id.createLinkId("i(4,9)"), carrierShipment2.getTo()); Assertions.assertEquals(2, carrierShipment2.getDemand()); - Assertions.assertEquals(31.0, carrierShipment2.getDeliveryServiceTime(), 0); - Assertions.assertEquals(3601.0, carrierShipment2.getDeliveryTimeWindow().getStart(), 0); - Assertions.assertEquals(36001.0, carrierShipment2.getDeliveryTimeWindow().getEnd(), 0); - Assertions.assertEquals(0.0, carrierShipment2.getPickupServiceTime(), 0); - Assertions.assertEquals(0.0, carrierShipment2.getPickupTimeWindow().getStart(), 0); - Assertions.assertEquals(36001.0, carrierShipment2.getPickupTimeWindow().getEnd(), 0); + Assertions.assertEquals(31.0, carrierShipment2.getDeliveryDuration(), 0); + Assertions.assertEquals(3601.0, carrierShipment2.getDeliveryStartsTimeWindow().getStart(), 0); + Assertions.assertEquals(36001.0, carrierShipment2.getDeliveryStartsTimeWindow().getEnd(), 0); + Assertions.assertEquals(0.0, carrierShipment2.getPickupDuration(), 0); + Assertions.assertEquals(0.0, carrierShipment2.getPickupStartsTimeWindow().getStart(), 0); + Assertions.assertEquals(36001.0, carrierShipment2.getPickupStartsTimeWindow().getEnd(), 0); } Assertions.assertTrue(foundService1, "Not found converted Service1 after converting"); Assertions.assertTrue(foundService2, "Not found converted Service2 after converting"); diff --git a/contribs/vsp/src/main/java/org/matsim/freight/carriers/analysis/FreightAnalysisShipmentTracking.java b/contribs/vsp/src/main/java/org/matsim/freight/carriers/analysis/FreightAnalysisShipmentTracking.java index e7126cca05e..91613aa1d34 100644 --- a/contribs/vsp/src/main/java/org/matsim/freight/carriers/analysis/FreightAnalysisShipmentTracking.java +++ b/contribs/vsp/src/main/java/org/matsim/freight/carriers/analysis/FreightAnalysisShipmentTracking.java @@ -57,12 +57,14 @@ public void trackDeliveryActivity(ActivityStartEvent activityStartEvent) { for (ShipmentTracker shipment: shipments.values()){ if (shipment.to==activityStartEvent.getLinkId() ){ if(shipment.driverId == null){ - if(shipment.shipment.getDeliveryTimeWindow().getStart()<=activityStartEvent.getTime() && activityStartEvent.getTime()<=shipment.shipment.getDeliveryTimeWindow().getEnd()){ - if (shipment.possibleDrivers.contains(activityStartEvent.getPersonId().toString())) { - shipment.driverIdGuess = activityStartEvent.getPersonId(); - shipment.deliveryTimeGuess=activityStartEvent.getTime(); - } - } + if(shipment.shipment.getDeliveryStartsTimeWindow().getStart() <= activityStartEvent.getTime()) { + if (activityStartEvent.getTime()<= shipment.shipment.getDeliveryStartsTimeWindow().getEnd()) { + if (shipment.possibleDrivers.contains(activityStartEvent.getPersonId().toString())) { + shipment.driverIdGuess = activityStartEvent.getPersonId(); + shipment.deliveryTimeGuess=activityStartEvent.getTime(); + } + } + } } else if (shipment.driverId.toString().equals(activityStartEvent.getPersonId().toString())){ shipment.deliveryTime=activityStartEvent.getTime(); } @@ -75,8 +77,10 @@ public void trackPickupActivity(ActivityStartEvent activityStartEvent) { for (ShipmentTracker shipmentTracker: shipments.values()){ if (shipmentTracker.from==activityStartEvent.getLinkId()){ if (shipmentTracker.driverId==null){ - if(shipmentTracker.shipment.getPickupTimeWindow().getStart()<=activityStartEvent.getTime() && activityStartEvent.getTime()<=shipmentTracker.shipment.getPickupTimeWindow().getEnd()){ - shipmentTracker.possibleDrivers.add(activityStartEvent.getPersonId().toString()); + if(shipmentTracker.shipment.getPickupStartsTimeWindow().getStart() <= activityStartEvent.getTime()) { + if (activityStartEvent.getTime()<= shipmentTracker.shipment.getPickupStartsTimeWindow().getEnd()) { + shipmentTracker.possibleDrivers.add(activityStartEvent.getPersonId().toString()); + } } } } From 1eac34488d393021d4012f8e8f98e1894cde2c55 Mon Sep 17 00:00:00 2001 From: Kai Martins-Turner Date: Fri, 20 Dec 2024 14:55:31 +0100 Subject: [PATCH 16/18] rename getters and setters to make it more consistent. old setters remain as deprecated --- .../DemandReaderFromCSV.java | 10 ++-- .../FreightDemandGenerationUtils.java | 12 ++--- .../DemandReaderFromCSVTest.java | 46 +++++++++---------- .../freight/carriers/CarrierPlanReaderV1.java | 8 ++-- .../carriers/CarrierPlanXmlParserV2.java | 12 ++--- .../carriers/CarrierPlanXmlParserV2_1.java | 12 ++--- .../carriers/CarrierPlanXmlWriterV2_1.java | 6 +-- .../freight/carriers/CarrierService.java | 10 +++- .../freight/carriers/CarrierShipment.java | 20 +++++++- .../freight/carriers/CarriersUtils.java | 2 +- .../org/matsim/freight/carriers/Tour.java | 6 +-- .../events/CarrierServiceEndEvent.java | 2 +- .../events/CarrierServiceStartEvent.java | 2 +- .../CarrierShipmentDeliveryEndEvent.java | 2 +- .../CarrierShipmentDeliveryStartEvent.java | 2 +- .../events/CarrierShipmentPickupEndEvent.java | 2 +- .../CarrierShipmentPickupStartEvent.java | 2 +- .../carriers/jsprit/MatsimJspritFactory.java | 34 +++++++------- .../multipleChains/MultipleChainsUtils.java | 4 +- .../freight/carriers/CarriersUtilsTest.java | 8 ++-- .../jsprit/MatsimTransformerTest.java | 8 ++-- .../utils/CarrierControllerUtilsTest.java | 16 +++---- .../CollectionLSPSchedulingTest.java | 4 +- .../CompleteLSPSchedulingTest.java | 16 +++---- .../FirstReloadLSPSchedulingTest.java | 6 +-- .../MainRunLSPSchedulingTest.java | 10 ++-- ...eShipmentsCollectionLSPSchedulingTest.java | 4 +- ...pleShipmentsCompleteLSPSchedulingTest.java | 16 +++---- ...ShipmentsFirstReloadLSPSchedulingTest.java | 6 +-- ...ipleShipmentsMainRunLSPSchedulingTest.java | 10 ++-- ...hipmentsSecondReloadLSPSchedulingTest.java | 12 ++--- .../SecondReloadLSPSchedulingTest.java | 12 ++--- .../receiver/ReceiverControlerListener.java | 2 +- ...tingTrafficToSmallScaleCommercialImpl.java | 10 ++-- .../DefaultUnhandledServicesSolution.java | 2 +- .../analysis/FreightAnalysisEventHandler.java | 4 +- .../FreightAnalysisServiceTracking.java | 2 +- .../FreightAnalysisShipmentTracking.java | 4 +- 38 files changed, 185 insertions(+), 161 deletions(-) diff --git a/contribs/application/src/main/java/org/matsim/freightDemandGeneration/DemandReaderFromCSV.java b/contribs/application/src/main/java/org/matsim/freightDemandGeneration/DemandReaderFromCSV.java index 2ebf3060e2e..6b2d6c10784 100644 --- a/contribs/application/src/main/java/org/matsim/freightDemandGeneration/DemandReaderFromCSV.java +++ b/contribs/application/src/main/java/org/matsim/freightDemandGeneration/DemandReaderFromCSV.java @@ -1188,8 +1188,8 @@ private static void combineSimilarJobs(Scenario scenario) { if (!shipmentsToRemove.containsKey(thisShipmentId)) { CarrierShipment thisShipment = thisCarrier.getShipments().get(thisShipmentId); if (baseShipment.getId() != thisShipment.getId() - && baseShipment.getFrom() == thisShipment.getFrom() - && baseShipment.getTo() == thisShipment.getTo()) { + && baseShipment.getPickupLinkId() == thisShipment.getPickupLinkId() + && baseShipment.getDeliveryLinkId() == thisShipment.getDeliveryLinkId()) { if (baseShipment.getPickupStartsTimeWindow() == thisShipment.getPickupStartsTimeWindow()) { if (baseShipment.getDeliveryStartsTimeWindow() == thisShipment.getDeliveryStartsTimeWindow()) shipmentsToConnect.put(thisShipmentId, thisShipment); } @@ -1207,7 +1207,7 @@ private static void combineSimilarJobs(Scenario scenario) { shipmentsToRemove.put(carrierShipment.getId(), carrierShipment); } CarrierShipment newShipment = CarrierShipment.Builder - .newInstance(idNewShipment, baseShipment.getFrom(), baseShipment.getTo(), demandForThisLink) + .newInstance(idNewShipment, baseShipment.getPickupLinkId(), baseShipment.getDeliveryLinkId(), demandForThisLink) .setPickupDuration(serviceTimePickup) .setPickupStartsTimeWindow(baseShipment.getPickupStartsTimeWindow()) .setDeliveryDuration(serviceTimeDelivery) @@ -1237,7 +1237,7 @@ private static void combineSimilarJobs(Scenario scenario) { if (!servicesToRemove.containsKey(thisServiceId)) { CarrierService thisService = thisCarrier.getServices().get(thisServiceId); if (baseService.getId() != thisService.getId() - && baseService.getLocationLinkId() == thisService.getLocationLinkId() && baseService + && baseService.getServiceLinkId() == thisService.getServiceLinkId() && baseService .getServiceStartTimeWindow() == thisService.getServiceStartTimeWindow()) servicesToConnect.put(thisServiceId, thisService); } @@ -1251,7 +1251,7 @@ private static void combineSimilarJobs(Scenario scenario) { servicesToRemove.put(carrierService.getId(), carrierService); } CarrierService newService = CarrierService.Builder - .newInstance(idNewService, baseService.getLocationLinkId()) + .newInstance(idNewService, baseService.getServiceLinkId()) .setServiceDuration(serviceTimeService) .setServiceStartTimeWindow(baseService.getServiceStartTimeWindow()) .setDemand(demandForThisLink).build(); 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 ede28ace76d..235789535db 100644 --- a/contribs/application/src/main/java/org/matsim/freightDemandGeneration/FreightDemandGenerationUtils.java +++ b/contribs/application/src/main/java/org/matsim/freightDemandGeneration/FreightDemandGenerationUtils.java @@ -130,23 +130,23 @@ static void createDemandLocationsFile(Controler controler) { for (Carrier thisCarrier : CarriersUtils.getCarriers(controler.getScenario()).getCarriers().values()) { for (CarrierService thisService : thisCarrier.getServices().values()) { Coord coord = FreightDemandGenerationUtils - .getCoordOfMiddlePointOfLink(network.getLinks().get(thisService.getLocationLinkId())); + .getCoordOfMiddlePointOfLink(network.getLinks().get(thisService.getServiceLinkId())); writer.write(thisCarrier.getId().toString() + thisService.getId().toString() + " " + coord.getX() + " " + coord.getY() + " " + "Service" + " " - + thisService.getLocationLinkId().toString() + " " + "\n"); + + thisService.getServiceLinkId().toString() + " " + "\n"); } for (CarrierShipment thisShipment : thisCarrier.getShipments().values()) { Coord coordFrom = FreightDemandGenerationUtils - .getCoordOfMiddlePointOfLink(network.getLinks().get(thisShipment.getFrom())); + .getCoordOfMiddlePointOfLink(network.getLinks().get(thisShipment.getPickupLinkId())); Coord coordTo = FreightDemandGenerationUtils - .getCoordOfMiddlePointOfLink(network.getLinks().get(thisShipment.getTo())); + .getCoordOfMiddlePointOfLink(network.getLinks().get(thisShipment.getDeliveryLinkId())); writer.write(thisCarrier.getId().toString() + thisShipment.getId().toString() + " " + coordFrom.getX() + " " + coordFrom.getY() + " " + "Pickup" + " " - + thisShipment.getFrom().toString() + " " + thisShipment.getTo().toString() + "\n"); + + thisShipment.getPickupLinkId().toString() + " " + thisShipment.getDeliveryLinkId().toString() + "\n"); writer.write(thisCarrier.getId().toString() + thisShipment.getId() + " " + coordTo.getX() + " " + coordTo.getY() + " " + "Delivery" + " " - + thisShipment.getFrom() + " " + thisShipment.getTo() + "\n"); + + thisShipment.getPickupLinkId() + " " + thisShipment.getDeliveryLinkId() + "\n"); } } writer.flush(); diff --git a/contribs/application/src/test/java/org/matsim/freightDemandGeneration/DemandReaderFromCSVTest.java b/contribs/application/src/test/java/org/matsim/freightDemandGeneration/DemandReaderFromCSVTest.java index d27e5d5a202..32972385d8a 100644 --- a/contribs/application/src/test/java/org/matsim/freightDemandGeneration/DemandReaderFromCSVTest.java +++ b/contribs/application/src/test/java/org/matsim/freightDemandGeneration/DemandReaderFromCSVTest.java @@ -109,9 +109,9 @@ void demandCreationWithSampleWithChangeNumberOfLocations() throws IOException { Assertions.assertEquals(TimeWindow.newInstance(8000, 50000), shipment.getPickupStartsTimeWindow()); Assertions.assertEquals(TimeWindow.newInstance(10000, 60000), shipment.getDeliveryStartsTimeWindow()); locationsPerShipmentElement.computeIfAbsent("ShipmentElement1_pickup", (k) -> new HashSet<>()) - .add(shipment.getFrom().toString()); + .add(shipment.getPickupLinkId().toString()); locationsPerShipmentElement.computeIfAbsent("ShipmentElement1_delivery", (k) -> new HashSet<>()) - .add(shipment.getTo().toString()); + .add(shipment.getDeliveryLinkId().toString()); } Assertions.assertEquals(20, countDemand); Assertions.assertEquals(4, countShipmentsWithCertainDemand.getInt(5)); @@ -176,9 +176,9 @@ void demandCreationWithSampleWithDemandOnLocation() throws IOException { Assertions.assertEquals(TimeWindow.newInstance(8000, 50000), shipment.getPickupStartsTimeWindow()); Assertions.assertEquals(TimeWindow.newInstance(10000, 60000), shipment.getDeliveryStartsTimeWindow()); locationsPerShipmentElement.computeIfAbsent("ShipmentElement1_pickup", (k) -> new HashSet<>()) - .add(shipment.getFrom().toString()); + .add(shipment.getPickupLinkId().toString()); locationsPerShipmentElement.computeIfAbsent("ShipmentElement1_delivery", (k) -> new HashSet<>()) - .add(shipment.getTo().toString()); + .add(shipment.getDeliveryLinkId().toString()); } Assertions.assertEquals(20, countDemand); Assertions.assertEquals(2, countShipmentsWithCertainDemand.getInt(10)); @@ -243,9 +243,9 @@ void demandCreationWithSampleWithDemandOnLocationWithCombiningJobs() throws IOEx Assertions.assertEquals(TimeWindow.newInstance(8000, 50000), shipment.getPickupStartsTimeWindow()); Assertions.assertEquals(TimeWindow.newInstance(10000, 60000), shipment.getDeliveryStartsTimeWindow()); locationsPerShipmentElement.computeIfAbsent("ShipmentElement1_pickup", (k) -> new HashSet<>()) - .add(shipment.getFrom().toString()); + .add(shipment.getPickupLinkId().toString()); locationsPerShipmentElement.computeIfAbsent("ShipmentElement1_delivery", (k) -> new HashSet<>()) - .add(shipment.getTo().toString()); + .add(shipment.getDeliveryLinkId().toString()); } Assertions.assertEquals(20, countDemand); Assertions.assertEquals(2, countShipmentsWithCertainDemand.getInt(10)); @@ -313,9 +313,9 @@ void demandCreationNoSampling() throws IOException { Assertions.assertEquals(TimeWindow.newInstance(8000, 50000), shipment.getPickupStartsTimeWindow()); Assertions.assertEquals(TimeWindow.newInstance(10000, 60000), shipment.getDeliveryStartsTimeWindow()); locationsPerShipmentElement.computeIfAbsent("ShipmentElement1_pickup", (k) -> new HashSet<>()) - .add(shipment.getFrom().toString()); + .add(shipment.getPickupLinkId().toString()); locationsPerShipmentElement.computeIfAbsent("ShipmentElement1_delivery", (k) -> new HashSet<>()) - .add(shipment.getTo().toString()); + .add(shipment.getDeliveryLinkId().toString()); } Assertions.assertEquals(20, countDemand); Assertions.assertEquals(2, countShipmentsWithCertainDemand.getInt(10)); @@ -480,18 +480,18 @@ private static void checkCarrier1and2(Scenario scenario, Network network, ShpOpt Assertions.assertEquals(180, service.getServiceDuration(), MatsimTestUtils.EPSILON); Assertions.assertEquals(TimeWindow.newInstance(3000, 13000), service.getServiceStartTimeWindow()); locationsPerServiceElement.computeIfAbsent("serviceElement1", (k) -> new HashSet<>()) - .add(service.getLocationLinkId().toString()); + .add(service.getServiceLinkId().toString()); } else if (service.getDemand() == 1) { Assertions.assertEquals(100, service.getServiceDuration(), MatsimTestUtils.EPSILON); Assertions.assertEquals(TimeWindow.newInstance(5000, 20000), service.getServiceStartTimeWindow()); locationsPerServiceElement.computeIfAbsent("serviceElement2", (k) -> new HashSet<>()) - .add(service.getLocationLinkId().toString()); + .add(service.getServiceLinkId().toString()); } else { if (service.getDemand() == 2) { Assertions.assertEquals(200, service.getServiceDuration(), MatsimTestUtils.EPSILON); Assertions.assertEquals(TimeWindow.newInstance(5000, 20000), service.getServiceStartTimeWindow()); locationsPerServiceElement.computeIfAbsent("serviceElement2", (k) -> new HashSet<>()) - .add(service.getLocationLinkId().toString()); + .add(service.getServiceLinkId().toString()); } else Assertions.fail("Service has a wrong demand."); } @@ -530,18 +530,18 @@ private static void checkCarrier1and2(Scenario scenario, Network network, ShpOpt Assertions.assertEquals(TimeWindow.newInstance(10000, 45000), shipment.getPickupStartsTimeWindow()); Assertions.assertEquals(TimeWindow.newInstance(11000, 44000), shipment.getDeliveryStartsTimeWindow()); locationsPerShipmentElement.computeIfAbsent("ShipmentElement1_pickup", (k) -> new HashSet<>()) - .add(shipment.getFrom().toString()); + .add(shipment.getPickupLinkId().toString()); locationsPerShipmentElement.computeIfAbsent("ShipmentElement1_delivery", (k) -> new HashSet<>()) - .add(shipment.getTo().toString()); + .add(shipment.getDeliveryLinkId().toString()); } else if (shipment.getDemand() == 2) { Assertions.assertEquals(400, shipment.getPickupDuration(), MatsimTestUtils.EPSILON); Assertions.assertEquals(400, shipment.getDeliveryDuration(), MatsimTestUtils.EPSILON); Assertions.assertEquals(TimeWindow.newInstance(11000, 44000), shipment.getPickupStartsTimeWindow()); Assertions.assertEquals(TimeWindow.newInstance(20000, 40000), shipment.getDeliveryStartsTimeWindow()); locationsPerShipmentElement.computeIfAbsent("ShipmentElement2_pickup", (k) -> new HashSet<>()) - .add(shipment.getFrom().toString()); + .add(shipment.getPickupLinkId().toString()); locationsPerShipmentElement.computeIfAbsent("ShipmentElement2_delivery", (k) -> new HashSet<>()) - .add(shipment.getTo().toString()); + .add(shipment.getDeliveryLinkId().toString()); } else { if (shipment.getDemand() == 3) { Assertions.assertEquals(600, shipment.getPickupDuration(), MatsimTestUtils.EPSILON); @@ -549,9 +549,9 @@ private static void checkCarrier1and2(Scenario scenario, Network network, ShpOpt Assertions.assertEquals(TimeWindow.newInstance(11000, 44000), shipment.getPickupStartsTimeWindow()); Assertions.assertEquals(TimeWindow.newInstance(20000, 40000), shipment.getDeliveryStartsTimeWindow()); locationsPerShipmentElement.computeIfAbsent("ShipmentElement2_pickup", (k) -> new HashSet<>()) - .add(shipment.getFrom().toString()); + .add(shipment.getPickupLinkId().toString()); locationsPerShipmentElement.computeIfAbsent("ShipmentElement2_delivery", (k) -> new HashSet<>()) - .add(shipment.getTo().toString()); + .add(shipment.getDeliveryLinkId().toString()); } else Assertions.fail("Shipment has an unexpected demand."); } @@ -589,12 +589,12 @@ private static void checkCarrier1and2WithCombiningJobs(Scenario scenario, Networ Assertions.assertEquals(180, service.getServiceDuration(), MatsimTestUtils.EPSILON); Assertions.assertEquals(TimeWindow.newInstance(3000, 13000), service.getServiceStartTimeWindow()); locationsPerServiceElement.computeIfAbsent("serviceElement1", (k) -> new HashSet<>()) - .add(service.getLocationLinkId().toString()); + .add(service.getServiceLinkId().toString()); } else { Assertions.assertEquals(service.getDemand() * 100, service.getServiceDuration(), MatsimTestUtils.EPSILON); Assertions.assertEquals(TimeWindow.newInstance(5000, 20000), service.getServiceStartTimeWindow()); locationsPerServiceElement.computeIfAbsent("serviceElement2", (k) -> new HashSet<>()) - .add(service.getLocationLinkId().toString()); + .add(service.getServiceLinkId().toString()); } } Assertions.assertEquals(12, countDemand); @@ -629,18 +629,18 @@ private static void checkCarrier1and2WithCombiningJobs(Scenario scenario, Networ Assertions.assertEquals(TimeWindow.newInstance(10000, 45000), shipment.getPickupStartsTimeWindow()); Assertions.assertEquals(TimeWindow.newInstance(11000, 44000), shipment.getDeliveryStartsTimeWindow()); locationsPerShipmentElement.computeIfAbsent("ShipmentElement1_pickup", (k) -> new HashSet<>()) - .add(shipment.getFrom().toString()); + .add(shipment.getPickupLinkId().toString()); locationsPerShipmentElement.computeIfAbsent("ShipmentElement1_delivery", (k) -> new HashSet<>()) - .add(shipment.getTo().toString()); + .add(shipment.getDeliveryLinkId().toString()); } else { Assertions.assertEquals(shipment.getDemand() * 200, shipment.getPickupDuration(), MatsimTestUtils.EPSILON); Assertions.assertEquals(shipment.getDemand() * 200, shipment.getDeliveryDuration(), MatsimTestUtils.EPSILON); Assertions.assertEquals(TimeWindow.newInstance(11000, 44000), shipment.getPickupStartsTimeWindow()); Assertions.assertEquals(TimeWindow.newInstance(20000, 40000), shipment.getDeliveryStartsTimeWindow()); locationsPerShipmentElement.computeIfAbsent("ShipmentElement2_pickup", (k) -> new HashSet<>()) - .add(shipment.getFrom().toString()); + .add(shipment.getPickupLinkId().toString()); locationsPerShipmentElement.computeIfAbsent("ShipmentElement2_delivery", (k) -> new HashSet<>()) - .add(shipment.getTo().toString()); + .add(shipment.getDeliveryLinkId().toString()); } } Assertions.assertEquals(15, countDemand); diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierPlanReaderV1.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierPlanReaderV1.java index 42b2317a6cb..c22b5928899 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierPlanReaderV1.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierPlanReaderV1.java @@ -208,16 +208,16 @@ public void startTag(String name, Attributes attributes, Stack context) case "pickup" -> { String id = attributes.getValue(SHIPMENT_ID); CarrierShipment s = currentShipments.get(id); - finishLeg(s.getFrom()); + finishLeg(s.getPickupLinkId()); currentTourBuilder.schedulePickup(s); - previousActLoc = s.getFrom(); + previousActLoc = s.getPickupLinkId(); } case "delivery" -> { String id = attributes.getValue(SHIPMENT_ID); CarrierShipment s = currentShipments.get(id); - finishLeg(s.getTo()); + finishLeg(s.getDeliveryLinkId()); currentTourBuilder.scheduleDelivery(s); - previousActLoc = s.getTo(); + previousActLoc = s.getDeliveryLinkId(); } case "end" -> { finishLeg(currentVehicle.getLinkId()); diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierPlanXmlParserV2.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierPlanXmlParserV2.java index 599c48a3886..7bbc83c9479 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierPlanXmlParserV2.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierPlanXmlParserV2.java @@ -261,26 +261,26 @@ public void startTag(String name, Attributes atts, Stack context) { String id = atts.getValue(SHIPMENT_ID); if (id == null) throw new IllegalStateException("pickup.shipmentId is missing."); CarrierShipment s = currentShipments.get(id); - finishLeg(s.getFrom()); + finishLeg(s.getPickupLinkId()); currentTourBuilder.schedulePickup(s); - previousActLoc = s.getFrom(); + previousActLoc = s.getPickupLinkId(); } case "delivery" -> { String id = atts.getValue(SHIPMENT_ID); if (id == null) throw new IllegalStateException("delivery.shipmentId is missing."); CarrierShipment s = currentShipments.get(id); - finishLeg(s.getTo()); + finishLeg(s.getDeliveryLinkId()); currentTourBuilder.scheduleDelivery(s); - previousActLoc = s.getTo(); + previousActLoc = s.getDeliveryLinkId(); } case "service" -> { String id = atts.getValue("serviceId"); if (id == null) throw new IllegalStateException("act.serviceId is missing."); CarrierService s = serviceMap.get(Id.create(id, CarrierService.class)); if (s == null) throw new IllegalStateException("serviceId is not known."); - finishLeg(s.getLocationLinkId()); + finishLeg(s.getServiceLinkId()); currentTourBuilder.scheduleService(s); - previousActLoc = s.getLocationLinkId(); + previousActLoc = s.getServiceLinkId(); } case "end" -> { finishLeg(currentVehicle.getLinkId()); diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierPlanXmlParserV2_1.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierPlanXmlParserV2_1.java index a9f06abb1f4..f439d323ddd 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierPlanXmlParserV2_1.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierPlanXmlParserV2_1.java @@ -263,26 +263,26 @@ public void startTag(String name, Attributes atts, Stack context) { String id = atts.getValue(SHIPMENT_ID); if (id == null) throw new IllegalStateException("pickup.shipmentId is missing."); CarrierShipment s = currentShipments.get(id); - finishLeg(s.getFrom()); + finishLeg(s.getPickupLinkId()); currentTourBuilder.schedulePickup(s); - previousActLoc = s.getFrom(); + previousActLoc = s.getPickupLinkId(); } case "delivery" -> { String id = atts.getValue(SHIPMENT_ID); if (id == null) throw new IllegalStateException("delivery.shipmentId is missing."); CarrierShipment s = currentShipments.get(id); - finishLeg(s.getTo()); + finishLeg(s.getDeliveryLinkId()); currentTourBuilder.scheduleDelivery(s); - previousActLoc = s.getTo(); + previousActLoc = s.getDeliveryLinkId(); } case "service" -> { String id = atts.getValue("serviceId"); if (id == null) throw new IllegalStateException("act.serviceId is missing."); CarrierService s = serviceMap.get(Id.create(id, CarrierService.class)); if (s == null) throw new IllegalStateException("serviceId is not known."); - finishLeg(s.getLocationLinkId()); + finishLeg(s.getServiceLinkId()); currentTourBuilder.scheduleService(s); - previousActLoc = s.getLocationLinkId(); + previousActLoc = s.getServiceLinkId(); } case "end" -> { finishLeg(currentVehicle.getLinkId()); diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierPlanXmlWriterV2_1.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierPlanXmlWriterV2_1.java index 5641fbc85f9..811153ead21 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierPlanXmlWriterV2_1.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierPlanXmlWriterV2_1.java @@ -159,8 +159,8 @@ private void writeShipments(Carrier carrier, BufferedWriter writer) { private void writeShipment(CarrierShipment s, Id shipmentId, boolean closeElement, boolean lineBreak) { this.writeStartTag(SHIPMENT, List.of( createTuple(ID, shipmentId.toString()), - createTuple(FROM, s.getFrom().toString()), - createTuple(TO, s.getTo().toString()), + createTuple(FROM, s.getPickupLinkId().toString()), + createTuple(TO, s.getDeliveryLinkId().toString()), createTuple(SIZE, s.getDemand()), createTuple(START_PICKUP, getTime(s.getPickupStartsTimeWindow().getStart())), createTuple(END_PICKUP, getTime(s.getPickupStartsTimeWindow().getEnd())), @@ -190,7 +190,7 @@ private void writeServices(Carrier carrier, BufferedWriter writer) { private void writeService(CarrierService s, boolean closeElement, boolean lineBreak) { this.writeStartTag(SERVICE, List.of( createTuple(ID, s.getId().toString()), - createTuple(TO, s.getLocationLinkId().toString()), + createTuple(TO, s.getServiceLinkId().toString()), createTuple(CAPACITY_DEMAND, s.getDemand()), createTuple(EARLIEST_START, getTime(s.getServiceStartTimeWindow().getStart())), createTuple(LATEST_END, getTime(s.getServiceStartTimeWindow().getEnd())), diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierService.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierService.java index 7a140a5b386..99be9a2f21f 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierService.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierService.java @@ -141,10 +141,18 @@ public Id getId() { return id; } - public Id getLocationLinkId() { + public Id getServiceLinkId() { return serviceLinkId; } + /** + * @deprecated please inline and use {@link #getServiceLinkId()} instead + */ + @Deprecated(since = "dec'24") + public Id getLocationLinkId() { + return getServiceLinkId(); + } + public double getServiceDuration() { return serviceDuration; } diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierShipment.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierShipment.java index 1bdb0d390e2..a78e636ee49 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierShipment.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierShipment.java @@ -278,11 +278,11 @@ public Id getId() { return id; } - public Id getFrom() { + public Id getPickupLinkId() { return pickupLinkId; } - public Id getTo() { + public Id getDeliveryLinkId() { return deliveryLinkId; } @@ -317,6 +317,22 @@ public int getSize() { return getDemand(); } + /** + * @deprecated please inline and use {@link #getPickupLinkId()} instead + */ + @Deprecated(since = "dec'24") + public Id getFrom() { + return getPickupLinkId(); + } + + /** + * @deprecated please inline and use {@link #getDeliveryLinkId()} instead + */ + @Deprecated(since = "dec'24") + public Id getTo() { + return getDeliveryLinkId(); + } + /** * @deprecated please inline and use {@link #getPickupStartsTimeWindow()} instead */ diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarriersUtils.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarriersUtils.java index 61a7ff0c27b..d82e2e0ba46 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarriersUtils.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarriersUtils.java @@ -430,7 +430,7 @@ private static void createShipmentsFromServices(Carrier carrierWS, Carrier carri log.debug("Converting CarrierService to CarrierShipment: {}", carrierService.getId()); CarrierShipment carrierShipment = CarrierShipment.Builder .newInstance(Id.create(carrierService.getId().toString(), CarrierShipment.class), - depotServiceIsDeliveredFrom.get(carrierService.getId()), carrierService.getLocationLinkId(), + depotServiceIsDeliveredFrom.get(carrierService.getId()), carrierService.getServiceLinkId(), carrierService.getDemand()) .setDeliveryDuration(carrierService.getServiceDuration()) // .setPickupServiceTime(pickupServiceTime) //Not set yet, because in service we diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/Tour.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/Tour.java index 41325eb3920..fec5bc60655 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/Tour.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/Tour.java @@ -379,7 +379,7 @@ public String getActivityType() { @Override public Id getLocation() { - return service.getLocationLinkId(); + return service.getServiceLinkId(); } @Override @@ -544,7 +544,7 @@ public TimeWindow getTimeWindow() { @Override public Id getLocation() { - return shipment.getFrom(); + return shipment.getPickupLinkId(); } @Override @@ -602,7 +602,7 @@ public String getActivityType() { @Override public Id getLocation() { - return shipment.getTo(); + return shipment.getDeliveryLinkId(); } @Override diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierServiceEndEvent.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierServiceEndEvent.java index f806248471c..17907fe74eb 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierServiceEndEvent.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierServiceEndEvent.java @@ -42,7 +42,7 @@ public final class CarrierServiceEndEvent extends AbstractCarrierEvent { private final double serviceDuration; public CarrierServiceEndEvent(double time, Id carrierId, CarrierService service, Id vehicleId) { - super(time, carrierId, service.getLocationLinkId(), vehicleId); + super(time, carrierId, service.getServiceLinkId(), vehicleId); this.serviceId = service.getId(); this.serviceDuration = service.getServiceDuration(); } diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierServiceStartEvent.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierServiceStartEvent.java index 02b24c5d56c..f0a2cc0fde6 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierServiceStartEvent.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierServiceStartEvent.java @@ -44,7 +44,7 @@ public final class CarrierServiceStartEvent extends AbstractCarrierEvent { private final int capacityDemand; public CarrierServiceStartEvent(double time, Id carrierId, CarrierService service, Id vehicleId) { - super(time, carrierId, service.getLocationLinkId(), vehicleId); + super(time, carrierId, service.getServiceLinkId(), vehicleId); this.serviceId = service.getId(); this.serviceDuration = service.getServiceDuration(); this.capacityDemand = service.getDemand(); diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentDeliveryEndEvent.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentDeliveryEndEvent.java index fbd9e4ddff8..2687b550387 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentDeliveryEndEvent.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentDeliveryEndEvent.java @@ -44,7 +44,7 @@ public class CarrierShipmentDeliveryEndEvent extends AbstractCarrierEvent { private final double deliveryDuration; private final int capacityDemand; public CarrierShipmentDeliveryEndEvent(double time, Id carrierId, CarrierShipment shipment, Id vehicleId) { - super(time, carrierId, shipment.getTo(), vehicleId); + super(time, carrierId, shipment.getDeliveryLinkId(), vehicleId); this.shipmentId = shipment.getId(); this.deliveryDuration = shipment.getDeliveryDuration(); this.capacityDemand = shipment.getDemand(); diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentDeliveryStartEvent.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentDeliveryStartEvent.java index 355b76782b0..ca4a2ec4767 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentDeliveryStartEvent.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentDeliveryStartEvent.java @@ -45,7 +45,7 @@ public class CarrierShipmentDeliveryStartEvent extends AbstractCarrierEvent { private final double deliveryDuration; private final int capacityDemand; public CarrierShipmentDeliveryStartEvent(double time, Id carrierId, CarrierShipment shipment, Id vehicleId) { - super(time, carrierId, shipment.getTo(), vehicleId); + super(time, carrierId, shipment.getDeliveryLinkId(), vehicleId); this.shipmentId = shipment.getId(); this.deliveryDuration = shipment.getDeliveryDuration(); this.capacityDemand = shipment.getDemand(); diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentPickupEndEvent.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentPickupEndEvent.java index 1f669809087..97da9f70817 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentPickupEndEvent.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentPickupEndEvent.java @@ -46,7 +46,7 @@ public class CarrierShipmentPickupEndEvent extends AbstractCarrierEvent { public CarrierShipmentPickupEndEvent(double time, Id carrierId, CarrierShipment shipment, Id vehicleId) { - super(time, carrierId, shipment.getFrom(), vehicleId); + super(time, carrierId, shipment.getPickupLinkId(), vehicleId); this.shipmentId = shipment.getId(); this.pickupDuration = shipment.getPickupDuration(); this.capacityDemand = shipment.getDemand(); diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentPickupStartEvent.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentPickupStartEvent.java index 9e9bb519ae1..7334a9fa8a6 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentPickupStartEvent.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentPickupStartEvent.java @@ -44,7 +44,7 @@ public class CarrierShipmentPickupStartEvent extends AbstractCarrierEvent { public CarrierShipmentPickupStartEvent(double time, Id carrierId, CarrierShipment shipment, Id vehicleId) { - super(time, carrierId, shipment.getFrom(), vehicleId); + super(time, carrierId, shipment.getPickupLinkId(), vehicleId); this.shipmentId = shipment.getId(); this.pickupDuration = shipment.getPickupDuration(); this.capacityDemand = shipment.getDemand(); diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/jsprit/MatsimJspritFactory.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/jsprit/MatsimJspritFactory.java index 986eb953391..11776d0152b 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/jsprit/MatsimJspritFactory.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/jsprit/MatsimJspritFactory.java @@ -108,13 +108,13 @@ static CarrierShipment createCarrierShipment(Shipment jspritShipment) { */ static Shipment createJspritShipment(CarrierShipment carrierShipment) { Shipment.Builder shipmentBuilder = Shipment.Builder.newInstance(carrierShipment.getId().toString()) - .setDeliveryLocation(Location.newInstance(carrierShipment.getTo().toString())) + .setDeliveryLocation(Location.newInstance(carrierShipment.getDeliveryLinkId().toString())) .setDeliveryServiceTime(carrierShipment.getDeliveryDuration()) .setDeliveryTimeWindow(com.graphhopper.jsprit.core.problem.solution.route.activity.TimeWindow .newInstance(carrierShipment.getDeliveryStartsTimeWindow().getStart(), carrierShipment.getDeliveryStartsTimeWindow().getEnd())) .setPickupServiceTime(carrierShipment.getPickupDuration()) - .setPickupLocation(Location.newInstance(carrierShipment.getFrom().toString())) + .setPickupLocation(Location.newInstance(carrierShipment.getPickupLinkId().toString())) .setPickupTimeWindow(com.graphhopper.jsprit.core.problem.solution.route.activity.TimeWindow.newInstance( carrierShipment.getPickupStartsTimeWindow().getStart(), carrierShipment.getPickupStartsTimeWindow().getEnd())) @@ -127,14 +127,14 @@ static Shipment createJspritShipment(CarrierShipment carrierShipment) { static Shipment createJspritShipment(CarrierShipment carrierShipment, Coord fromCoord, Coord toCoord) { Location.Builder fromLocationBuilder = Location.Builder.newInstance(); - fromLocationBuilder.setId(carrierShipment.getFrom().toString()); + fromLocationBuilder.setId(carrierShipment.getPickupLinkId().toString()); if (fromCoord != null) { fromLocationBuilder.setCoordinate(Coordinate.newInstance(fromCoord.getX(), fromCoord.getY())); } Location fromLocation = fromLocationBuilder.build(); Location.Builder toLocationBuilder = Location.Builder.newInstance(); - toLocationBuilder.setId(carrierShipment.getTo().toString()); + toLocationBuilder.setId(carrierShipment.getDeliveryLinkId().toString()); if (toCoord != null) { toLocationBuilder.setCoordinate(Coordinate.newInstance(toCoord.getX(), toCoord.getY())); } @@ -158,7 +158,7 @@ static Shipment createJspritShipment(CarrierShipment carrierShipment, Coord from static Service createJspritService(CarrierService carrierService, Coord locationCoord) { Location.Builder locationBuilder = Location.Builder.newInstance(); - locationBuilder.setId(carrierService.getLocationLinkId().toString()); + locationBuilder.setId(carrierService.getServiceLinkId().toString()); if (locationCoord != null) { locationBuilder.setCoordinate(Coordinate.newInstance(locationCoord.getX(), locationCoord.getY())); } @@ -515,11 +515,11 @@ public static VehicleRoutingProblem createRoutingProblem(Carrier carrier, Networ Coord coordinate = null; if (network != null) { - Link link = network.getLinks().get(service.getLocationLinkId()); + Link link = network.getLinks().get(service.getServiceLinkId()); if (link != null) { coordinate = link.getCoord(); } else - log.warn("cannot find linkId {}", service.getLocationLinkId()); + log.warn("cannot find linkId {}", service.getServiceLinkId()); } vrpBuilder.addJob(createJspritService(service, coordinate)); } @@ -530,8 +530,8 @@ public static VehicleRoutingProblem createRoutingProblem(Carrier carrier, Networ Coord fromCoordinate = null; Coord toCoordinate = null; if (network != null) { - Link fromLink = network.getLinks().get(carrierShipment.getFrom()); - Link toLink = network.getLinks().get(carrierShipment.getTo()); + Link fromLink = network.getLinks().get(carrierShipment.getPickupLinkId()); + Link toLink = network.getLinks().get(carrierShipment.getDeliveryLinkId()); if (fromLink != null && toLink != null) { // Shipment to be delivered from specified location to // specified location @@ -540,8 +540,8 @@ public static VehicleRoutingProblem createRoutingProblem(Carrier carrier, Networ vrpBuilder.addJob(createJspritShipment(carrierShipment, fromCoordinate, toCoordinate)); } else throw new IllegalStateException( - "cannot create shipment since neither fromLinkId " + carrierShipment.getTo() - + " nor toLinkId " + carrierShipment.getTo() + " exists in network."); + "cannot create shipment since neither fromLinkId " + carrierShipment.getDeliveryLinkId() + + " nor toLinkId " + carrierShipment.getDeliveryLinkId() + " exists in network."); } vrpBuilder.addJob(createJspritShipment(carrierShipment, fromCoordinate, toCoordinate)); @@ -611,9 +611,9 @@ public static VehicleRoutingProblem.Builder createRoutingProblemBuilder(Carrier log.debug("Handle CarrierService: {}", service.toString()); Coord coordinate = null; if (network != null) { - Link link = network.getLinks().get(service.getLocationLinkId()); + Link link = network.getLinks().get(service.getServiceLinkId()); if (link == null) { - throw new IllegalStateException("cannot create service since linkId " + service.getLocationLinkId() + throw new IllegalStateException("cannot create service since linkId " + service.getServiceLinkId() + " does not exists in network."); } else coordinate = link.getCoord(); @@ -628,8 +628,8 @@ public static VehicleRoutingProblem.Builder createRoutingProblemBuilder(Carrier Coord fromCoordinate = null; Coord toCoordinate = null; if (network != null) { - Link fromLink = network.getLinks().get(carrierShipment.getFrom()); - Link toLink = network.getLinks().get(carrierShipment.getTo()); + Link fromLink = network.getLinks().get(carrierShipment.getPickupLinkId()); + Link toLink = network.getLinks().get(carrierShipment.getDeliveryLinkId()); if (fromLink != null && toLink != null) { // Shipment to be delivered from specified location to // specified location @@ -638,8 +638,8 @@ public static VehicleRoutingProblem.Builder createRoutingProblemBuilder(Carrier toCoordinate = toLink.getCoord(); } else throw new IllegalStateException("cannot create shipment " + carrierShipment.getId().toString() - + " since either fromLinkId " + carrierShipment.getFrom() + " or toLinkId " - + carrierShipment.getTo() + " exists in network."); + + " since either fromLinkId " + carrierShipment.getPickupLinkId() + " or toLinkId " + + carrierShipment.getDeliveryLinkId() + " exists in network."); } vrpBuilder.addJob(createJspritShipment(carrierShipment, fromCoordinate, toCoordinate)); diff --git a/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/multipleChains/MultipleChainsUtils.java b/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/multipleChains/MultipleChainsUtils.java index 70abe3fedd8..8670ad977ea 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/multipleChains/MultipleChainsUtils.java +++ b/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/multipleChains/MultipleChainsUtils.java @@ -60,8 +60,8 @@ public static Collection createLSPShipmentsFromCarrierShipments(Car LspShipmentUtils.LspShipmentBuilder.newInstance( Id.create(shipment.getId().toString(), LspShipment.class)); builder.setCapacityDemand(shipment.getDemand()); - builder.setFromLinkId(shipment.getFrom()); - builder.setToLinkId(shipment.getTo()); + builder.setFromLinkId(shipment.getPickupLinkId()); + builder.setToLinkId(shipment.getDeliveryLinkId()); builder.setStartTimeWindow(shipment.getPickupStartsTimeWindow()); builder.setEndTimeWindow(shipment.getDeliveryStartsTimeWindow()); builder.setPickupServiceTime(shipment.getPickupDuration()); diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarriersUtilsTest.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarriersUtilsTest.java index 7a784b4351d..839f2cceaef 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarriersUtilsTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarriersUtilsTest.java @@ -75,14 +75,14 @@ void testAddAndGetServiceToCarrier() { Assertions.assertEquals(1, carrier.getServices().size()); CarrierService cs1a = (CarrierService) carrier.getServices().values().toArray()[0]; Assertions.assertEquals(service1, cs1a); - Assertions.assertEquals(Id.createLinkId("link0"), cs1a.getLocationLinkId()); + Assertions.assertEquals(Id.createLinkId("link0"), cs1a.getServiceLinkId()); //get Service CarrierService cs1b = CarriersUtils.getService(carrier, serviceId ); assert cs1b != null; Assertions.assertEquals(serviceId, cs1b.getId()); Assertions.assertEquals(service1.getId(), cs1b.getId()); - Assertions.assertEquals(Id.createLinkId("link0"), cs1b.getLocationLinkId()); + Assertions.assertEquals(Id.createLinkId("link0"), cs1b.getServiceLinkId()); Assertions.assertEquals(30, cs1b.getServiceDuration(), EPSILON); } @@ -97,14 +97,14 @@ void testAddAndGetShipmentToCarrier() { Assertions.assertEquals(1, carrier.getShipments().size()); CarrierShipment carrierShipment1a = (CarrierShipment) carrier.getShipments().values().toArray()[0]; Assertions.assertEquals(service1, carrierShipment1a); - Assertions.assertEquals(Id.createLinkId("link0"), carrierShipment1a.getFrom()); + Assertions.assertEquals(Id.createLinkId("link0"), carrierShipment1a.getPickupLinkId()); //get Shipment CarrierShipment carrierShipment1b = CarriersUtils.getShipment(carrier, shipmentId ); assert carrierShipment1b != null; Assertions.assertEquals(shipmentId, carrierShipment1b.getId()); Assertions.assertEquals(service1.getId(), carrierShipment1b.getId()); - Assertions.assertEquals(Id.createLinkId("link0"), carrierShipment1b.getFrom()); + Assertions.assertEquals(Id.createLinkId("link0"), carrierShipment1b.getPickupLinkId()); Assertions.assertEquals(20, carrierShipment1b.getDemand(), EPSILON); } diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/MatsimTransformerTest.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/MatsimTransformerTest.java index 705f4290980..2882cec1336 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/MatsimTransformerTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/MatsimTransformerTest.java @@ -146,7 +146,7 @@ void whenTransforming_jspritService2matsimService_isMadeCorrectly() { CarrierService service = MatsimJspritFactory.createCarrierService(carrierService); assertNotNull(service); - assertEquals("locationId", service.getLocationLinkId().toString()); + assertEquals("locationId", service.getServiceLinkId().toString()); assertEquals(30.0, service.getServiceDuration(), 0.01); assertEquals(50, service.getDemand()); assertEquals(10.0, service.getServiceStartTimeWindow().getStart(), 0.01); @@ -193,11 +193,11 @@ void whenTransforming_jspritShipment2matsimShipment_isMadeCorrectly() { CarrierShipment carrierShipment = MatsimJspritFactory.createCarrierShipment(shipment); assertNotNull(carrierShipment); - assertEquals("PickupLocationId", carrierShipment.getFrom().toString()); + assertEquals("PickupLocationId", carrierShipment.getPickupLinkId().toString()); assertEquals(30.0, carrierShipment.getPickupDuration(), 0.01); assertEquals(10.0, carrierShipment.getPickupStartsTimeWindow().getStart(), 0.01); assertEquals(20.0, carrierShipment.getPickupStartsTimeWindow().getEnd(), 0.01); - assertEquals("DeliveryLocationId", carrierShipment.getTo().toString()); + assertEquals("DeliveryLocationId", carrierShipment.getDeliveryLinkId().toString()); assertEquals(40.0, carrierShipment.getDeliveryDuration(), 0.01); assertEquals(50.0, carrierShipment.getDeliveryStartsTimeWindow().getStart(), 0.01); assertEquals(60.0, carrierShipment.getDeliveryStartsTimeWindow().getEnd(), 0.01); @@ -234,7 +234,7 @@ private Collection getJobsFrom(ScheduledTour sTour) { CarrierService carrierService = ((Tour.ServiceActivity) e) .getService(); Service service = Service.Builder.newInstance(carrierService.getId().toString()) - .setLocation(Location.newInstance(carrierService.getLocationLinkId().toString())).build(); + .setLocation(Location.newInstance(carrierService.getServiceLinkId().toString())).build(); services.add(service); } } diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/utils/CarrierControllerUtilsTest.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/utils/CarrierControllerUtilsTest.java index 110ed45f27e..393f73088a3 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/utils/CarrierControllerUtilsTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/utils/CarrierControllerUtilsTest.java @@ -244,8 +244,8 @@ void copyingOfShipmentsIsDoneCorrectly() { if (carrierShipment1.getId() == Id.create("shipment1", CarrierShipment.class)) { System.out.println("Found Shipment1"); foundShipment1 = true; - Assertions.assertEquals(Id.createLinkId("i(1,0)"), carrierShipment1.getFrom()); - Assertions.assertEquals(Id.createLinkId("i(7,6)R"), carrierShipment1.getTo()); + Assertions.assertEquals(Id.createLinkId("i(1,0)"), carrierShipment1.getPickupLinkId()); + Assertions.assertEquals(Id.createLinkId("i(7,6)R"), carrierShipment1.getDeliveryLinkId()); Assertions.assertEquals(1, carrierShipment1.getDemand()); Assertions.assertEquals(30.0, carrierShipment1.getDeliveryDuration(), 0); Assertions.assertEquals(3600.0, carrierShipment1.getDeliveryStartsTimeWindow().getStart(), 0); @@ -259,8 +259,8 @@ void copyingOfShipmentsIsDoneCorrectly() { if (carrierShipment2.getId() == Id.create("shipment2", CarrierShipment.class)) { System.out.println("Found Shipment2"); foundShipment2 = true; - Assertions.assertEquals(Id.createLinkId("i(3,0)"), carrierShipment2.getFrom()); - Assertions.assertEquals(Id.createLinkId("i(3,7)"), carrierShipment2.getTo()); + Assertions.assertEquals(Id.createLinkId("i(3,0)"), carrierShipment2.getPickupLinkId()); + Assertions.assertEquals(Id.createLinkId("i(3,7)"), carrierShipment2.getDeliveryLinkId()); Assertions.assertEquals(2, carrierShipment2.getDemand()); Assertions.assertEquals(30.0, carrierShipment2.getDeliveryDuration(), 0); Assertions.assertEquals(3600.0, carrierShipment2.getDeliveryStartsTimeWindow().getStart(), 0); @@ -282,8 +282,8 @@ void convertionOfServicesIsDoneCorrectly() { assert carrierShipment1 != null; if (carrierShipment1.getId() == Id.create("Service1", CarrierShipment.class)) { foundService1 = true; - Assertions.assertEquals(Id.createLinkId("i(6,0)"), carrierShipment1.getFrom()); - Assertions.assertEquals(Id.createLinkId("i(3,9)"), carrierShipment1.getTo()); + Assertions.assertEquals(Id.createLinkId("i(6,0)"), carrierShipment1.getPickupLinkId()); + Assertions.assertEquals(Id.createLinkId("i(3,9)"), carrierShipment1.getDeliveryLinkId()); Assertions.assertEquals(2, carrierShipment1.getDemand()); Assertions.assertEquals(31.0, carrierShipment1.getDeliveryDuration(), 0); Assertions.assertEquals(3601.0, carrierShipment1.getDeliveryStartsTimeWindow().getStart(), 0); @@ -296,8 +296,8 @@ void convertionOfServicesIsDoneCorrectly() { assert carrierShipment2 != null; if (carrierShipment2.getId() == Id.create("Service2", CarrierShipment.class)) { foundService2 = true; - Assertions.assertEquals(Id.createLinkId("i(6,0)"), carrierShipment2.getFrom()); - Assertions.assertEquals(Id.createLinkId("i(4,9)"), carrierShipment2.getTo()); + Assertions.assertEquals(Id.createLinkId("i(6,0)"), carrierShipment2.getPickupLinkId()); + Assertions.assertEquals(Id.createLinkId("i(4,9)"), carrierShipment2.getDeliveryLinkId()); Assertions.assertEquals(2, carrierShipment2.getDemand()); Assertions.assertEquals(31.0, carrierShipment2.getDeliveryDuration(), 0); Assertions.assertEquals(3601.0, carrierShipment2.getDeliveryStartsTimeWindow().getStart(), 0); diff --git a/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/CollectionLSPSchedulingTest.java b/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/CollectionLSPSchedulingTest.java index d031c5f6d1d..ba6d1fd35e7 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/CollectionLSPSchedulingTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/CollectionLSPSchedulingTest.java @@ -196,7 +196,7 @@ public void testCollectionLSPScheduling() { { assertInstanceOf(LSPTourEndEventHandler.class, eventHandlers.getFirst()); LSPTourEndEventHandler endHandler = (LSPTourEndEventHandler) eventHandlers.getFirst(); - assertSame(endHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); + assertSame(endHandler.getCarrierService().getServiceLinkId(), shipment.getFrom()); assertEquals(endHandler.getCarrierService().getDemand(), shipment.getSize()); assertEquals(endHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(endHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); @@ -211,7 +211,7 @@ public void testCollectionLSPScheduling() { { assertInstanceOf(CollectionServiceEndEventHandler.class, eventHandlers.get(1)); CollectionServiceEndEventHandler serviceHandler = (CollectionServiceEndEventHandler) eventHandlers.get(1); - assertSame(serviceHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); + assertSame(serviceHandler.getCarrierService().getServiceLinkId(), shipment.getFrom()); assertEquals(serviceHandler.getCarrierService().getDemand(), shipment.getSize()); assertEquals(serviceHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(serviceHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); diff --git a/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/CompleteLSPSchedulingTest.java b/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/CompleteLSPSchedulingTest.java index 3a6a13e629a..11d49bd6c0b 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/CompleteLSPSchedulingTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/CompleteLSPSchedulingTest.java @@ -433,7 +433,7 @@ public void testCompletedLSPScheduling() { CarrierService service = entry.getKey(); LspShipment shipment = entry.getValue().lspShipment; LogisticChainElement element = entry.getValue().logisticChainElement; - assertSame(service.getLocationLinkId(), shipment.getFrom()); + assertSame(service.getServiceLinkId(), shipment.getFrom()); assertEquals(service.getDemand(), shipment.getSize()); assertEquals(service.getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); boolean handledByTranshipmentHub = false; @@ -460,7 +460,7 @@ public void testCompletedLSPScheduling() { CarrierService service = entry.getKey(); LspShipment shipment = entry.getValue().lspShipment; LogisticChainElement element = entry.getValue().logisticChainElement; - assertSame(service.getLocationLinkId(), toLinkId); + assertSame(service.getServiceLinkId(), toLinkId); assertEquals(service.getDemand(), shipment.getSize()); assertEquals(service.getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); boolean handledByTranshipmentHub = false; @@ -484,7 +484,7 @@ public void testCompletedLSPScheduling() { assertInstanceOf(LSPTourEndEventHandler.class, eventHandlers.getFirst()); LSPTourEndEventHandler endHandler = (LSPTourEndEventHandler) eventHandlers.getFirst(); - assertSame(endHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); + assertSame(endHandler.getCarrierService().getServiceLinkId(), shipment.getFrom()); assertEquals(endHandler.getCarrierService().getDemand(), shipment.getSize()); assertEquals(endHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(endHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); @@ -502,7 +502,7 @@ public void testCompletedLSPScheduling() { //CollectionServiceEnd assertInstanceOf(CollectionServiceEndEventHandler.class, eventHandlers.get(1)); CollectionServiceEndEventHandler serviceHandler = (CollectionServiceEndEventHandler) eventHandlers.get(1); - assertSame(serviceHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); + assertSame(serviceHandler.getCarrierService().getServiceLinkId(), shipment.getFrom()); assertEquals(serviceHandler.getCarrierService().getDemand(), shipment.getSize()); assertEquals(serviceHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(serviceHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); @@ -520,7 +520,7 @@ public void testCompletedLSPScheduling() { //MainRunStart assertInstanceOf(LSPTourStartEventHandler.class, eventHandlers.get(2)); LSPTourStartEventHandler mainRunStartHandler = (LSPTourStartEventHandler) eventHandlers.get(2); - assertSame(mainRunStartHandler.getCarrierService().getLocationLinkId(), toLinkId); + assertSame(mainRunStartHandler.getCarrierService().getServiceLinkId(), toLinkId); assertEquals(mainRunStartHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(mainRunStartHandler.getCarrierService().getDemand(), shipment.getSize()); assertEquals(0, mainRunStartHandler.getCarrierService().getServiceStartTimeWindow().getStart(), 0.0); @@ -538,7 +538,7 @@ public void testCompletedLSPScheduling() { //MainRunEnd assertInstanceOf(LSPTourEndEventHandler.class, eventHandlers.get(3)); LSPTourEndEventHandler mainRunEndHandler = (LSPTourEndEventHandler) eventHandlers.get(3); - assertSame(mainRunEndHandler.getCarrierService().getLocationLinkId(), toLinkId); + assertSame(mainRunEndHandler.getCarrierService().getServiceLinkId(), toLinkId); assertEquals(mainRunEndHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(mainRunEndHandler.getCarrierService().getDemand(), shipment.getSize()); assertEquals(0, mainRunEndHandler.getCarrierService().getServiceStartTimeWindow().getStart(), 0.0); @@ -556,7 +556,7 @@ public void testCompletedLSPScheduling() { //DistributionRunStart assertInstanceOf(LSPTourStartEventHandler.class, eventHandlers.get(4)); LSPTourStartEventHandler lspTourStartEventHandler = (LSPTourStartEventHandler) eventHandlers.get(4); - assertSame(lspTourStartEventHandler.getCarrierService().getLocationLinkId(), shipment.getTo()); + assertSame(lspTourStartEventHandler.getCarrierService().getServiceLinkId(), shipment.getTo()); assertEquals(lspTourStartEventHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(lspTourStartEventHandler.getCarrierService().getDemand(), shipment.getSize()); assertEquals(0, lspTourStartEventHandler.getCarrierService().getServiceStartTimeWindow().getStart(), 0.0); @@ -574,7 +574,7 @@ public void testCompletedLSPScheduling() { //DistributionServiceStart assertInstanceOf(DistributionServiceStartEventHandler.class, eventHandlers.get(5)); DistributionServiceStartEventHandler distributionServiceHandler = (DistributionServiceStartEventHandler) eventHandlers.get(5); - assertSame(distributionServiceHandler.getCarrierService().getLocationLinkId(), shipment.getTo()); + assertSame(distributionServiceHandler.getCarrierService().getServiceLinkId(), shipment.getTo()); assertEquals(distributionServiceHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(distributionServiceHandler.getCarrierService().getDemand(), shipment.getSize()); assertEquals(0, distributionServiceHandler.getCarrierService().getServiceStartTimeWindow().getStart(), 0.0); diff --git a/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/FirstReloadLSPSchedulingTest.java b/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/FirstReloadLSPSchedulingTest.java index 5b724cf6a80..76191192a70 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/FirstReloadLSPSchedulingTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/FirstReloadLSPSchedulingTest.java @@ -259,7 +259,7 @@ public void testFirstReloadLSPScheduling() { CarrierService service = entry.getKey(); LspShipment shipment = entry.getValue().lspShipment; LogisticChainElement element = entry.getValue().logisticChainElement; - assertSame(service.getLocationLinkId(), shipment.getFrom()); + assertSame(service.getServiceLinkId(), shipment.getFrom()); assertEquals(service.getDemand(), shipment.getSize()); assertEquals(service.getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); boolean handledByTranshipmentHub = false; @@ -283,7 +283,7 @@ public void testFirstReloadLSPScheduling() { assertInstanceOf(LSPTourEndEventHandler.class, eventHandlers.getFirst()); LSPTourEndEventHandler endHandler = (LSPTourEndEventHandler) eventHandlers.getFirst(); - assertSame(endHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); + assertSame(endHandler.getCarrierService().getServiceLinkId(), shipment.getFrom()); assertEquals(endHandler.getCarrierService().getDemand(), shipment.getSize()); assertEquals(endHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(endHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); @@ -296,7 +296,7 @@ public void testFirstReloadLSPScheduling() { assertInstanceOf(CollectionServiceEndEventHandler.class, eventHandlers.get(1)); CollectionServiceEndEventHandler serviceHandler = (CollectionServiceEndEventHandler) eventHandlers.get(1); - assertSame(serviceHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); + assertSame(serviceHandler.getCarrierService().getServiceLinkId(), shipment.getFrom()); assertEquals(serviceHandler.getCarrierService().getDemand(), shipment.getSize()); assertEquals(serviceHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(serviceHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); diff --git a/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MainRunLSPSchedulingTest.java b/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MainRunLSPSchedulingTest.java index 8d653d8e171..ce0a83639a8 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MainRunLSPSchedulingTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MainRunLSPSchedulingTest.java @@ -324,7 +324,7 @@ public void testMainRunLSPScheduling() { CarrierService service = entry.getKey(); LspShipment shipment = entry.getValue().lspShipment; LogisticChainElement element = entry.getValue().logisticChainElement; - assertSame(service.getLocationLinkId(), shipment.getFrom()); + assertSame(service.getServiceLinkId(), shipment.getFrom()); assertEquals(service.getDemand(), shipment.getSize()); assertEquals(service.getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); boolean handledByTranshipmentHub = false; @@ -350,7 +350,7 @@ public void testMainRunLSPScheduling() { assertInstanceOf(LSPTourEndEventHandler.class, eventHandlers.getFirst()); LSPTourEndEventHandler endHandler = (LSPTourEndEventHandler) eventHandlers.getFirst(); - assertSame(endHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); + assertSame(endHandler.getCarrierService().getServiceLinkId(), shipment.getFrom()); assertEquals(endHandler.getCarrierService().getDemand(), shipment.getSize()); assertEquals(endHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(endHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); @@ -368,7 +368,7 @@ public void testMainRunLSPScheduling() { //CollectionServiceEnd assertInstanceOf(CollectionServiceEndEventHandler.class, eventHandlers.get(1)); CollectionServiceEndEventHandler serviceHandler = (CollectionServiceEndEventHandler) eventHandlers.get(1); - assertSame(serviceHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); + assertSame(serviceHandler.getCarrierService().getServiceLinkId(), shipment.getFrom()); assertEquals(serviceHandler.getCarrierService().getDemand(), shipment.getSize()); assertEquals(serviceHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(serviceHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); @@ -386,7 +386,7 @@ public void testMainRunLSPScheduling() { //MainRunTourStart assertInstanceOf(LSPTourStartEventHandler.class, eventHandlers.get(2)); LSPTourStartEventHandler mainRunStartHandler = (LSPTourStartEventHandler) eventHandlers.get(2); - assertSame(mainRunStartHandler.getCarrierService().getLocationLinkId(), toLinkId); + assertSame(mainRunStartHandler.getCarrierService().getServiceLinkId(), toLinkId); assertEquals(mainRunStartHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(mainRunStartHandler.getCarrierService().getDemand(), shipment.getSize()); assertEquals(0, mainRunStartHandler.getCarrierService().getServiceStartTimeWindow().getStart(), 0.0); @@ -404,7 +404,7 @@ public void testMainRunLSPScheduling() { //MainRunTourEnd assertInstanceOf(LSPTourEndEventHandler.class, eventHandlers.get(3)); LSPTourEndEventHandler mainRunEndHandler = (LSPTourEndEventHandler) eventHandlers.get(3); - assertSame(mainRunEndHandler.getCarrierService().getLocationLinkId(), toLinkId); + assertSame(mainRunEndHandler.getCarrierService().getServiceLinkId(), toLinkId); assertEquals(mainRunEndHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(mainRunEndHandler.getCarrierService().getDemand(), shipment.getSize()); assertEquals(0, mainRunEndHandler.getCarrierService().getServiceStartTimeWindow().getStart(), 0.0); diff --git a/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsCollectionLSPSchedulingTest.java b/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsCollectionLSPSchedulingTest.java index dd51e2d4e4a..d3fe9b5214d 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsCollectionLSPSchedulingTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsCollectionLSPSchedulingTest.java @@ -198,7 +198,7 @@ public void testCollectionLSPScheduling() { assertInstanceOf(LSPTourEndEventHandler.class, eventHandlers.getFirst()); LSPTourEndEventHandler endHandler = (LSPTourEndEventHandler) eventHandlers.getFirst(); - assertSame(endHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); + assertSame(endHandler.getCarrierService().getServiceLinkId(), shipment.getFrom()); assertEquals(endHandler.getCarrierService().getDemand(), shipment.getSize()); assertEquals(endHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(endHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); @@ -211,7 +211,7 @@ public void testCollectionLSPScheduling() { assertInstanceOf(CollectionServiceEndEventHandler.class, eventHandlers.get(1)); CollectionServiceEndEventHandler serviceHandler = (CollectionServiceEndEventHandler) eventHandlers.get(1); - assertSame(serviceHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); + assertSame(serviceHandler.getCarrierService().getServiceLinkId(), shipment.getFrom()); assertEquals(serviceHandler.getCarrierService().getDemand(), shipment.getSize()); assertEquals(serviceHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(serviceHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); diff --git a/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsCompleteLSPSchedulingTest.java b/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsCompleteLSPSchedulingTest.java index 481c48ec6ba..1a584b463b5 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsCompleteLSPSchedulingTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsCompleteLSPSchedulingTest.java @@ -436,7 +436,7 @@ public void testCompletedLSPScheduling() { CarrierService service = entry.getKey(); LspShipment shipment = entry.getValue().lspShipment; LogisticChainElement element = entry.getValue().logisticChainElement; - assertSame(service.getLocationLinkId(), shipment.getFrom()); + assertSame(service.getServiceLinkId(), shipment.getFrom()); assertEquals(service.getDemand(), shipment.getSize()); assertEquals(service.getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); boolean handledByTranshipmentHub = false; @@ -463,7 +463,7 @@ public void testCompletedLSPScheduling() { CarrierService service = entry.getKey(); LspShipment shipment = entry.getValue().lspShipment; LogisticChainElement element = entry.getValue().logisticChainElement; - assertSame(service.getLocationLinkId(), toLinkId); + assertSame(service.getServiceLinkId(), toLinkId); assertEquals(service.getDemand(), shipment.getSize()); assertEquals(service.getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); boolean handledByTranshipmentHub = false; @@ -487,7 +487,7 @@ public void testCompletedLSPScheduling() { assertInstanceOf(LSPTourEndEventHandler.class, eventHandlers.getFirst()); LSPTourEndEventHandler endHandler = (LSPTourEndEventHandler) eventHandlers.getFirst(); - assertSame(endHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); + assertSame(endHandler.getCarrierService().getServiceLinkId(), shipment.getFrom()); assertEquals(endHandler.getCarrierService().getDemand(), shipment.getSize()); assertEquals(endHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(endHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); @@ -505,7 +505,7 @@ public void testCompletedLSPScheduling() { //CollectionServiceEnd assertInstanceOf(CollectionServiceEndEventHandler.class, eventHandlers.get(1)); CollectionServiceEndEventHandler serviceHandler = (CollectionServiceEndEventHandler) eventHandlers.get(1); - assertSame(serviceHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); + assertSame(serviceHandler.getCarrierService().getServiceLinkId(), shipment.getFrom()); assertEquals(serviceHandler.getCarrierService().getDemand(), shipment.getSize()); assertEquals(serviceHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(serviceHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); @@ -523,7 +523,7 @@ public void testCompletedLSPScheduling() { //MainRunTourStart assertInstanceOf(LSPTourStartEventHandler.class, eventHandlers.get(2)); LSPTourStartEventHandler mainRunStartHandler = (LSPTourStartEventHandler) eventHandlers.get(2); - assertSame(mainRunStartHandler.getCarrierService().getLocationLinkId(), toLinkId); + assertSame(mainRunStartHandler.getCarrierService().getServiceLinkId(), toLinkId); assertEquals(mainRunStartHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(mainRunStartHandler.getCarrierService().getDemand(), shipment.getSize()); assertEquals(0, mainRunStartHandler.getCarrierService().getServiceStartTimeWindow().getStart(), 0.0); @@ -541,7 +541,7 @@ public void testCompletedLSPScheduling() { //MainRunTourEnd assertInstanceOf(LSPTourEndEventHandler.class, eventHandlers.get(3)); LSPTourEndEventHandler mainRunEndHandler = (LSPTourEndEventHandler) eventHandlers.get(3); - assertSame(mainRunEndHandler.getCarrierService().getLocationLinkId(), toLinkId); + assertSame(mainRunEndHandler.getCarrierService().getServiceLinkId(), toLinkId); assertEquals(mainRunEndHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(mainRunEndHandler.getCarrierService().getDemand(), shipment.getSize()); assertEquals(0, mainRunEndHandler.getCarrierService().getServiceStartTimeWindow().getStart(), 0.0); @@ -559,7 +559,7 @@ public void testCompletedLSPScheduling() { //DistributionTourStart assertInstanceOf(LSPTourStartEventHandler.class, eventHandlers.get(4)); LSPTourStartEventHandler lspTourStartEventHandler = (LSPTourStartEventHandler) eventHandlers.get(4); - assertSame(lspTourStartEventHandler.getCarrierService().getLocationLinkId(), shipment.getTo()); + assertSame(lspTourStartEventHandler.getCarrierService().getServiceLinkId(), shipment.getTo()); assertEquals(lspTourStartEventHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(lspTourStartEventHandler.getCarrierService().getDemand(), shipment.getSize()); assertEquals(0, lspTourStartEventHandler.getCarrierService().getServiceStartTimeWindow().getStart(), 0.0); @@ -577,7 +577,7 @@ public void testCompletedLSPScheduling() { //DistributionServiceStart assertInstanceOf(DistributionServiceStartEventHandler.class, eventHandlers.get(5)); DistributionServiceStartEventHandler distributionServiceHandler = (DistributionServiceStartEventHandler) eventHandlers.get(5); - assertSame(distributionServiceHandler.getCarrierService().getLocationLinkId(), shipment.getTo()); + assertSame(distributionServiceHandler.getCarrierService().getServiceLinkId(), shipment.getTo()); assertEquals(distributionServiceHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(distributionServiceHandler.getCarrierService().getDemand(), shipment.getSize()); assertEquals(0, distributionServiceHandler.getCarrierService().getServiceStartTimeWindow().getStart(), 0.0); diff --git a/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsFirstReloadLSPSchedulingTest.java b/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsFirstReloadLSPSchedulingTest.java index eb6af700893..4d41d635e10 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsFirstReloadLSPSchedulingTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsFirstReloadLSPSchedulingTest.java @@ -258,7 +258,7 @@ public void testFirstReloadLSPScheduling() { CarrierService service = entry.getKey(); LspShipment shipment = entry.getValue().lspShipment; LogisticChainElement element = entry.getValue().logisticChainElement; - assertSame(service.getLocationLinkId(), shipment.getFrom()); + assertSame(service.getServiceLinkId(), shipment.getFrom()); assertEquals(service.getDemand(), shipment.getSize()); assertEquals(service.getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); boolean handledByTranshipmentHub = false; @@ -282,7 +282,7 @@ public void testFirstReloadLSPScheduling() { assertInstanceOf(LSPTourEndEventHandler.class, eventHandlers.getFirst()); LSPTourEndEventHandler endHandler = (LSPTourEndEventHandler) eventHandlers.getFirst(); - assertSame(endHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); + assertSame(endHandler.getCarrierService().getServiceLinkId(), shipment.getFrom()); assertEquals(endHandler.getCarrierService().getDemand(), shipment.getSize()); assertEquals(endHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(endHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); @@ -295,7 +295,7 @@ public void testFirstReloadLSPScheduling() { assertInstanceOf(CollectionServiceEndEventHandler.class, eventHandlers.get(1)); CollectionServiceEndEventHandler serviceHandler = (CollectionServiceEndEventHandler) eventHandlers.get(1); - assertSame(serviceHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); + assertSame(serviceHandler.getCarrierService().getServiceLinkId(), shipment.getFrom()); assertEquals(serviceHandler.getCarrierService().getDemand(), shipment.getSize()); assertEquals(serviceHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(serviceHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); diff --git a/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsMainRunLSPSchedulingTest.java b/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsMainRunLSPSchedulingTest.java index f82bde886c8..b63c6d854d4 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsMainRunLSPSchedulingTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsMainRunLSPSchedulingTest.java @@ -324,7 +324,7 @@ public void testMainRunLSPScheduling() { CarrierService service = entry.getKey(); LspShipment shipment = entry.getValue().lspShipment; LogisticChainElement element = entry.getValue().logisticChainElement; - assertSame(service.getLocationLinkId(), shipment.getFrom()); + assertSame(service.getServiceLinkId(), shipment.getFrom()); assertEquals(service.getDemand(), shipment.getSize()); assertEquals(service.getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); boolean handledByTranshipmentHub = false; @@ -350,7 +350,7 @@ public void testMainRunLSPScheduling() { assertInstanceOf(LSPTourEndEventHandler.class, eventHandlers.getFirst()); LSPTourEndEventHandler endHandler = (LSPTourEndEventHandler) eventHandlers.getFirst(); - assertSame(endHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); + assertSame(endHandler.getCarrierService().getServiceLinkId(), shipment.getFrom()); assertEquals(endHandler.getCarrierService().getDemand(), shipment.getSize()); assertEquals(endHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(endHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); @@ -368,7 +368,7 @@ public void testMainRunLSPScheduling() { //CollectionServiceEnd assertInstanceOf(CollectionServiceEndEventHandler.class, eventHandlers.get(1)); CollectionServiceEndEventHandler serviceHandler = (CollectionServiceEndEventHandler) eventHandlers.get(1); - assertSame(serviceHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); + assertSame(serviceHandler.getCarrierService().getServiceLinkId(), shipment.getFrom()); assertEquals(serviceHandler.getCarrierService().getDemand(), shipment.getSize()); assertEquals(serviceHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(serviceHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); @@ -386,7 +386,7 @@ public void testMainRunLSPScheduling() { //MainRunTourStart assertInstanceOf(LSPTourStartEventHandler.class, eventHandlers.get(2)); LSPTourStartEventHandler mainRunStartHandler = (LSPTourStartEventHandler) eventHandlers.get(2); - assertSame(mainRunStartHandler.getCarrierService().getLocationLinkId(), toLinkId); + assertSame(mainRunStartHandler.getCarrierService().getServiceLinkId(), toLinkId); assertEquals(mainRunStartHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(mainRunStartHandler.getCarrierService().getDemand(), shipment.getSize()); assertEquals(0, mainRunStartHandler.getCarrierService().getServiceStartTimeWindow().getStart(), 0.0); @@ -404,7 +404,7 @@ public void testMainRunLSPScheduling() { //MainRunEnd assertInstanceOf(LSPTourEndEventHandler.class, eventHandlers.get(3)); LSPTourEndEventHandler mainRunEndHandler = (LSPTourEndEventHandler) eventHandlers.get(3); - assertSame(mainRunEndHandler.getCarrierService().getLocationLinkId(), toLinkId); + assertSame(mainRunEndHandler.getCarrierService().getServiceLinkId(), toLinkId); assertEquals(mainRunEndHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(mainRunEndHandler.getCarrierService().getDemand(), shipment.getSize()); assertEquals(0, mainRunEndHandler.getCarrierService().getServiceStartTimeWindow().getStart(), 0.0); diff --git a/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsSecondReloadLSPSchedulingTest.java b/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsSecondReloadLSPSchedulingTest.java index 403bf619d90..03f374b15f0 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsSecondReloadLSPSchedulingTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsSecondReloadLSPSchedulingTest.java @@ -368,7 +368,7 @@ public void testSecondReloadLSPScheduling() { CarrierService service = entry.getKey(); LspShipment shipment = entry.getValue().lspShipment; LogisticChainElement element = entry.getValue().logisticChainElement; - assertSame(service.getLocationLinkId(), shipment.getFrom()); + assertSame(service.getServiceLinkId(), shipment.getFrom()); assertEquals(service.getDemand(), shipment.getSize()); assertEquals(service.getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); boolean handledByTranshipmentHub = false; @@ -400,7 +400,7 @@ public void testSecondReloadLSPScheduling() { CarrierService service = entry.getKey(); LspShipment shipment = entry.getValue().lspShipment; LogisticChainElement element = entry.getValue().logisticChainElement; - assertSame(service.getLocationLinkId(), toLinkId); + assertSame(service.getServiceLinkId(), toLinkId); assertEquals(service.getDemand(), shipment.getSize()); assertEquals(service.getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); boolean handledByTranshipmentHub = false; @@ -430,7 +430,7 @@ public void testSecondReloadLSPScheduling() { { assertInstanceOf(LSPTourEndEventHandler.class, eventHandlers.getFirst()); LSPTourEndEventHandler collectionEndHandler = (LSPTourEndEventHandler) eventHandlers.getFirst(); - assertSame(collectionEndHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); + assertSame(collectionEndHandler.getCarrierService().getServiceLinkId(), shipment.getFrom()); assertEquals(collectionEndHandler.getCarrierService().getDemand(), shipment.getSize()); assertEquals(collectionEndHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(collectionEndHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); @@ -449,7 +449,7 @@ public void testSecondReloadLSPScheduling() { {//CollectionServiceEnd assertInstanceOf(CollectionServiceEndEventHandler.class, eventHandlers.get(1)); CollectionServiceEndEventHandler collectionServiceHandler = (CollectionServiceEndEventHandler) eventHandlers.get(1); - assertSame(collectionServiceHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); + assertSame(collectionServiceHandler.getCarrierService().getServiceLinkId(), shipment.getFrom()); assertEquals(collectionServiceHandler.getCarrierService().getDemand(), shipment.getSize()); assertEquals(collectionServiceHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(collectionServiceHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); @@ -468,7 +468,7 @@ public void testSecondReloadLSPScheduling() { {//MainRunStart assertInstanceOf(LSPTourStartEventHandler.class, eventHandlers.get(2)); LSPTourStartEventHandler mainRunStartHandler = (LSPTourStartEventHandler) eventHandlers.get(2); - assertSame(mainRunStartHandler.getCarrierService().getLocationLinkId(), toLinkId); + assertSame(mainRunStartHandler.getCarrierService().getServiceLinkId(), toLinkId); assertEquals(mainRunStartHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(mainRunStartHandler.getCarrierService().getDemand(), shipment.getSize()); assertEquals(0, mainRunStartHandler.getCarrierService().getServiceStartTimeWindow().getStart(), 0.0); @@ -487,7 +487,7 @@ public void testSecondReloadLSPScheduling() { {//MainRunEnd assertInstanceOf(LSPTourEndEventHandler.class, eventHandlers.get(3)); LSPTourEndEventHandler mainRunEndHandler = (LSPTourEndEventHandler) eventHandlers.get(3); - assertSame(mainRunEndHandler.getCarrierService().getLocationLinkId(), toLinkId); + assertSame(mainRunEndHandler.getCarrierService().getServiceLinkId(), toLinkId); assertEquals(mainRunEndHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(mainRunEndHandler.getCarrierService().getDemand(), shipment.getSize()); assertEquals(0, mainRunEndHandler.getCarrierService().getServiceStartTimeWindow().getStart(), 0.0); diff --git a/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/SecondReloadLSPSchedulingTest.java b/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/SecondReloadLSPSchedulingTest.java index 08dbac36e8b..66a30fa10d4 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/SecondReloadLSPSchedulingTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/SecondReloadLSPSchedulingTest.java @@ -368,7 +368,7 @@ public void testSecondReloadLSPScheduling() { CarrierService service = entry.getKey(); LspShipment shipment = entry.getValue().lspShipment; LogisticChainElement element = entry.getValue().logisticChainElement; - assertSame(service.getLocationLinkId(), shipment.getFrom()); + assertSame(service.getServiceLinkId(), shipment.getFrom()); assertEquals(service.getDemand(), shipment.getSize()); assertEquals(service.getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); boolean handledByTranshipmentHub = false; @@ -406,7 +406,7 @@ public void testSecondReloadLSPScheduling() { CarrierService service = entry.getKey(); LspShipment shipment = entry.getValue().lspShipment; LogisticChainElement element = entry.getValue().logisticChainElement; - assertSame(service.getLocationLinkId(), toLinkId); + assertSame(service.getServiceLinkId(), toLinkId); assertEquals(service.getDemand(), shipment.getSize()); assertEquals(service.getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); boolean handledByTranshipmentHub = false; @@ -437,7 +437,7 @@ public void testSecondReloadLSPScheduling() { {//CollectionTourEnd assertInstanceOf(LSPTourEndEventHandler.class, eventHandlers.getFirst()); LSPTourEndEventHandler collectionEndHandler = (LSPTourEndEventHandler) eventHandlers.getFirst(); - assertSame(collectionEndHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); + assertSame(collectionEndHandler.getCarrierService().getServiceLinkId(), shipment.getFrom()); assertEquals(collectionEndHandler.getCarrierService().getDemand(), shipment.getSize()); assertEquals(collectionEndHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(collectionEndHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); @@ -456,7 +456,7 @@ public void testSecondReloadLSPScheduling() { {//CollectionServiceEnd assertInstanceOf(CollectionServiceEndEventHandler.class, eventHandlers.get(1)); CollectionServiceEndEventHandler collectionServiceHandler = (CollectionServiceEndEventHandler) eventHandlers.get(1); - assertSame(collectionServiceHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); + assertSame(collectionServiceHandler.getCarrierService().getServiceLinkId(), shipment.getFrom()); assertEquals(collectionServiceHandler.getCarrierService().getDemand(), shipment.getSize()); assertEquals(collectionServiceHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(collectionServiceHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); @@ -475,7 +475,7 @@ public void testSecondReloadLSPScheduling() { {//MainRunStart assertInstanceOf(LSPTourStartEventHandler.class, eventHandlers.get(2)); LSPTourStartEventHandler mainRunStartHandler = (LSPTourStartEventHandler) eventHandlers.get(2); - assertSame(mainRunStartHandler.getCarrierService().getLocationLinkId(), toLinkId); + assertSame(mainRunStartHandler.getCarrierService().getServiceLinkId(), toLinkId); assertEquals(mainRunStartHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(mainRunStartHandler.getCarrierService().getDemand(), shipment.getSize()); assertEquals(0, mainRunStartHandler.getCarrierService().getServiceStartTimeWindow().getStart(), 0.0); @@ -494,7 +494,7 @@ public void testSecondReloadLSPScheduling() { {//MainRunEnd assertInstanceOf(LSPTourEndEventHandler.class, eventHandlers.get(3)); LSPTourEndEventHandler mainRunEndHandler = (LSPTourEndEventHandler) eventHandlers.get(3); - assertSame(mainRunEndHandler.getCarrierService().getLocationLinkId(), toLinkId); + assertSame(mainRunEndHandler.getCarrierService().getServiceLinkId(), toLinkId); assertEquals(mainRunEndHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(mainRunEndHandler.getCarrierService().getDemand(), shipment.getSize()); assertEquals(0, mainRunEndHandler.getCarrierService().getServiceStartTimeWindow().getStart(), 0.0); diff --git a/contribs/freightreceiver/src/main/java/org/matsim/freight/receiver/ReceiverControlerListener.java b/contribs/freightreceiver/src/main/java/org/matsim/freight/receiver/ReceiverControlerListener.java index 852452663a6..a35dddecc24 100644 --- a/contribs/freightreceiver/src/main/java/org/matsim/freight/receiver/ReceiverControlerListener.java +++ b/contribs/freightreceiver/src/main/java/org/matsim/freight/receiver/ReceiverControlerListener.java @@ -178,7 +178,7 @@ private void linkReceiverTimeWindowToCarrierTourPosition() throws IOException { String shipmentId = act.getShipment().getId().toString(); if (act.getActivityType().equalsIgnoreCase("delivery")) { - Id linkId = act.getShipment().getTo(); + Id linkId = act.getShipment().getDeliveryLinkId(); if (!receiverLinkMap.containsKey(linkId)) { LOG.error("Woops, the carrier is delivering a shipment to an unknown receiver!"); throw new RuntimeException("Don't know to whom delivery is."); diff --git a/contribs/small-scale-traffic-generation/src/main/java/org/matsim/smallScaleCommercialTrafficGeneration/DefaultIntegrateExistingTrafficToSmallScaleCommercialImpl.java b/contribs/small-scale-traffic-generation/src/main/java/org/matsim/smallScaleCommercialTrafficGeneration/DefaultIntegrateExistingTrafficToSmallScaleCommercialImpl.java index 6652c17b955..052fb62b9f1 100644 --- a/contribs/small-scale-traffic-generation/src/main/java/org/matsim/smallScaleCommercialTrafficGeneration/DefaultIntegrateExistingTrafficToSmallScaleCommercialImpl.java +++ b/contribs/small-scale-traffic-generation/src/main/java/org/matsim/smallScaleCommercialTrafficGeneration/DefaultIntegrateExistingTrafficToSmallScaleCommercialImpl.java @@ -372,8 +372,8 @@ public void reduceDemandBasedOnExistingCarriers(Scenario scenario, Map createListOfCarrierWithUnhandledJobs(Scenario scenario){ private void redrawAllServiceDurations(Carrier carrier, GenerateSmallScaleCommercialTrafficDemand.CarrierAttributes carrierAttributes, int additionalTravelBufferPerIterationInMinutes) { for (CarrierService service : carrier.getServices().values()) { double newServiceDuration = generator.getServiceTimePerStop(carrier, carrierAttributes, additionalTravelBufferPerIterationInMinutes); - CarrierService redrawnService = CarrierService.Builder.newInstance(service.getId(), service.getLocationLinkId()) + CarrierService redrawnService = CarrierService.Builder.newInstance(service.getId(), service.getServiceLinkId()) .setServiceDuration(newServiceDuration).setServiceStartTimeWindow(service.getServiceStartTimeWindow()).build(); carrier.getServices().put(redrawnService.getId(), redrawnService); } diff --git a/contribs/vsp/src/main/java/org/matsim/freight/carriers/analysis/FreightAnalysisEventHandler.java b/contribs/vsp/src/main/java/org/matsim/freight/carriers/analysis/FreightAnalysisEventHandler.java index 2f322e8640f..3b159189bda 100644 --- a/contribs/vsp/src/main/java/org/matsim/freight/carriers/analysis/FreightAnalysisEventHandler.java +++ b/contribs/vsp/src/main/java/org/matsim/freight/carriers/analysis/FreightAnalysisEventHandler.java @@ -391,8 +391,8 @@ public void exportShipmentInfo(String path, Boolean exportGuesses) { if (shipmentTracker == null) { continue; } - Id from = shipment.getFrom(); - Id toLink = shipment.getTo(); + Id from = shipment.getPickupLinkId(); + Id toLink = shipment.getDeliveryLinkId(); // if info is not certain, export the guess if that is wanted. String carrierIdString = id2String(carrier.getId()); String shipmentIdString = id2String(shipment.getId()); diff --git a/contribs/vsp/src/main/java/org/matsim/freight/carriers/analysis/FreightAnalysisServiceTracking.java b/contribs/vsp/src/main/java/org/matsim/freight/carriers/analysis/FreightAnalysisServiceTracking.java index 88ee09b7b5c..b0e668fdc2f 100644 --- a/contribs/vsp/src/main/java/org/matsim/freight/carriers/analysis/FreightAnalysisServiceTracking.java +++ b/contribs/vsp/src/main/java/org/matsim/freight/carriers/analysis/FreightAnalysisServiceTracking.java @@ -57,7 +57,7 @@ public void addTracker(CarrierService service, Id id) { public void trackServiceActivityStart(ActivityStartEvent activityStartEvent) { for (ServiceTracker.CarrierServiceTracker cst: carrierServiceTrackers.values()) { for (ServiceTracker service : cst.serviceTrackers.values()) { - if (service.service.getLocationLinkId().equals(activityStartEvent.getLinkId())) { + if (service.service.getServiceLinkId().equals(activityStartEvent.getLinkId())) { if (service.driverId == null) { // if there is no driver, but there is a service which is to be performed at the moment at this place, we guess this could be the event for it. // (Does not work well obviously as soon as there are multiple services at a location that have generous time windows, like e.g. at stores). diff --git a/contribs/vsp/src/main/java/org/matsim/freight/carriers/analysis/FreightAnalysisShipmentTracking.java b/contribs/vsp/src/main/java/org/matsim/freight/carriers/analysis/FreightAnalysisShipmentTracking.java index 91613aa1d34..5673a46b530 100644 --- a/contribs/vsp/src/main/java/org/matsim/freight/carriers/analysis/FreightAnalysisShipmentTracking.java +++ b/contribs/vsp/src/main/java/org/matsim/freight/carriers/analysis/FreightAnalysisShipmentTracking.java @@ -128,8 +128,8 @@ class ShipmentTracker { public ShipmentTracker(CarrierShipment shipment) { this.id = shipment.getId(); - this.from = shipment.getFrom(); - this.to=shipment.getTo(); + this.from = shipment.getPickupLinkId(); + this.to=shipment.getDeliveryLinkId(); this.shipment=shipment; } From 9e65b096c6e722847ad7bae721285083d6e2ff9d Mon Sep 17 00:00:00 2001 From: Kai Martins-Turner Date: Fri, 20 Dec 2024 14:56:49 +0100 Subject: [PATCH 17/18] reorganisation of code --- .../freight/carriers/CarrierShipment.java | 35 ++++++++++--------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierShipment.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierShipment.java index a78e636ee49..748b9f0a412 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierShipment.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierShipment.java @@ -254,7 +254,7 @@ public double getDeliveryDuration() { /** * Do we really need the setter? We do have it in the builder. * I do not see, why we should be able to update it, since most of the values are immutable. - * @deprecated Consider setting it using the Builder. This will maybe be removed and the field gets immutable.. + * @deprecated Consider setting it using the Builder. This will maybe be removed and the field gets immutable. * kturner, dec'24 */ @Deprecated(since = "dec'24") @@ -265,7 +265,7 @@ public void setPickupDuration(double pickupDuration) { /** * Do we really need the setter? We do have it in the builder. * I do not see, why we should be able to update it, since most of the values are immutable. - * @deprecated Consider setting it using the Builder. This will maybe be removed and the field gets immutable.. + * @deprecated Consider setting it using the Builder. This will maybe be removed and the field gets immutable. * kturner, dec'24 */ @Deprecated(since = "dec'24") @@ -317,6 +317,7 @@ public int getSize() { return getDemand(); } + /** * @deprecated please inline and use {@link #getPickupLinkId()} instead */ @@ -325,14 +326,6 @@ public Id getFrom() { return getPickupLinkId(); } - /** - * @deprecated please inline and use {@link #getDeliveryLinkId()} instead - */ - @Deprecated(since = "dec'24") - public Id getTo() { - return getDeliveryLinkId(); - } - /** * @deprecated please inline and use {@link #getPickupStartsTimeWindow()} instead */ @@ -341,13 +334,12 @@ public TimeWindow getPickupTimeWindow() { return getPickupStartsTimeWindow(); } - /** - * @deprecated please inline and use {@link #getDeliveryStartsTimeWindow()} instead + * @deprecated please inline and use {@link #setPickupDuration(double)} instead */ @Deprecated(since = "dec'24") - public TimeWindow getDeliveryTimeWindow() { - return getDeliveryStartsTimeWindow(); + public void setPickupServiceTime(double pickupDuration) { + setPickupDuration(pickupDuration); } /** @@ -358,12 +350,21 @@ public double getPickupServiceTime() { return getPickupDuration(); } + /** - * @deprecated please inline and use {@link #setPickupDuration(double)} instead + * @deprecated please inline and use {@link #getDeliveryLinkId()} instead */ @Deprecated(since = "dec'24") - public void setPickupServiceTime(double pickupDuration) { - setPickupDuration(pickupDuration); + public Id getTo() { + return getDeliveryLinkId(); + } + + /** + * @deprecated please inline and use {@link #getDeliveryStartsTimeWindow()} instead + */ + @Deprecated(since = "dec'24") + public TimeWindow getDeliveryTimeWindow() { + return getDeliveryStartsTimeWindow(); } /** From 060dde94b39a58dd20f6c0f3200229bc54cebc9d Mon Sep 17 00:00:00 2001 From: Kai Martins-Turner Date: Fri, 20 Dec 2024 15:19:33 +0100 Subject: [PATCH 18/18] remove long-time deprecated constructor / newInstance(...)-method in CarrierShipment.Builder --- .../freight/carriers/CarrierShipment.java | 34 ++----------------- 1 file changed, 2 insertions(+), 32 deletions(-) diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierShipment.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierShipment.java index 748b9f0a412..a74177246d5 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierShipment.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierShipment.java @@ -62,28 +62,10 @@ public static class Builder { private TimeWindow deliveryStartsTimeWindow = TimeWindow.newInstance(0.0, Integer.MAX_VALUE); private double deliveryDuration = 0.0; - /** - * @deprecated Please use Builder newInstance(Id id, Id from, Id to, int size) instead. - *

* Returns a new shipment builder. - *

The builder is init with the shipment's origin (from), destination (to) and with the shipment's size. - * The default-value for serviceTime is 0.0. The default-value for a timeWindow is [start=0.0, end=Double.maxValue()]. - * - * @param from the origin - * @param to the destination - * @param size size of the shipment - * @return the builder - */ - @Deprecated - public static Builder newInstance(Id from, Id to, int size){ - var id = Id.create(CarrierConstants.SHIPMENT +"_" + from.toString() + "_" + to.toString(), CarrierShipment.class); - return new Builder(id, from,to,size); - } - - /** - * Returns a new shipment builder. - *

The builder is init with the shipment's origin (from), destination (to) and with the shipment's demand. + *

+ * The builder is init with the shipment's origin (from), destination (to) and with the shipment's demand. * The default-value for serviceTime is 0.0. The default-value for a timeWindow is [start=0.0, end=Double.maxValue()]. * * @param id the id of the shipment @@ -96,18 +78,6 @@ public static Builder newInstance(Id id, Id from, Id id, Id from, Id to, int size) instead. - */ - @Deprecated - public Builder(Id pickupLinkId, Id deliveryLinkId, int demand) { - super(); - this.id = Id.create(CarrierConstants.SHIPMENT +"_" + pickupLinkId.toString() + "_" + deliveryLinkId.toString(), CarrierShipment.class); - this.pickupLinkId = pickupLinkId; - this.deliveryLinkId = deliveryLinkId; - this.demand = demand; - } - private Builder(Id id, Id pickupLinkId, Id deliveryLinkId, int demand) { super(); this.id = id;