Skip to content

Commit

Permalink
Merge branch 'master' into fix-overview-dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
rakow authored Nov 14, 2023
2 parents 015f10c + 48949d4 commit d0ccdd4
Show file tree
Hide file tree
Showing 13 changed files with 69 additions and 46 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/full-integration.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: full-integration

on:
workflow_dispatch:
schedule:
- cron: '30 0 * * *' # daily at 0:30 UTC

Expand All @@ -13,7 +14,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
os: [ubuntu-latest, windows-latest, macos-latest]

steps:
- name: Prepare git
Expand Down
4 changes: 2 additions & 2 deletions contribs/accessibility/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
<dependency>
<groupId>org.openstreetmap.osmosis</groupId>
<artifactId>osmosis-core</artifactId>
<version>0.48.3</version>
<version>${osmosis.version}</version>
<exclusions>
<!-- needed to compile in IntelliJ with Eclipse compiler -->
<!-- see: https://bugs.eclipse.org/bugs/show_bug.cgi?id=536928 -->
Expand All @@ -65,7 +65,7 @@
<dependency>
<groupId>org.openstreetmap.osmosis</groupId>
<artifactId>osmosis-xml</artifactId>
<version>0.48.3</version>
<version>${osmosis.version}</version>
</dependency>
<dependency>
<groupId>org.matsim.contrib</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,23 @@

import org.matsim.api.core.v01.Id;
import org.matsim.api.core.v01.network.Link;
import org.matsim.contrib.drt.extension.edrt.schedule.EDrtTaskFactoryImpl;
import org.matsim.contrib.drt.schedule.DrtStayTask;
import org.matsim.contrib.drt.schedule.DrtTaskFactory;
import org.matsim.contrib.dvrp.fleet.DvrpVehicle;
import org.matsim.contrib.dvrp.schedule.Schedule;
import org.matsim.contrib.drt.extension.edrt.schedule.EDrtTaskFactoryImpl;
import org.matsim.contrib.ev.charging.ChargingStrategy;
import org.matsim.contrib.ev.charging.ChargingWithAssignmentLogic;
import org.matsim.contrib.evrp.EvDvrpVehicle;
import org.matsim.contrib.ev.fleet.ElectricVehicle;
import org.matsim.contrib.ev.infrastructure.Charger;
import org.matsim.contrib.ev.infrastructure.ChargingInfrastructure;
import org.matsim.contrib.evrp.EvDvrpVehicle;
import org.matsim.core.mobsim.framework.MobsimTimer;

import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;

