Skip to content

Commit

Permalink
Merge branch 'master' into run-gui
Browse files Browse the repository at this point in the history
  • Loading branch information
rakow committed Feb 10, 2024
2 parents b0d7365 + a23f78a commit 0a10fe3
Show file tree
Hide file tree
Showing 161 changed files with 3,492 additions and 1,580 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/code-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
run: mvn verify -P jacoco --batch-mode --also-make --projects matsim -Dmaven.test.redirectTestOutputToFile -Dmatsim.preferLocalDtds=true

- name: Push coverage to CodeCov
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
files: ./matsim/target/site/jacoco/jacoco.xml

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy-on-pr-merge.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
- name: Submit Dependency Graph
# Generate a complete dependency graph and submit the graph to the GitHub repository.
# The goal is to improve security alerts from dependabot, because dependabot is not able to compute the complete dependency graph.
uses: advanced-security/maven-dependency-submission-action@v3
uses: advanced-security/maven-dependency-submission-action@v4

env:
MAVEN_OPTS: -Xmx2g
2 changes: 1 addition & 1 deletion .github/workflows/verify-push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ jobs:
- name: Detect changes against master
# we only want to build matsim (module) if changes are not limited to contribs
id: detect-changes
uses: dorny/paths-filter@v2
uses: dorny/paths-filter@v3
if: ${{matrix.module == 'matsim'}}
with:
filters: |
Expand Down
2 changes: 1 addition & 1 deletion contribs/analysis/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<dependency>
<groupId>org.apache.httpcomponents.client5</groupId>
<artifactId>httpclient5</artifactId>
<version>5.3</version>
<version>5.3.1</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.matsim.api.core.v01.Id;
import org.matsim.api.core.v01.Scenario;
import org.matsim.api.core.v01.network.Link;
import org.matsim.application.options.ShpOptions;
import org.matsim.freight.carriers.*;
import org.matsim.freight.carriers.CarrierCapabilities.FleetSize;
import org.matsim.core.utils.geometry.CoordinateTransformation;
Expand All @@ -41,7 +42,7 @@

