Skip to content

Commit 90cedbe

Browse files
nkuehnelrakowkainageltschlentherdependabot[bot]
authored
Update MATSim CW30 (#106)
* Score explanation functionality * rename a method from add... to set... since that is what is does. * changes * update config group * update tests and added attributes * fix un initialized attribute * small improvement to object creation * add leg score for individual legs * more consistent naming * more consistent naming * revert unintentional changes * CreateDrtDashboard * Bump org.apache.maven.plugins:maven-failsafe-plugin from 3.2.5 to 3.3.0 Bumps [org.apache.maven.plugins:maven-failsafe-plugin](https://github.com/apache/maven-surefire) from 3.2.5 to 3.3.0. - [Release notes](https://github.com/apache/maven-surefire/releases) - [Commits](apache/maven-surefire@surefire-3.2.5...surefire-3.3.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-failsafe-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * rename pooling ratio to occupancy rate * account for group bookings in DrtAnalysisPostProcessing (and thus DrtDashboard) * typo in CreateDrtDashboard * fix wrong sum calculation * debug NoiseAnalysis and proper testing in NoiseDashboardTests * fix wrong map selection * add reduction of numberOfJobs * add comments and format log massages * combine * rename parameter * reduce code * format logging * use method for demand calculating * use method for shipment creation * remove todo * use method to calculate demand based on link lengths * introduce parameter * simplify * cleanup * Support TransitRouteStops where boarding or alighting is not allowed In reality, there are trains that call at stops but where it might not be allowed to enter or exit such trains. Examples are night trains, where on the first few stops, only boarding is allowed, while at the last few stops only alighting is allowed. This means that it is not allowed to use such night trains to just travel between the first few stops. This commit adds two optional attributes `allowBoarding` and `allowAlighting` to TransitRouteStops, with the default value being true for backwards compatibility and when the attribute is not specified. SwissRailRaptor respects these attributes and will not return routes where agents would enter a vehicle at a route stop where boarding is not allowed, or where agents would exit a vehicle at a route stop where alighting is not allowed. * make drt shifts multi mode drt comatible * adjust shift efficiency tracker as well * Extended Trip analysis and dashboard (matsim-org#3332) * trip analysis for subgroups * refactor categories * write trip analysis * write out correct table * use static method * prepare for facets, add TODOs * start working on plotly facet integration * Added Test Trip Dashboard for Facets * update API * add trip choice analysis * adding test case and some todos * calculating some trip choice metrics * add choice metrics to trip dashboard * hide tab if not needed * add text box and round metrics * normalize shares per reference group correctly, added some facet dashboards (WIP) * fix pivot usage * rename entries * add plots for distance distributions * add todo * use dropdown for plots * add cohen kappa to evaluation * output euclidean distance for trip choices * add ref_id attribute * added heatmap to TripDashboard * update description * allow arbitrary object for ref ids * show heatmap labels * comment out trip dashboard wip part * use correct logger * improve wording --------- Co-authored-by: frievoe97 <friedrich.voelkers@me.com> * Bump org.apache.maven.plugins:maven-surefire-plugin from 3.2.5 to 3.3.0 Bumps [org.apache.maven.plugins:maven-surefire-plugin](https://github.com/apache/maven-surefire) from 3.2.5 to 3.3.0. - [Release notes](https://github.com/apache/maven-surefire/releases) - [Commits](apache/maven-surefire@surefire-3.2.5...surefire-3.3.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-surefire-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * Bump org.apache.maven.plugins:maven-surefire-report-plugin Bumps [org.apache.maven.plugins:maven-surefire-report-plugin](https://github.com/apache/maven-surefire) from 3.2.5 to 3.3.0. - [Release notes](https://github.com/apache/maven-surefire/releases) - [Commits](apache/maven-surefire@surefire-3.2.5...surefire-3.3.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-surefire-report-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * Bump org.apache.maven.plugins:maven-jar-plugin from 3.4.1 to 3.4.2 Bumps [org.apache.maven.plugins:maven-jar-plugin](https://github.com/apache/maven-jar-plugin) from 3.4.1 to 3.4.2. - [Release notes](https://github.com/apache/maven-jar-plugin/releases) - [Commits](apache/maven-jar-plugin@maven-jar-plugin-3.4.1...maven-jar-plugin-3.4.2) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-jar-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> * Bump com.fasterxml.woodstox:woodstox-core from 6.6.2 to 7.0.0 Bumps [com.fasterxml.woodstox:woodstox-core](https://github.com/FasterXML/woodstox) from 6.6.2 to 7.0.0. - [Commits](FasterXML/woodstox@woodstox-core-6.6.2...woodstox-core-7.0.0) --- updated-dependencies: - dependency-name: com.fasterxml.woodstox:woodstox-core dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> * Bump org.jfree:jfreechart from 1.5.4 to 1.5.5 Bumps [org.jfree:jfreechart](https://github.com/jfree/jfreechart) from 1.5.4 to 1.5.5. - [Release notes](https://github.com/jfree/jfreechart/releases) - [Commits](jfree/jfreechart@v1.5.4...v1.5.5) --- updated-dependencies: - dependency-name: org.jfree:jfreechart dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> * make drt work with only custom constraints sets * add some logging to NetworkChangeEventsWriter * correct logging statement * add router binding for complex request unscheduling * use time as disutility * Bump junit.version from 5.10.2 to 5.10.3 Bumps `junit.version` from 5.10.2 to 5.10.3. Updates `org.junit.jupiter:junit-jupiter-engine` from 5.10.2 to 5.10.3 - [Release notes](https://github.com/junit-team/junit5/releases) - [Commits](junit-team/junit5@r5.10.2...r5.10.3) Updates `org.junit.jupiter:junit-jupiter` from 5.10.2 to 5.10.3 - [Release notes](https://github.com/junit-team/junit5/releases) - [Commits](junit-team/junit5@r5.10.2...r5.10.3) --- updated-dependencies: - dependency-name: org.junit.jupiter:junit-jupiter-engine dependency-type: direct:development update-type: version-update:semver-patch - dependency-name: org.junit.jupiter:junit-jupiter dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> * norm subgroups to 1 (matsim-org#3346) * add test integration test case for complex unscheduler * Bump io.grpc:grpc-all from 1.64.0 to 1.65.0 Bumps [io.grpc:grpc-all](https://github.com/grpc/grpc-java) from 1.64.0 to 1.65.0. - [Release notes](https://github.com/grpc/grpc-java/releases) - [Commits](grpc/grpc-java@v1.64.0...v1.65.0) --- updated-dependencies: - dependency-name: io.grpc:grpc-all dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * Bump com.google.protobuf:protobuf-java from 4.27.1 to 4.27.2 Bumps [com.google.protobuf:protobuf-java](https://github.com/protocolbuffers/protobuf) from 4.27.1 to 4.27.2. - [Release notes](https://github.com/protocolbuffers/protobuf/releases) - [Changelog](https://github.com/protocolbuffers/protobuf/blob/main/protobuf_release.bzl) - [Commits](https://github.com/protocolbuffers/protobuf/commits) --- updated-dependencies: - dependency-name: com.google.protobuf:protobuf-java dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> * Split CalculateSkimMatrices.prepareAndCalculateNetworkMatrices() to allow for custom travel times objects * Bump org.checkerframework:checker-qual from 3.44.0 to 3.45.0 Bumps [org.checkerframework:checker-qual](https://github.com/typetools/checker-framework) from 3.44.0 to 3.45.0. - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](typetools/checker-framework@checker-framework-3.44.0...checker-framework-3.45.0) --- updated-dependencies: - dependency-name: org.checkerframework:checker-qual dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * Switch to DrtWithExtensionsConfigGroup * Bump org.apache.poi:poi-ooxml from 5.2.5 to 5.3.0 Bumps org.apache.poi:poi-ooxml from 5.2.5 to 5.3.0. --- updated-dependencies: - dependency-name: org.apache.poi:poi-ooxml dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * reworked CreatePseudoNetwork with loop-links to avoid duplicating stops * Trip facet dashboard (matsim-org#3350) * implement dropdown facets on the trip dashboard * implement dropdown facets on the trip dashboard * added backgroundColor attribute and restyled text seperators * set backgroundcolor on all plots --------- Co-authored-by: rakow <rakow@users.noreply.github.com> * adjust rounding * exclude case * Drt dashboard typo fix (matsim-org#3360) * added tooltip for gridmap/emissionsDashboard * fix typo in drt dashboard --------- Co-authored-by: rakow <rakow@users.noreply.github.com> * Bump com.fasterxml.jackson:jackson-bom from 2.17.1 to 2.17.2 Bumps [com.fasterxml.jackson:jackson-bom](https://github.com/FasterXML/jackson-bom) from 2.17.1 to 2.17.2. - [Commits](FasterXML/jackson-bom@jackson-bom-2.17.1...jackson-bom-2.17.2) --- updated-dependencies: - dependency-name: com.fasterxml.jackson:jackson-bom dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> * Bump net.bytebuddy:byte-buddy from 1.14.17 to 1.14.18 Bumps [net.bytebuddy:byte-buddy](https://github.com/raphw/byte-buddy) from 1.14.17 to 1.14.18. - [Release notes](https://github.com/raphw/byte-buddy/releases) - [Changelog](https://github.com/raphw/byte-buddy/blob/master/release-notes.md) - [Commits](raphw/byte-buddy@byte-buddy-1.14.17...byte-buddy-1.14.18) --- updated-dependencies: - dependency-name: net.bytebuddy:byte-buddy dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> * set networkMode based on vehicleTypes * Bump org.assertj:assertj-core from 3.26.0 to 3.26.3 Bumps [org.assertj:assertj-core](https://github.com/assertj/assertj) from 3.26.0 to 3.26.3. - [Release notes](https://github.com/assertj/assertj/releases) - [Commits](assertj/assertj@assertj-build-3.26.0...assertj-build-3.26.3) --- updated-dependencies: - dependency-name: org.assertj:assertj-core dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> * chore: clean up MinimalTransferTimes (matsim-org#3365) * chore: cleanup adaptive transfers (matsim-org#3366) * chore: cleanup adaptvie transfers * make final * Bump org.apache.maven.plugins:maven-failsafe-plugin from 3.3.0 to 3.3.1 Bumps [org.apache.maven.plugins:maven-failsafe-plugin](https://github.com/apache/maven-surefire) from 3.3.0 to 3.3.1. - [Release notes](https://github.com/apache/maven-surefire/releases) - [Commits](apache/maven-surefire@surefire-3.3.0...surefire-3.3.1) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-failsafe-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> * add missing case of enum * add functionality to split jobs * use new methods * update activity creation * set activity time correctly * remove unneeded exception * change to parameterized log message * delete empty test methods * remove unused import * fix unchecked assignment * remove redundant local variables * minor code style update * remove not needed throw information * make things final * remove redundant final declaration * remove unnecessary 'throws' declarations * simplify assertions * cleanup Strings * remove redundant casts * code style update * cleanup imports * Java language: Replace explicit type with <> * Java language: use computeIfAbsent * Java language: use Double.hashCode(...) * Java language: replace if by switch * Java language: avoid raw use * Java language: use text block * Java language: use pattern variable * Java language: use add/getFirst() * Access to TestUtils.EPSILION * add not null assertion * remove one layer of "LSPs" * add prebooking support for drt shifts some minor shift cleanups possibility to assign requests to shifts that are assigned bot not started yet * cancel assigned shifts * add some documentation * shift drt maintenance * some more drt shift maintenance * consider break corridors for (pre)bookings * consider break corridors for (pre)bookings * clean up obsolete method * update FISS test, reduce iterations to reduce runtime * avoid abandoning prebooked requests twice in the same time step --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: rakow <rakow@vsp.tu-berlin.de> Co-authored-by: Kai Nagel <nagel@vsp.tu-berlin.de> Co-authored-by: kainagel <kainagel@users.noreply.github.com> Co-authored-by: rakow <rakow@users.noreply.github.com> Co-authored-by: schlenther <schlenther@vsp.tu-berlin.de> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Ricardo Ewert <ewert@vsp.tu-berlin.de> Co-authored-by: Ricardo Ewert <60344745+rewertvsp@users.noreply.github.com> Co-authored-by: Marcel Rieser <rieser@simunto.com> Co-authored-by: frievoe97 <friedrich.voelkers@me.com> Co-authored-by: Joschka Bischoff <joschka.bischoff@sbb.ch> Co-authored-by: Michal Maciejewski <michalmac@users.noreply.github.com> Co-authored-by: marecabo <23156476+marecabo@users.noreply.github.com> Co-authored-by: steffenaxer <26229392+steffenaxer@users.noreply.github.com> Co-authored-by: u229351 <davi.guggisberg@sbb.ch> Co-authored-by: frievoe97 <44405087+frievoe97@users.noreply.github.com> Co-authored-by: Sebastian Hörl <sebastian.horl@irt-systemx.fr> Co-authored-by: Kai Martins-Turner <martins-turner@vsp.tu-berlin.de> Co-authored-by: Kai Martins-Turner <kt86@users.noreply.github.com>
1 parent 1627fbc commit 90cedbe

File tree

105 files changed

+1362
-850
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+1362
-850
lines changed

contribs/application/src/main/java/org/matsim/freightDemandGeneration/DemandReaderFromCSV.java

Lines changed: 82 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -667,18 +667,25 @@ else if (samplingOption.equals("changeDemandOnLocation")) {
667667
int demandForThisLink = calculateDemandBasedOnLinkLength(countOfLinks, distributedDemand, demandToDistribute, possibleLinksForService.size(),
668668
sumOfPossibleLinkLength, link);
669669
countOfLinks++;
670-
double serviceTime = newDemandInformationElement.getFirstJobElementTimePerUnit()
671-
* demandForThisLink;
672-
Id<CarrierService> idNewService = Id.create(
670+
Carrier thisCarrier = CarriersUtils.getCarriers(scenario).getCarriers()
671+
.get(Id.create(newDemandInformationElement.getCarrierName(), Carrier.class));
672+
int numberOfJobsForDemand = calculateNumberOfJobsForDemand(thisCarrier, demandForThisLink);
673+
for (int i = 0; i < numberOfJobsForDemand; i++) {
674+
int singleDemandForThisLink = demandForThisLink / numberOfJobsForDemand;
675+
if (i == numberOfJobsForDemand - 1)
676+
singleDemandForThisLink = demandForThisLink - (numberOfJobsForDemand - 1) * singleDemandForThisLink;
677+
double serviceTime = newDemandInformationElement.getFirstJobElementTimePerUnit()
678+
* singleDemandForThisLink;
679+
Id<CarrierService> idNewService = Id.create(
673680
createJobId(scenario, newDemandInformationElement, link.getId(), null),
674681
CarrierService.class);
675-
if (demandToDistribute > 0 && demandForThisLink > 0) {
676-
CarrierService thisService = CarrierService.Builder.newInstance(idNewService, link.getId())
677-
.setCapacityDemand(demandForThisLink).setServiceDuration(serviceTime)
682+
if (demandToDistribute > 0 && singleDemandForThisLink > 0) {
683+
CarrierService thisService = CarrierService.Builder.newInstance(idNewService, link.getId())
684+
.setCapacityDemand(singleDemandForThisLink).setServiceDuration(serviceTime)
678685
.setServiceStartTimeWindow(newDemandInformationElement.getFirstJobElementTimeWindow())
679686
.build();
680-
CarriersUtils.getCarriers(scenario).getCarriers().values().iterator().next().getServices()
681-
.put(thisService.getId(), thisService);
687+
thisCarrier.getServices().put(thisService.getId(), thisService);
688+
}
682689
}
683690
distributedDemand = distributedDemand + demandForThisLink;
684691
}
@@ -706,23 +713,31 @@ else if (samplingOption.equals("changeDemandOnLocation")) {
706713
}
707714
int demandForThisLink = calculateDemandForThisLink(demandToDistribute, numberOfJobs, distributedDemand, i);
708715

709-
double serviceTime;
710-
if (demandToDistribute == 0)
711-
serviceTime = newDemandInformationElement.getFirstJobElementTimePerUnit();
712-
else
713-
serviceTime = newDemandInformationElement.getFirstJobElementTimePerUnit() * demandForThisLink;
714-
usedServiceLocations.add(link.getId().toString());
716+
Carrier thisCarrier = CarriersUtils.getCarriers(scenario).getCarriers()
717+
.get(Id.create(newDemandInformationElement.getCarrierName(), Carrier.class));
718+
int numberOfJobsForDemand = calculateNumberOfJobsForDemand(thisCarrier, demandForThisLink);
719+
for (int j = 0; j < numberOfJobsForDemand; j++) {
720+
int singleDemandForThisLink = demandForThisLink / numberOfJobsForDemand;
721+
if (j == numberOfJobsForDemand - 1)
722+
singleDemandForThisLink = demandForThisLink - (numberOfJobsForDemand - 1) * singleDemandForThisLink;
723+
double serviceTime;
724+
if (singleDemandForThisLink == 0)
725+
serviceTime = newDemandInformationElement.getFirstJobElementTimePerUnit();
726+
else
727+
serviceTime = newDemandInformationElement.getFirstJobElementTimePerUnit() * demandForThisLink;
728+
usedServiceLocations.add(link.getId().toString());
715729

716-
Id<CarrierService> idNewService = Id.create(
730+
Id<CarrierService> idNewService = Id.create(
717731
createJobId(scenario, newDemandInformationElement, link.getId(), null), CarrierService.class);
718-
if ((demandToDistribute > 0 && demandForThisLink > 0) || demandToDistribute == 0) {
719-
CarrierService thisService = CarrierService.Builder.newInstance(idNewService, link.getId())
720-
.setCapacityDemand(demandForThisLink).setServiceDuration(serviceTime)
732+
if ((demandToDistribute > 0 && singleDemandForThisLink > 0) || demandToDistribute == 0) {
733+
CarrierService thisService = CarrierService.Builder.newInstance(idNewService, link.getId())
734+
.setCapacityDemand(singleDemandForThisLink).setServiceDuration(serviceTime)
721735
.setServiceStartTimeWindow(newDemandInformationElement.getFirstJobElementTimeWindow())
722736
.build();
723-
CarriersUtils.getCarriers(scenario).getCarriers()
737+
CarriersUtils.getCarriers(scenario).getCarriers()
724738
.get(Id.create(newDemandInformationElement.getCarrierName(), Carrier.class)).getServices()
725739
.put(thisService.getId(), thisService);
740+
}
726741
}
727742
distributedDemand = distributedDemand + demandForThisLink;
728743
}
@@ -1007,29 +1022,56 @@ else if (numberOfPickupLocations != null) {
10071022
private static void createSingleShipment(Scenario scenario, DemandInformationElement newDemandInformationElement,
10081023
Link linkPickup, Link linkDelivery, int demandForThisLink) {
10091024

1010-
Id<CarrierShipment> idNewShipment = Id.create(createJobId(scenario, newDemandInformationElement,
1011-
linkPickup.getId(), linkDelivery.getId()), CarrierShipment.class);
1025+
Carrier thisCarrier = CarriersUtils.getCarriers(scenario).getCarriers()
1026+
.get(Id.create(newDemandInformationElement.getCarrierName(), Carrier.class));
1027+
int numberOfJobsForDemand = calculateNumberOfJobsForDemand(thisCarrier, demandForThisLink);
10121028

10131029
TimeWindow timeWindowPickup = newDemandInformationElement.getFirstJobElementTimeWindow();
10141030
TimeWindow timeWindowDelivery = newDemandInformationElement.getSecondJobElementTimeWindow();
10151031

1016-
double serviceTimePickup;
1017-
double serviceTimeDelivery;
1018-
if (demandForThisLink == 0) {
1019-
serviceTimePickup = newDemandInformationElement.getFirstJobElementTimePerUnit();
1020-
serviceTimeDelivery = newDemandInformationElement.getSecondJobElementTimePerUnit();
1021-
} else {
1022-
serviceTimePickup = newDemandInformationElement.getFirstJobElementTimePerUnit() * demandForThisLink;
1023-
serviceTimeDelivery = newDemandInformationElement.getSecondJobElementTimePerUnit() * demandForThisLink;
1032+
for (int i = 0; i < numberOfJobsForDemand; i++) {
1033+
Id<CarrierShipment> idNewShipment = Id.create(createJobId(scenario, newDemandInformationElement,
1034+
linkPickup.getId(), linkDelivery.getId()), CarrierShipment.class);
1035+
double serviceTimePickup;
1036+
double serviceTimeDelivery;
1037+
int singleDemandForThisLink = Math.round ((float) demandForThisLink / numberOfJobsForDemand);
1038+
if (i == numberOfJobsForDemand - 1)
1039+
singleDemandForThisLink = demandForThisLink - (numberOfJobsForDemand - 1) * singleDemandForThisLink;
1040+
if (singleDemandForThisLink == 0) {
1041+
serviceTimePickup = newDemandInformationElement.getFirstJobElementTimePerUnit();
1042+
serviceTimeDelivery = newDemandInformationElement.getSecondJobElementTimePerUnit();
1043+
} else {
1044+
serviceTimePickup = newDemandInformationElement.getFirstJobElementTimePerUnit() * singleDemandForThisLink;
1045+
serviceTimeDelivery = newDemandInformationElement.getSecondJobElementTimePerUnit() * singleDemandForThisLink;
1046+
}
1047+
CarrierShipment thisShipment = CarrierShipment.Builder
1048+
.newInstance(idNewShipment, linkPickup.getId(), linkDelivery.getId(), singleDemandForThisLink)
1049+
.setPickupServiceTime(serviceTimePickup).setPickupTimeWindow(timeWindowPickup)
1050+
.setDeliveryServiceTime(serviceTimeDelivery).setDeliveryTimeWindow(timeWindowDelivery)
1051+
.build();
1052+
thisCarrier.getShipments().put(thisShipment.getId(), thisShipment);
1053+
}
1054+
}
1055+
1056+
/**
1057+
* Method calculates the number of jobs for a demand on one link based on the largest vehicle capacity of the carrier.
1058+
*
1059+
* @param thisCarrier the carrier of a job
1060+
* @param demandForThisLink Demand for this link
1061+
* @return Number of jobs for this demand
1062+
*/
1063+
private static int calculateNumberOfJobsForDemand(Carrier thisCarrier, int demandForThisLink) {
1064+
double largestVehicleCapacity = 0;
1065+
for (CarrierVehicle vehicle : thisCarrier.getCarrierCapabilities().getCarrierVehicles().values()) {
1066+
if (vehicle.getType().getCapacity().getOther() > largestVehicleCapacity) {
1067+
largestVehicleCapacity = vehicle.getType().getCapacity().getOther();
1068+
}
1069+
}
1070+
if (demandForThisLink > largestVehicleCapacity) {
1071+
log.info("Demand {} is larger than the largest vehicle capacity ({}). Splitting demand into multiple jobs.", demandForThisLink, largestVehicleCapacity);
1072+
return (int) Math.ceil((double) demandForThisLink / largestVehicleCapacity);
10241073
}
1025-
CarrierShipment thisShipment = CarrierShipment.Builder
1026-
.newInstance(idNewShipment, linkPickup.getId(), linkDelivery.getId(), demandForThisLink)
1027-
.setPickupServiceTime(serviceTimePickup).setPickupTimeWindow(timeWindowPickup)
1028-
.setDeliveryServiceTime(serviceTimeDelivery).setDeliveryTimeWindow(timeWindowDelivery)
1029-
.build();
1030-
CarriersUtils.getCarriers(scenario).getCarriers()
1031-
.get(Id.create(newDemandInformationElement.getCarrierName(), Carrier.class)).getShipments()
1032-
.put(thisShipment.getId(), thisShipment);
1074+
return 1;
10331075
}
10341076

10351077
/**
@@ -1086,7 +1128,7 @@ private static int calculateDemandForThisLink(int demandToDistribute, int number
10861128
} else {
10871129
roundingError = roundingError
10881130
+ ((double) demandForThisLink - ((double) demandToDistribute / (double) numberOfJobs));
1089-
if (roundingError > 1) {
1131+
if (roundingError >= 1) {
10901132
demandForThisLink = demandForThisLink - 1;
10911133
roundingError = roundingError - 1;
10921134
}
@@ -1113,7 +1155,7 @@ private static int calculateDemandBasedOnLinkLength(int countOfLinks, int distri
11131155
.ceil(link.getLength() / sumOfPossibleLinkLength * (double) demandToDistribute);
11141156
roundingError = roundingError + ((double) demandForThisLink
11151157
- (link.getLength() / sumOfPossibleLinkLength * (double) demandToDistribute));
1116-
if (roundingError > 1) {
1158+
if (roundingError >= 1) {
11171159
demandForThisLink = demandForThisLink - 1;
11181160
roundingError = roundingError - 1;
11191161
}
@@ -1265,7 +1307,7 @@ private static HashMap<Id<Link>, Link> findAllPossibleLinks(Scenario scenario,
12651307
crsTransformationNetworkAndShape);
12661308
if (!possibleLinks.containsKey(newPossibleLink.getId()))
12671309
possibleLinks.put(newPossibleLink.getId(), newPossibleLink);
1268-
if (nearestLinkPerPerson.size() == possiblePersons.size())
1310+
if (!possiblePersons.isEmpty() && nearestLinkPerPerson.size() == possiblePersons.size())
12691311
break;
12701312
}
12711313
}

contribs/application/src/main/java/org/matsim/freightDemandGeneration/FreightDemandGeneration.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,13 @@ private void createDemand(DemandGenerationOptions selectedDemandGenerationOption
381381
*/
382382
FreightDemandGenerationUtils.preparePopulation(population, sampleSizeInputPopulation,
383383
upSamplePopulationTo, "changeDemandOnLocation");
384+
case noPopulationSampling ->
385+
/*
386+
* If the demand sample is equal to the population sample, the demand is created
387+
* based on the given population and the set input population sampleSize
388+
*/
389+
FreightDemandGenerationUtils.preparePopulation(population, sampleSizeInputPopulation,
390+
sampleSizeInputPopulation, "noPopulationSampling");
384391
default -> throw new RuntimeException("No valid sampling option selected!");
385392
}
386393
switch (selectedPopulationOption) {

contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/dashboards/DrtDashboard.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ public void configure(Header header, Layout layout) {
159159
viz.description = "Number of rides (customers) is displayed in bars, wait statistics in lines";
160160

161161
Plotly.DataSet waitStats = viz.addDataset(data.output("*_waitStats_" + drtConfigGroup.mode + ".csv"));
162-
Plotly.DataSet rejections = viz.addDataset(data.output("*drt_rejections_perTimeBin_" + drtConfigGroup.mode + ".csv"));
162+
Plotly.DataSet rejections = viz.addDataset(data.output("*drt_rejections_perTimeBin_" + drtConfigGroup.mode + ".csv"));
163163

164164
viz.layout = tech.tablesaw.plotly.components.Layout.builder()
165165
.xAxis(Axis.builder().title("Time Bin").build())
@@ -244,7 +244,7 @@ public void configure(Header header, Layout layout) {
244244

245245
viz.layout = tech.tablesaw.plotly.components.Layout.builder()
246246
.xAxis(Axis.builder().title("Iteration").build())
247-
.yAxis(Axis.builder().title("Wait Time [s]").build())
247+
.yAxis(Axis.builder().title("Number of Rides").build())
248248
.barMode(tech.tablesaw.plotly.components.Layout.BarMode.STACK)
249249
.build();
250250

@@ -272,12 +272,12 @@ public void configure(Header header, Layout layout) {
272272
viz.description = "";
273273
viz.dataset = data.output("*customer_stats_" + drtConfigGroup.mode + ".csv");
274274
viz.x = "iteration";
275-
viz.columns = List.of("wait_average","wait_median", "wait_p95");
275+
viz.columns = List.of("wait_average", "wait_median", "wait_p95");
276276
viz.legendName = List.of("Average", "Median", "95th Percentile");
277277
viz.xAxisName = "Iteration";
278278
viz.yAxisName = "Waiting Time [s]";
279279
})
280-
;
280+
;
281281

282282
layout.row("Demand And Travel Time Statistics per iteration")
283283
.el(Plotly.class, (viz, data) -> {

contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/edrt/run/EDrtControlerCreator.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,13 @@
4141
public class EDrtControlerCreator {
4242

4343
public static Controler createControler(Config config, boolean otfvis) {
44-
MultiModeDrtConfigGroup multiModeDrtConfig = MultiModeDrtConfigGroup.get(config);
45-
DrtConfigs.adjustMultiModeDrtConfig(multiModeDrtConfig, config.scoring(), config.routing());
46-
4744
Scenario scenario = DrtControlerCreator.createScenarioWithDrtRouteFactory(config);
4845
ScenarioUtils.loadScenario(scenario);
46+
return createControler(config, scenario, otfvis);
47+
}
48+
public static Controler createControler(Config config, Scenario scenario, boolean otfvis) {
49+
MultiModeDrtConfigGroup multiModeDrtConfig = MultiModeDrtConfigGroup.get(config);
50+
DrtConfigs.adjustMultiModeDrtConfig(multiModeDrtConfig, config.scoring(), config.routing());
4951

5052
Controler controler = new Controler(scenario);
5153
controler.addOverridingModule(new MultiModeEDrtModule());

contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/DrtOperationsControlerCreator.java

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package org.matsim.contrib.drt.extension.operations;
22

3+
import org.matsim.api.core.v01.Scenario;
4+
import org.matsim.contrib.drt.extension.DrtWithExtensionsConfigGroup;
35
import org.matsim.contrib.drt.extension.operations.operationFacilities.OperationFacilitiesModeModule;
46
import org.matsim.contrib.drt.extension.operations.operationFacilities.OperationFacilitiesQSimModule;
57
import org.matsim.contrib.drt.extension.operations.shifts.analysis.efficiency.DrtShiftEfficiencyModeModule;
@@ -26,20 +28,34 @@ public class DrtOperationsControlerCreator {
2628
* @return
2729
*/
2830
public static Controler createControler(Config config, boolean otfvis) {
29-
MultiModeDrtConfigGroup multiModeDrtConfig = MultiModeDrtConfigGroup.get(config);
30-
3131
Controler controler = DrtControlerCreator.createControler(config, otfvis);
32+
return prepareController(config, controler);
33+
}
34+
35+
/**
36+
* Creates a controller in one step.
37+
*
38+
* @param config
39+
* @param scenario
40+
* @param otfvis
41+
* @return
42+
*/
43+
public static Controler createControler(Config config, Scenario scenario, boolean otfvis) {
44+
Controler controler = DrtControlerCreator.createControler(config, scenario, otfvis);
45+
return prepareController(config, controler);
46+
}
3247

48+
private static Controler prepareController(Config config, Controler controler) {
49+
MultiModeDrtConfigGroup multiModeDrtConfig = MultiModeDrtConfigGroup.get(config);
3350
for (DrtConfigGroup drtCfg : multiModeDrtConfig.getModalElements()) {
3451
controler.addOverridingModule(new ShiftDrtModeModule(drtCfg));
3552
controler.addOverridingQSimModule(new DrtModeQSimModule(drtCfg, new ShiftDrtModeOptimizerQSimModule(drtCfg)));
36-
controler.addOverridingModule(new OperationFacilitiesModeModule((DrtWithOperationsConfigGroup) drtCfg));
53+
controler.addOverridingModule(new OperationFacilitiesModeModule((DrtWithExtensionsConfigGroup) drtCfg));
3754
controler.addOverridingQSimModule(new OperationFacilitiesQSimModule(drtCfg));
3855
controler.addOverridingModule(new DrtShiftEfficiencyModeModule(drtCfg));
3956
}
4057

4158
controler.configureQSimComponents(DvrpQSimComponents.activateAllModes(multiModeDrtConfig));
42-
4359
return controler;
4460
}
4561
}

contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/DrtWithOperationsConfigGroup.java

Lines changed: 0 additions & 31 deletions
This file was deleted.

contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/EDrtOperationsControlerCreator.java

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package org.matsim.contrib.drt.extension.operations;
22

3+
import org.matsim.api.core.v01.Scenario;
4+
import org.matsim.contrib.drt.extension.DrtWithExtensionsConfigGroup;
35
import org.matsim.contrib.drt.extension.edrt.run.EDrtControlerCreator;
46
import org.matsim.contrib.drt.extension.operations.eshifts.charging.ShiftOperatingVehicleProvider;
57
import org.matsim.contrib.drt.extension.operations.eshifts.fleet.EvShiftDvrpFleetQSimModule;
@@ -23,29 +25,34 @@
2325
public class EDrtOperationsControlerCreator {
2426

2527
public static Controler createControler(Config config, boolean otfvis) {
26-
27-
MultiModeDrtConfigGroup multiModeDrtConfig = MultiModeDrtConfigGroup.get(config);
28-
2928
Controler controler = EDrtControlerCreator.createControler(config, otfvis);
29+
prepareController(config, controler);
30+
return controler;
31+
}
32+
33+
public static Controler createControler(Config config, Scenario scenario, boolean otfvis) {
34+
Controler controler = EDrtControlerCreator.createControler(config, scenario, otfvis);
35+
prepareController(config, controler);
36+
return controler;
37+
}
3038

39+
private static void prepareController(Config config, Controler controler) {
40+
MultiModeDrtConfigGroup multiModeDrtConfig = MultiModeDrtConfigGroup.get(config);
3141
for (DrtConfigGroup drtCfg : multiModeDrtConfig.getModalElements()) {
3242
controler.addOverridingModule(new ShiftDrtModeModule(drtCfg));
3343
controler.addOverridingQSimModule(new DrtModeQSimModule(drtCfg, new ShiftDrtModeOptimizerQSimModule(drtCfg)));
3444
controler.addOverridingQSimModule(new ShiftEDrtModeOptimizerQSimModule(drtCfg));
3545
controler.addOverridingQSimModule(new EvShiftDvrpFleetQSimModule(drtCfg.getMode()));
36-
controler.addOverridingModule(new OperationFacilitiesModeModule((DrtWithOperationsConfigGroup) drtCfg));
46+
controler.addOverridingModule(new OperationFacilitiesModeModule((DrtWithExtensionsConfigGroup) drtCfg));
3747
controler.addOverridingQSimModule(new OperationFacilitiesQSimModule(drtCfg));
3848
controler.addOverridingModule(new DrtShiftEfficiencyModeModule(drtCfg));
3949
}
4050

41-
4251
controler.addOverridingQSimModule(new AbstractQSimModule() {
4352
@Override
4453
protected void configureQSim() {
4554
this.bind(IdleDischargingHandler.VehicleProvider.class).to(ShiftOperatingVehicleProvider.class);
4655
}
4756
});
48-
49-
return controler;
5057
}
5158
}

0 commit comments

Comments
 (0)