/**
Expand All @@ -43,30 +46,36 @@
public class EmptyVehicleChargingScheduler {
private final MobsimTimer timer;
private final EDrtTaskFactoryImpl taskFactory;
private final Map<Id<Link>, Charger> linkToChargerMap;
private final Map<Id<Link>, List<Charger>> linkToChargersMap;

public EmptyVehicleChargingScheduler(MobsimTimer timer, DrtTaskFactory taskFactory,
ChargingInfrastructure chargingInfrastructure) {
this.timer = timer;
this.taskFactory = (EDrtTaskFactoryImpl)taskFactory;
linkToChargerMap = chargingInfrastructure.getChargers()
linkToChargersMap = chargingInfrastructure.getChargers()
.values()
.stream()
.collect(Collectors.toMap(c -> c.getLink().getId(), c -> c));
.collect(Collectors.groupingBy(c -> c.getLink().getId()));
}

public void chargeVehicle(DvrpVehicle vehicle) {
DrtStayTask currentTask = (DrtStayTask)vehicle.getSchedule().getCurrentTask();
Link currentLink = currentTask.getLink();
Charger charger = linkToChargerMap.get(currentLink.getId());
if (charger != null) {
List<Charger> chargers = linkToChargersMap.get(currentLink.getId());
if (chargers != null) {
Optional<Charger> freeCharger = chargers.stream().filter(c -> c.getLogic().getPluggedVehicles().isEmpty()).findFirst();

// Empty charger or at least smallest queue charger
Charger charger = freeCharger.orElseGet(() -> chargers.stream().min(Comparator.comparingInt(e -> e.getLogic().getQueuedVehicles().size())).orElseThrow());
ElectricVehicle ev = ((EvDvrpVehicle)vehicle).getElectricVehicle();
if (!charger.getLogic().getChargingStrategy().isChargingCompleted(ev)) {
chargeVehicleImpl(vehicle, charger);
}
}
}



private void chargeVehicleImpl(DvrpVehicle vehicle, Charger charger) {
Schedule schedule = vehicle.getSchedule();
DrtStayTask stayTask = (DrtStayTask)schedule.getCurrentTask();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
*/
public class FreeSpeedTravelTimeMatrix implements TravelTimeMatrix {
public static FreeSpeedTravelTimeMatrix createFreeSpeedMatrix(Network dvrpNetwork, DvrpTravelTimeMatrixParams params, int numberOfThreads,
double qSimTimeStepSize) {
double qSimTimeStepSize) {
return new FreeSpeedTravelTimeMatrix(dvrpNetwork, params, numberOfThreads, new QSimFreeSpeedTravelTime(qSimTimeStepSize));
}

Expand All @@ -48,17 +48,19 @@ public FreeSpeedTravelTimeMatrix(Network dvrpNetwork, DvrpTravelTimeMatrixParams
var routingParams = new TravelTimeMatrices.RoutingParams(dvrpNetwork, travelTime, travelDisutility, numberOfThreads);
freeSpeedTravelTimeMatrix = TravelTimeMatrices.calculateTravelTimeMatrix(routingParams, centralNodes, 0);
freeSpeedTravelTimeSparseMatrix = TravelTimeMatrices.calculateTravelTimeSparseMatrix(routingParams, params.maxNeighborDistance,
params.maxNeighborTravelTime, 0);
params.maxNeighborTravelTime, 0).orElse(null);
}

@Override
public int getTravelTime(Node fromNode, Node toNode, double departureTime) {
if (fromNode == toNode) {
return 0;
}
int time = freeSpeedTravelTimeSparseMatrix.get(fromNode, toNode);
if (time >= 0) {// value is present
return time;
if (freeSpeedTravelTimeSparseMatrix != null) {
int time = freeSpeedTravelTimeSparseMatrix.get(fromNode, toNode);
if (time >= 0) {// value is present
return time;
}
}
return freeSpeedTravelTimeMatrix.get(gridSystem.getZone(fromNode), gridSystem.getZone(toNode));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.IntStream;

import org.matsim.api.core.v01.network.Network;
Expand Down Expand Up @@ -56,7 +57,7 @@ public static Matrix calculateTravelTimeMatrix(RoutingParams params, Map<Zone, N
}

private static void computeForDepartureZone(Zone fromZone, Map<Zone, Node> centralNodes, double departureTime, Matrix travelTimeMatrix,
LeastCostPathTree lcpTree) {
LeastCostPathTree lcpTree) {
Node fromNode = centralNodes.get(fromZone);
lcpTree.calculate(fromNode.getId().index(), departureTime, null, null);

Expand All @@ -65,26 +66,31 @@ private static void computeForDepartureZone(Zone fromZone, Map<Zone, Node> centr
int nodeIndex = toNode.getId().index();
OptionalTime currOptionalTime = lcpTree.getTime(nodeIndex);
double currTime = currOptionalTime.orElseThrow(() -> new RuntimeException(
"Undefined Time. Reason could be that the dvrp network is not fully connected. Please check and/or clean."));
"Undefined Time. Reason could be that the dvrp network is not fully connected. Please check and/or clean."));
double tt = currTime - departureTime;
travelTimeMatrix.set(fromZone, toZone, tt);
}
}

public static SparseMatrix calculateTravelTimeSparseMatrix(RoutingParams params, double maxDistance, double maxTravelTime, double departureTime) {
public static Optional<SparseMatrix> calculateTravelTimeSparseMatrix(RoutingParams params, double maxDistance, double maxTravelTime,
double departureTime) {
SparseMatrix travelTimeMatrix = new SparseMatrix();
if (maxDistance == 0 && maxTravelTime == 0) {
return Optional.empty();
}

var nodes = params.routingNetwork.getNodes().values();
var counter = "DVRP free-speed TT sparse matrix: node ";
Calculation<Node> calculation = (lcpTree, n) -> computeForDepartureNode(n, nodes, departureTime, travelTimeMatrix, lcpTree, maxDistance,
maxTravelTime);
maxTravelTime);
calculate(params, nodes, calculation, counter);
return travelTimeMatrix;
return Optional.of(travelTimeMatrix);
}