/**
* This CarrierReaderFromCSV reads all carrier information given in the read CSV
* file and creates the carriers. While the process of creating the carriers the
* file and creates the carriers. While the process of creating the carriers, the
* consistency of the information will be checked.
*
* @author Ricardo Ewert
Expand All @@ -55,11 +56,11 @@ public final class CarrierReaderFromCSV {
* file. For one carrier several CarrierInformationElement can be read in. This
* is necessary for creating different configurations of the vehicles. Not every
* parameter should be set for creating the carrier. While the process of
* creating the carriers the consistency of the information will be checked.
* creating the carriers, the consistency of the information will be checked.
*/
static class CarrierInformationElement {
/**
* Name of carrier of this information element.
* Name of the carrier of this information element.
*/
private final String carrierName;
/**
Expand Down Expand Up @@ -97,8 +98,8 @@ static class CarrierInformationElement {
private final int jspritIterations;
/**
* Sets a fixed number of vehicles per vehicleType and location. If this
* number is e.g. 3.: for each vehicleType 3 vehicles at each location will be
* created and the fleetsize is finite.
* number is e.g., 3.: for each vehicleType 3 vehicles at each location will be
* created, and the fleetsize is finite.
*/
private int fixedNumberOfVehiclePerTypeAndLocation;

Expand Down Expand Up @@ -236,20 +237,20 @@ public void setFixedNumberOfVehiclePerTypeAndLocation(int fixedNumberOfVehiclePe
* @param scenario
* @param freightCarriersConfigGroup
* @param csvLocationCarrier
* @param polygonsInShape
* @param indexShape
* @param defaultJspritIterations
* @param crsTransformationNetworkAndShape
* @param shapeCategory
* @throws IOException
*/
public static void readAndCreateCarrierFromCSV(Scenario scenario, FreightCarriersConfigGroup freightCarriersConfigGroup,
Path csvLocationCarrier, Collection<SimpleFeature> polygonsInShape, int defaultJspritIterations,
Path csvLocationCarrier, ShpOptions.Index indexShape, int defaultJspritIterations,
CoordinateTransformation crsTransformationNetworkAndShape, String shapeCategory) throws IOException {

Set<CarrierInformationElement> allNewCarrierInformation = readCarrierInformation(csvLocationCarrier);
checkNewCarrier(allNewCarrierInformation, freightCarriersConfigGroup, scenario, polygonsInShape, shapeCategory);
checkNewCarrier(allNewCarrierInformation, freightCarriersConfigGroup, scenario, indexShape, shapeCategory);
log.info("The read carrier information from the csv are checked without errors.");
createNewCarrierAndAddVehicleTypes(scenario, allNewCarrierInformation, freightCarriersConfigGroup, polygonsInShape,
createNewCarrierAndAddVehicleTypes(scenario, allNewCarrierInformation, freightCarriersConfigGroup, indexShape,
defaultJspritIterations, crsTransformationNetworkAndShape);
}

Expand Down Expand Up @@ -302,16 +303,16 @@ else if (!record.get("fleetSize").isBlank())
}

/**
* Checks if the read carrier information are consistent.
* Checks if the read carrier information is consistent.
*
* @param allNewCarrierInformation
* @param freightCarriersConfigGroup
* @param scenario
* @param polygonsInShape
* @param indexShape
* @param shapeCategory
*/
static void checkNewCarrier(Set<CarrierInformationElement> allNewCarrierInformation,
FreightCarriersConfigGroup freightCarriersConfigGroup, Scenario scenario, Collection<SimpleFeature> polygonsInShape, String shapeCategory) {
FreightCarriersConfigGroup freightCarriersConfigGroup, Scenario scenario, ShpOptions.Index indexShape, String shapeCategory) {

CarriersUtils.addOrGetCarriers(scenario);
for (CarrierInformationElement carrierElement : allNewCarrierInformation) {
Expand Down Expand Up @@ -355,12 +356,12 @@ static void checkNewCarrier(Set<CarrierInformationElement> allNewCarrierInformat
log.warn(
"No possible area for additional depot given. Random choice in the hole network of a possible position");
if (carrierElement.getAreaOfAdditionalDepots() != null) {
if (polygonsInShape == null)
if (indexShape == null)
throw new RuntimeException("For carrier " + carrierElement.getName()
+ " a certain area for depots is selected, but no shape is read in. Please check.");
for (String depotArea : carrierElement.getAreaOfAdditionalDepots()) {
boolean isInShape = false;
for (SimpleFeature singlePolygon : polygonsInShape) {
for (SimpleFeature singlePolygon : indexShape.getShp().readFeatures()) {
if (singlePolygon.getAttribute(shapeCategory).equals(depotArea)) {
isInShape = true;
break;
Expand Down Expand Up @@ -409,14 +410,14 @@ static void checkNewCarrier(Set<CarrierInformationElement> allNewCarrierInformat
* @param scenario
* @param allNewCarrierInformation
* @param freightCarriersConfigGroup
* @param polygonsInShape
* @param indexShape
* @param defaultJspritIterations
* @param crsTransformationNetworkAndShape
*/
static void createNewCarrierAndAddVehicleTypes(Scenario scenario,
Set<CarrierInformationElement> allNewCarrierInformation, FreightCarriersConfigGroup freightCarriersConfigGroup,
Collection<SimpleFeature> polygonsInShape, int defaultJspritIterations,
CoordinateTransformation crsTransformationNetworkAndShape) {
Set<CarrierInformationElement> allNewCarrierInformation, FreightCarriersConfigGroup freightCarriersConfigGroup,
ShpOptions.Index indexShape, int defaultJspritIterations,
CoordinateTransformation crsTransformationNetworkAndShape) {

Carriers carriers = CarriersUtils.addOrGetCarriers(scenario);
CarrierVehicleTypes carrierVehicleTypes = new CarrierVehicleTypes();
Expand Down Expand Up @@ -457,7 +458,7 @@ static void createNewCarrierAndAddVehicleTypes(Scenario scenario,
&& !link.getId().toString().contains("pt")
&& (!link.getAttributes().getAsMap().containsKey("type")
|| !link.getAttributes().getAsMap().get("type").toString().contains("motorway"))
&& FreightDemandGenerationUtils.checkPositionInShape(link, null, polygonsInShape,
&& FreightDemandGenerationUtils.checkPositionInShape(link, null, indexShape,
singleNewCarrier.getAreaOfAdditionalDepots(), crsTransformationNetworkAndShape)) {
singleNewCarrier.getVehicleDepots().add(link.getId().toString());
}
Expand Down
Loading

0 comments on commit 0a10fe3

Please sign in to comment.