Skip to content

Commit

Permalink
merging
Browse files Browse the repository at this point in the history
  • Loading branch information
rakow committed Nov 1, 2023
2 parents fd69600 + 3219f95 commit 9d8363d
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 55 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# This workflow will build a Java project with Maven
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven

name: Java CI with Maven
on:
push:
branches: [ 5.5.x ]
pull_request:
branches: [ 5.5.x ]

jobs:
build:

runs-on: ubuntu-latest
environment: Build
env:
MATSIM_DECRYPTION_PASSWORD: ${{ secrets.MATSIM_DECRYPTION_PASSWORD }}

steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
java-version: '11'
distribution: 'adopt'
- name: Build with Maven
run: mvn -B package --file pom.xml
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

This repository provides an open MATSim transport model for Berlin, provided by the [Transport Systems Planning and Transport Telematics group](https://www.vsp.tu-berlin.de) of [Technische Universität Berlin](http://www.tu-berlin.de). Please reference/cite the scenario based on <a rel="license" href="https://doi.org/10.1016/j.procs.2019.04.120">this paper</a>.

<a rel="TU Berlin" href="https://www.vsp.tu-berlin.de"><img src="https://svn.vsp.tu-berlin.de/repos/public-svn/ueber_uns/logo/TUB_Logo.png" width="12%" height="12%"/></a>
<a rel="TU Berlin" href="https://www.vsp.tu-berlin.de"><img src="https://svn.vsp.tu-berlin.de/repos/public-svn/ueber_uns/logo/TU_BERLIN_Logo_Lang_RGB_SR_rot.svg" width="25%"/></a>

Currently, there are two versions of the MATSim Open Berlin model:

Expand All @@ -32,7 +32,7 @@ The **MATSim input files, output files, analysis data and visualizations** are l

## Note

Handling of large files within git is not without problems (git lfs files are not included in the zip download; we have to pay; ...). In consequence, large files, both on the input and on the output side, reside at https://svn.vsp.tu-berlin.de/repos/public-svn/matsim/scenarios/countries/de/berlin .
Handling of large files within git is not without problems (git lfs files are not included in the zip download; we have to pay; ...). In consequence, large files, both on the input and on the output side, reside at https://svn.vsp.tu-berlin.de/repos/public-svn/matsim/scenarios/countries/de/berlin . Please check out the latest release / the latest numbered branch since those are stable. The master branch is an potentially unstable development head.

----
## Simple things (without installing/running MATSim)
Expand Down Expand Up @@ -162,6 +162,4 @@ controler.run
---
## More information

For more information about the scenario generation, see VSP working paper # 19-01 under https://www.vsp.tu-berlin.de/publications/vspwp .

For more information about MATSim, see here: https://www.matsim.org/
90 changes: 40 additions & 50 deletions src/main/java/org/matsim/run/wasteCollection/AbfallUtils.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
package org.matsim.run.wasteCollection;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap;
import com.graphhopper.jsprit.analysis.toolbox.Plotter;
import com.graphhopper.jsprit.core.algorithm.VehicleRoutingAlgorithm;
import com.graphhopper.jsprit.core.algorithm.box.SchrimpfFactory;
import com.graphhopper.jsprit.core.problem.VehicleRoutingProblem;
import com.graphhopper.jsprit.core.problem.solution.VehicleRoutingProblemSolution;
import com.graphhopper.jsprit.core.util.Solutions;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.locationtech.jts.geom.Geometry;
Expand All @@ -23,16 +18,7 @@
import org.matsim.api.core.v01.network.Network;
import org.matsim.api.core.v01.population.Person;
import org.matsim.contrib.freight.FreightConfigGroup;
import org.matsim.contrib.freight.carrier.Carrier;
import org.matsim.contrib.freight.carrier.CarrierPlan;
import org.matsim.contrib.freight.carrier.CarrierPlanXmlWriterV2;
import org.matsim.contrib.freight.carrier.CarrierShipment;
import org.matsim.contrib.freight.carrier.CarrierUtils;
import org.matsim.contrib.freight.carrier.CarrierVehicleTypes;
import org.matsim.contrib.freight.carrier.Carriers;
import org.matsim.contrib.freight.carrier.ScheduledTour;
import org.matsim.contrib.freight.carrier.TimeWindow;
import org.matsim.contrib.freight.carrier.Tour;
import org.matsim.contrib.freight.carrier.*;
import org.matsim.contrib.freight.carrier.Tour.Delivery;
import org.matsim.contrib.freight.carrier.Tour.Leg;
import org.matsim.contrib.freight.carrier.Tour.Pickup;
Expand All @@ -56,14 +42,13 @@
import org.matsim.vehicles.VehicleType;
import org.opengis.feature.simple.SimpleFeature;

import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap;
import com.graphhopper.jsprit.analysis.toolbox.Plotter;
import com.graphhopper.jsprit.core.algorithm.VehicleRoutingAlgorithm;
import com.graphhopper.jsprit.core.algorithm.box.SchrimpfFactory;
import com.graphhopper.jsprit.core.problem.VehicleRoutingProblem;
import com.graphhopper.jsprit.core.problem.solution.VehicleRoutingProblemSolution;
import com.graphhopper.jsprit.core.util.Solutions;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.Map.Entry;

/**
* @author Ricardo Ewert
Expand All @@ -90,9 +75,9 @@ class AbfallUtils {
static String linkMpsReinickendorf = "59055";
static String linkUmladestationGradestrasse = "71781";
static String linkGruenauerStr = "97944";
static List<String> districtsWithShipments = new ArrayList<>();
static List<String> districtsWithNoShipments = new ArrayList<>();
static HashMap<String, String> dataEnt = new HashMap<>();
static List<String> districtsWithShipments = new ArrayList<String>();
static List<String> districtsWithNoShipments = new ArrayList<String>();
static HashMap<String, String> dataEnt = new HashMap<String, String>();
static Multimap<String, String> linksInDistricts;
static boolean streetAlreadyInGarbageLinks = false;

Expand Down Expand Up @@ -406,7 +391,7 @@ static void createShipmentsForSelectedDay(Collection<SimpleFeature> districtsWit
garbageToCollect = (int) ((double) districtInformation.getAttribute(day) * 1000);
dumpId = garbageDumps.get(districtInformation.getAttribute(dataEnt.get(day)));
usedCarrier = districtInformation.getAttribute("Depot").toString();
if (oneCarrierForEachDistrict) {
if (oneCarrierForEachDistrict == true) {
district = districtInformation.getAttribute("Ortsteil").toString();
Carrier newCarrier = createSingleCarrier(usedCarrier, carrierMap, district);
carrierMap.put(district, newCarrier);
Expand Down Expand Up @@ -448,7 +433,7 @@ static void createShipmentsForSelectedDay(Collection<SimpleFeature> districtsWit
distanceWithShipments = 0;
garbageLinks.clear();
}
if (oneCarrierForEachDistrict) {
if (oneCarrierForEachDistrict == true) {
carrierMap.remove("Nordring");
carrierMap.remove("MalmoeerStr");
carrierMap.remove("Forckenbeck");
Expand Down Expand Up @@ -643,18 +628,18 @@ static Controler prepareControler(Scenario scenario) {
controler.addOverridingModule(new AbstractModule() {
@Override
public void install() {
install(new CarrierModule());
// bind(CarrierPlanStrategyManagerFactory.class).toInstance( null );
// bind(CarrierScoringFunctionFactory.class).toInstance(null );
}
});

return controler;
}

// /**
// * @param scenario
// * @return
// */
/**
* @param scenario
* @return
*/
// private static CarrierScoringFunctionFactoryImpl createMyScoringFunction2(final Scenario scenario) {
//
// return new CarrierScoringFunctionFactoryImpl(scenario.getNetwork());
Expand Down Expand Up @@ -859,7 +844,7 @@ static void outputSummary(Collection<SimpleFeature> districtsWithGarbage, Scenar
}
}
allCollectedGarbage = sizeForckenbeck + sizeMalmooer + sizeNordring + sizeGradestrasse + sizeChessboard;
powerConsumptionTour = (distanceTour / 1000) * energyConsumptionPerDistance
powerConsumptionTour = (double) (distanceTour / 1000) * energyConsumptionPerDistance
+ (double) (sizeTour / 1000) * energyConsumptionPerWeight;