private static void computeForDepartureNode(Node fromNode, Collection<? extends Node> nodes, double departureTime, SparseMatrix sparseMatrix,
LeastCostPathTree lcpTree, double maxDistance, double maxTravelTime) {
LeastCostPathTree lcpTree, double maxDistance, double maxTravelTime) {
lcpTree.calculate(fromNode.getId().index(), departureTime, null, null,
(nodeIndex, arrivalTime, travelCost, distance, departTime) -> distance >= maxDistance && arrivalTime >= departTime + maxTravelTime);
(nodeIndex, arrivalTime, travelCost, distance, departTime) -> distance >= maxDistance && arrivalTime >= departTime + maxTravelTime);

List<NodeAndTime> neighborNodes = new ArrayList<>();
for (Node toNode : nodes) {
Expand All @@ -109,8 +115,8 @@ private interface Calculation<E> {

private static <E> void calculate(RoutingParams params, Collection<? extends E> elements, Calculation<E> calculation, String counterPrefix) {
var trees = IntStream.range(0, params.numberOfThreads)
.mapToObj(i -> new LeastCostPathTree(new SpeedyGraph(params.routingNetwork), params.travelTime, params.travelDisutility))
.toList();
.mapToObj(i -> new LeastCostPathTree(new SpeedyGraph(params.routingNetwork), params.travelTime, params.travelDisutility))
.toList();
var executorService = new ExecutorServiceWithResource<>(trees);
var counter = new Counter(counterPrefix, " / " + elements.size());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public void travelTimeSparseMatrix_maxDistance() {
NetworkUtils.createAndAddLink(network, Id.createLinkId("CA"), nodeC, nodeA, 600, 15, 80, 1);

double maxDistance = 300;// B->A->C and C->A->B are pruned by the limit
var matrix = TravelTimeMatrices.calculateTravelTimeSparseMatrix(routingParams(network), maxDistance, 0, 0);
var matrix = TravelTimeMatrices.calculateTravelTimeSparseMatrix(routingParams(network), maxDistance, 0, 0).orElseThrow();

assertThat(matrix.get(nodeA, nodeA)).isEqualTo(0);
assertThat(matrix.get(nodeA, nodeB)).isEqualTo(10);
Expand Down Expand Up @@ -97,7 +97,7 @@ public void travelTimeSparseMatrix_maxTravelTime() {

// 20 s (max TT) corresponds to 300 m (max distance) in another test (see: travelTimeSparseMatrix_maxDistance())
double maxTravelTime = 20;// B->A->C and C->A->B are pruned by the limit
var matrix = TravelTimeMatrices.calculateTravelTimeSparseMatrix(routingParams(network), 0, maxTravelTime, 0);
var matrix = TravelTimeMatrices.calculateTravelTimeSparseMatrix(routingParams(network), 0, maxTravelTime, 0).orElseThrow();

assertThat(matrix.get(nodeA, nodeA)).isEqualTo(0);
assertThat(matrix.get(nodeA, nodeB)).isEqualTo(10);
Expand Down
2 changes: 1 addition & 1 deletion contribs/hybridsim/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<name>hybridsim</name>

<properties>
<protobuf.version>3.24.4</protobuf.version>
<protobuf.version>3.25.0</protobuf.version>
<grpc.version>1.59.0</grpc.version>
</properties>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,7 @@ public final void testSubsidyPControler() {
// Check final iteration
String actual = this.pStatsResults.get(2)[9];
// flaky (non-deterministic) test... allow multiple results
Assert.assertTrue("Number of budget (final iteration)",
List.of("174413625.6239444000", "174413625.7708889500", "174413625.7022777500").contains(actual));
Assert.assertEquals("Number of budget (final iteration)", 174413625.6, Double.parseDouble(actual), 1);
}

@Override
Expand Down
11 changes: 8 additions & 3 deletions contribs/noise/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.openstreetmap.osmosis</groupId>
<artifactId>osmosis-xml</artifactId>
<version>0.48.3</version>
<groupId>org.openstreetmap.osmosis</groupId>
<artifactId>osmosis-core</artifactId>
<version>${osmosis.version}</version>
<exclusions>
<!-- needed to compile in IntelliJ with Eclipse compiler -->
<!-- see: https://bugs.eclipse.org/bugs/show_bug.cgi?id=536928 -->
Expand All @@ -51,6 +51,11 @@
<artifactId>xml-apis</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.openstreetmap.osmosis</groupId>
<artifactId>osmosis-xml</artifactId>
<version>${osmosis.version}</version>
</dependency>
</dependencies>
</project>
2 changes: 1 addition & 1 deletion contribs/protobuf/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<name>protobuf</name>

<properties>
<protobuf.version>3.24.4</protobuf.version>
<protobuf.version>3.25.0</protobuf.version>
</properties>

<dependencies>
Expand Down
10 changes: 5 additions & 5 deletions contribs/vsp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
<dependency>
<groupId>org.openstreetmap.osmosis</groupId>
<artifactId>osmosis-core</artifactId>
<version>0.48.3</version>
<version>${osmosis.version}</version>
<exclusions>
<!-- needed to compile in IntelliJ with Eclipse compiler -->
<!-- see: https://bugs.eclipse.org/bugs/show_bug.cgi?id=536928 -->
Expand All @@ -115,22 +115,22 @@
<dependency>
<groupId>org.openstreetmap.osmosis</groupId>
<artifactId>osmosis-xml</artifactId>
<version>0.48.3</version>
<version>${osmosis.version}</version>
</dependency>
<dependency>
<groupId>org.openstreetmap.osmosis</groupId>
<artifactId>osmosis-tagfilter</artifactId>
<version>0.48.3</version>
<version>${osmosis.version}</version>
</dependency>
<dependency>
<groupId>org.openstreetmap.osmosis</groupId>
<artifactId>osmosis-set</artifactId>
<version>0.48.3</version>
<version>${osmosis.version}</version>
</dependency>
<dependency>
<groupId>org.openstreetmap.osmosis</groupId>
<artifactId>osmosis-areafilter</artifactId>
<version>0.48.3</version>
<version>${osmosis.version}</version>
</dependency>
<dependency>
<groupId>org.matsim.contrib</groupId>
Expand Down
4 changes: 2 additions & 2 deletions matsim/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>3.2.1</version>
<version>3.2.2</version>
</plugin>
</plugins>
</reporting>
Expand Down Expand Up @@ -203,7 +203,7 @@
<dependency>
<groupId>com.github.luben</groupId>
<artifactId>zstd-jni</artifactId>
<version>1.5.5-6</version>
<version>1.5.5-10</version>
</dependency>
<dependency>
<groupId>jakarta.validation</groupId>
Expand Down
13 changes: 7 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

<log4j.version>2.21.1</log4j.version>
<geotools.version>29.2</geotools.version>
<osmosis.version>0.49.1</osmosis.version>
<jts.version>1.19.0</jts.version>
<guice.version>7.0.0</guice.version>
<jackson.version>2.15.3</jackson.version>
Expand Down Expand Up @@ -123,7 +124,7 @@
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId>
<version>1.10.0</version>
<version>1.11.0</version>
</dependency>
<dependency>
<groupId>com.opencsv</groupId>
Expand Down Expand Up @@ -264,7 +265,7 @@
<dependency>
<groupId>org.checkerframework</groupId>
<artifactId>checker-qual</artifactId>
<version>3.39.0</version>
<version>3.40.0</version>
</dependency>

<dependency>
Expand All @@ -289,7 +290,7 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>5.6.0</version>
<version>5.7.0</version>
<scope>test</scope>
</dependency>

Expand Down Expand Up @@ -382,12 +383,12 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.2.1</version>
<version>3.2.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>3.2.1</version>
<version>3.2.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand All @@ -412,7 +413,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.6.0</version>
<version>3.6.2</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
Expand Down

0 comments on commit d0ccdd4

Please sign in to comment.