Skip to content

Commit

Permalink
Merge pull request #87 from moia-oss/master
Browse files Browse the repository at this point in the history
  • Loading branch information
TomE168 authored Feb 6, 2024
2 parents e971d62 + 8f18573 commit 02b1035
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 15 deletions.
7 changes: 7 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# https://help.github.com/articles/about-codeowners/
#
# These owners will be the default owners for everything in
# the repo. Unless a later match takes precedence,
# mentioned account names will be requested for
# review when someone opens a pull request.
* @moia-dev/mobility-analytics
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
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@
public final class DefaultPassengerEngine implements PassengerEngine, PassengerRequestRejectedEventHandler {

private final String mode;
private final Set<String> departureModes;

private final MobsimTimer mobsimTimer;
private final EventsManager eventsManager;

Expand All @@ -79,9 +81,10 @@ public final class DefaultPassengerEngine implements PassengerEngine, PassengerR
private final Map<Id<PassengerGroupIdentifier.PassengerGroup>, List<MobsimPassengerAgent>> groupDepartureStage = new LinkedHashMap<>();


DefaultPassengerEngine(String mode, EventsManager eventsManager, MobsimTimer mobsimTimer, PassengerRequestCreator requestCreator,
DefaultPassengerEngine(String mode, Set<String> departureModes, EventsManager eventsManager, MobsimTimer mobsimTimer, PassengerRequestCreator requestCreator,
VrpOptimizer optimizer, Network network, PassengerRequestValidator requestValidator, AdvanceRequestProvider advanceRequestProvider, PassengerGroupIdentifier passengerGroupIdentifier) {
this.mode = mode;
this.departureModes = departureModes;
this.mobsimTimer = mobsimTimer;
this.requestCreator = requestCreator;
this.optimizer = optimizer;
Expand Down Expand Up @@ -197,7 +200,7 @@ public void afterSim() {

@Override
public boolean handleDeparture(double now, MobsimAgent agent, Id<Link> fromLinkId) {
if (!agent.getMode().equals(mode)) {
if (!departureModes.contains(agent.getMode())) {
return false;
}

Expand Down Expand Up @@ -285,8 +288,12 @@ public void handleEvent(PassengerRequestRejectedEvent event) {
rejectedRequestsEvents.add(event);
}
}

public static Provider<PassengerEngine> createProvider(String mode) {
return createProvider(mode, Collections.singleton(mode));
}

public static Provider<PassengerEngine> createProvider(String mode, Set<String> departureModes) {
return new ModalProviders.AbstractProvider<>(mode, DvrpModes::mode) {
@Inject
private EventsManager eventsManager;
Expand All @@ -296,7 +303,7 @@ public static Provider<PassengerEngine> createProvider(String mode) {

@Override
public DefaultPassengerEngine get() {
return new DefaultPassengerEngine(getMode(), eventsManager, mobsimTimer, getModalInstance(PassengerRequestCreator.class),
return new DefaultPassengerEngine(getMode(), departureModes, eventsManager, mobsimTimer, getModalInstance(PassengerRequestCreator.class),
getModalInstance(VrpOptimizer.class), getModalInstance(Network.class), getModalInstance(PassengerRequestValidator.class),
getModalInstance(AdvanceRequestProvider.class), getModalInstance(PassengerGroupIdentifier.class));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import org.matsim.core.api.experimental.events.EventsManager;
import org.matsim.core.events.MobsimScopeEventHandler;
import org.matsim.core.mobsim.qsim.InternalInterface;
import org.matsim.core.mobsim.qsim.QSim;
import org.matsim.core.mobsim.qsim.interfaces.MobsimEngine;
import org.matsim.vehicles.Vehicle;

Expand Down Expand Up @@ -77,9 +78,10 @@ private boolean isOnFirstLink() {

private final Queue<LinkLeaveEvent> linkLeaveEvents = new ConcurrentLinkedQueue<>();
private final Queue<VehicleLeavesTrafficEvent> trafficLeaveEvents = new ConcurrentLinkedQueue<>();

private final QSim qsim;
@Inject
DriveDischargingHandler(ElectricFleet data, Network network, EventsManager eventsManager) {
DriveDischargingHandler(QSim qsim, ElectricFleet data, Network network, EventsManager eventsManager) {
this.qsim = qsim;
this.network = network;
this.eventsManager = eventsManager;
eVehicles = data.getElectricVehicles();
Expand Down Expand Up @@ -116,7 +118,7 @@ public void onPrepareSim() {
@Override
public void afterSim() {
// process remaining events
doSimStep(Double.POSITIVE_INFINITY);
doSimStep(this.qsim.getSimTimer().getTimeOfDay());
}

@Override
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion contribs/hybridsim/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<properties>
<protobuf.version>3.25.2</protobuf.version>
<grpc.version>1.61.0</grpc.version>
<grpc.version>1.61.1</grpc.version>
</properties>

<dependencies>
Expand Down
4 changes: 0 additions & 4 deletions contribs/vsp/src/test/java/playground/vsp/ev/UrbanEVIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,9 @@
import org.matsim.core.config.ConfigUtils;
import org.matsim.core.events.EventsUtils;
import org.matsim.core.population.PopulationUtils;
import org.matsim.core.utils.io.IOUtils;
import org.matsim.examples.ExamplesUtils;
import org.matsim.testcases.MatsimTestUtils;
import org.matsim.utils.eventsfilecomparison.EventsFileComparator;

import java.net.URL;

public class UrbanEVIT {
@RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils();

Expand Down
Binary file not shown.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<guice.version>7.0.0</guice.version>
<jackson.version>2.16.1</jackson.version>
<jogl.version>2.5.0</jogl.version>
<junit.version>5.10.1</junit.version>
<junit.version>5.10.2</junit.version>
</properties>

<scm>
Expand Down Expand Up @@ -304,7 +304,7 @@
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.25.2</version>
<version>3.25.3</version>
<scope>test</scope>
</dependency>

Expand Down

0 comments on commit 02b1035

Please sign in to comment.