if (scheduledTour.getVehicle().getId().toString().contains("TruckForckenbeck")) {
Expand Down Expand Up @@ -1007,7 +992,7 @@ static void outputSummary(Collection<SimpleFeature> districtsWithGarbage, Scenar
}
writer.write("\n" + "Fahrzeug: \t\t\t\t\t\t\t\t\t\t\t\t\t" + vehicleTypeId + "\n");
writer.write(
"Kapazität je Fahrzeug: \t\t\t\t\t\t\t\t\t\t" + (capacityTruck / 1000) + " Tonnen\n\n");
"Kapazität je Fahrzeug: \t\t\t\t\t\t\t\t\t\t" + ((double) capacityTruck / 1000) + " Tonnen\n\n");
writer.write("Volumen der Mülltonne: \t\t\t\t\t\t\t\t\t\t" + volumeDustbin + " Liter\n");
writer.write(
"ServiceTime pro Mülltonne:\t\t\t\t\t\t\t\t\t" + secondsServiceTimePerDustbin + " Sekunden\n\n");
Expand All @@ -1031,7 +1016,7 @@ static void outputSummary(Collection<SimpleFeature> districtsWithGarbage, Scenar
writer.write("\t\t\tFahrstrecke Durchschnitt:\t\t" + Math.round(averageTourDistanceForckenbeck)
+ " km\n");

if (electricCar) {
if (electricCar == true) {
writer.write("\t\t\tEnergieverbrauch Summe:\t\t\t" + powerConsumptionForckenbeck + " kwh\n");
writer.write("\t\t\tEnergieverbrauch Max:\t\t\t" + maxPowerConsumptionForckenbeck + " kwh\n");
writer.write("\t\t\tEnergieverbrauch Min:\t\t\t" + minPowerConsumptionForckenbeck + " kwh\n");
Expand Down Expand Up @@ -1180,6 +1165,10 @@ static void outputSummaryShipments(Scenario scenario, String day, HashMap<String
}

/**
* @param scenario
* @param carriers
* @param vehicleTypes
* @throws IOException
*/

@SuppressWarnings("null")
Expand Down Expand Up @@ -1242,7 +1231,8 @@ static void createResultFile(Scenario scenario, Carriers carriers) throws Except
numCollections++;

}
if (element instanceof Leg legElement) {
if (element instanceof Tour.Leg) {
Tour.Leg legElement = (Tour.Leg) element;
if (legElement.getRoute().getDistance() != 0)
distanceTour = distanceTour
+ RouteUtils.calcDistance((NetworkRoute) legElement.getRoute(), 0, 0, network);
Expand Down Expand Up @@ -1284,8 +1274,8 @@ static void createResultFile(Scenario scenario, Carriers carriers) throws Except
+ singleVehicleType.getCostInformation().getFixedCosts() + " €");
if (singleVehicleType.getEngineInformation().getAttributes().getAttribute("fuelType")
.equals("electricity")) {
double electricityConsumptionPer100km;
double electricityCapacityinkWh;
double electricityConsumptionPer100km = 0;
double electricityCapacityinkWh = 0;
electricityConsumptionPer100km = (double) singleVehicleType.getEngineInformation().getAttributes()
.getAttribute("engeryConsumptionPerKm");
electricityCapacityinkWh = (double) singleVehicleType.getEngineInformation().getAttributes()
Expand All @@ -1306,7 +1296,7 @@ static void createResultFile(Scenario scenario, Carriers carriers) throws Except
int consumption = 0;
double distanceRange = 0;
double electricityCapacityinkWh = 0;
double electricityConsumptionPerkm;
double electricityConsumptionPerkm = 0;

for (VehicleType singleVehicleType : vehicleTypes.getVehicleTypes().values()) {

Expand Down Expand Up @@ -1341,8 +1331,8 @@ static void createResultFile(Scenario scenario, Carriers carriers) throws Except
writer.close();
log.info("Output geschrieben");
log.info("### Done.");
if (!toursWithOverconsumption.isEmpty())
throw new Exception("The tour(s) " + toursWithOverconsumption
if (toursWithOverconsumption.isEmpty() == false)
throw new Exception("The tour(s) " + toursWithOverconsumption.toString()
+ " have a higher consumption then their capacity");

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public static void main(String[] args) throws Exception {
vehicleTypesFileLocation = inputVehicleTypes;
carriersFileLocation = inputCarriersWithMediumBatteryVehicle;
break;
case carriersFromInputFile:
case carriersFromInputFile:
break;
default:
new RuntimeException("no carriers selected.");
Expand Down

0 comments on commit 9d8363d

Please sign in to comment.