Skip to content

Commit

Permalink
Merge branch 'master' into drt-estimator
Browse files Browse the repository at this point in the history
  • Loading branch information
rakow authored Oct 16, 2023
2 parents 27c8f1c + 3b1b938 commit 148816e
Show file tree
Hide file tree
Showing 149 changed files with 2,573 additions and 1,961 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@
import org.matsim.core.controler.listener.StartupListener;
import org.matsim.core.utils.charts.XYLineChart;
import org.matsim.core.utils.io.IOUtils;
import org.matsim.core.utils.io.UncheckedIOException;

import java.awt.*;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.util.*;
import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import java.io.BufferedWriter;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
Expand All @@ -45,7 +46,6 @@
import org.matsim.core.controler.listener.StartupListener;
import org.matsim.core.utils.charts.XYLineChart;
import org.matsim.core.utils.io.IOUtils;
import org.matsim.core.utils.io.UncheckedIOException;

/**
* Calculates:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@
import org.matsim.core.router.TripStructureUtils.Trip;
import org.matsim.core.utils.geometry.CoordUtils;
import org.matsim.core.utils.io.IOUtils;
import org.matsim.core.utils.io.UncheckedIOException;
import org.matsim.utils.objectattributes.ObjectAttributes;
import org.matsim.utils.objectattributes.ObjectAttributesXmlWriter;
import org.matsim.vehicles.Vehicle;

import java.io.BufferedWriter;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.util.*;
import java.util.Map.Entry;

Expand Down Expand Up @@ -100,7 +100,7 @@ enum StatType {

private Vehicle2DriverEventHandler delegate = new Vehicle2DriverEventHandler() ;

// general trip counter. Would, in theory, not necessary to do this per StatType, but I find it too brittle
// general trip counter. Would, in theory, not necessary to do this per StatType, but I find it too brittle
// to avoid under- or over-counting with respect to loops.
// private final Map<StatType,Integer> legCount = new TreeMap<StatType,Integer>() ;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class CreateGeoJsonNetwork implements MATSimAppCommand {
@CommandLine.Option(names = "--match-id", description = "Pattern to filter links by id")
private String matchId;

@CommandLine.Option(names = "--mode-filter", split = ",", defaultValue = "car",
@CommandLine.Option(names = "--mode-filter", split = ",", defaultValue = "car,freight,drt",
description = "Only keep links if they have one of the specified modes. Specify 'none' to disable.")
private Set<String> modes;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,10 @@
import org.matsim.core.network.NetworkUtils;
import org.matsim.core.population.PopulationUtils;
import org.matsim.core.utils.io.IOUtils;
import org.matsim.vehicles.Vehicle;
import org.matsim.vehicles.VehicleType;
import org.matsim.vehicles.VehicleUtils;
import org.matsim.vehicles.Vehicles;

import java.io.BufferedWriter;
import java.io.IOException;
Expand Down Expand Up @@ -169,7 +171,7 @@ private static void writeCSVWithCategoryHeader(HashMap<String, Object2DoubleMap<
writer.close();

} catch (IOException e) {
e.printStackTrace();
log.error("Could not write the csv file with the data distribution data.", e);
}
}

Expand All @@ -186,6 +188,8 @@ static void createPlansBasedOnCarrierPlans(Scenario scenario, String smallScaleC
Map<String, AtomicLong> idCounter = new HashMap<>();

Population populationFromCarrier = (Population) scenario.getScenarioElement("allpersons");
Vehicles allVehicles = VehicleUtils.getOrCreateAllvehicles(scenario);

for (Person person : populationFromCarrier.getPersons().values()) {

Plan plan = popFactory.createPlan();
Expand Down Expand Up @@ -238,11 +242,12 @@ else if (subpopulation.contains("goodsTraffic"))
if (relatedCarrier.getAttributes().getAsMap().containsKey("tourStartArea"))
newPerson.getAttributes().putAttribute("tourStartArea",
relatedCarrier.getAttributes().getAttribute("tourStartArea"));
VehicleUtils.insertVehicleIdsIntoAttributes(newPerson, (new HashMap<>() {
{
put(mode, (Id.createVehicleId(person.getId().toString())));
}
}));

Id<Vehicle> vehicleId = Id.createVehicleId(person.getId().toString());

VehicleUtils.insertVehicleIdsIntoAttributes(newPerson, Map.of(mode, vehicleId));
VehicleUtils.insertVehicleTypesIntoAttributes(newPerson, Map.of(mode, allVehicles.getVehicles().get(vehicleId).getType().getId()));

population.addPerson(newPerson);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@
import org.matsim.application.options.ShpOptions;
import org.matsim.freight.carriers.jsprit.NetworkBasedTransportCosts;
import org.matsim.core.utils.io.IOUtils;
import org.matsim.core.utils.io.UncheckedIOException;
import org.matsim.vehicles.VehicleType;
import org.matsim.vehicles.VehicleUtils;
import org.opengis.feature.simple.SimpleFeature;
import org.matsim.smallScaleCommercialTrafficGeneration.TrafficVolumeGeneration.TrafficVolumeKey;

import java.io.BufferedWriter;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.net.MalformedURLException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@
package org.matsim.contrib.common.csv;

import java.io.IOException;
import java.io.UncheckedIOException;
import java.io.Writer;

import org.matsim.core.utils.io.UncheckedIOException;

import com.opencsv.CSVWriter;

public class CompactCSVWriter extends CSVWriter {
Expand Down
Loading

0 comments on commit 148816e

Please sign in to comment.