Skip to content

Commit

Permalink
Merge pull request #4 from moia-oss/deploymentFix
Browse files Browse the repository at this point in the history
Deployment fix
  • Loading branch information
ArmelliniMG authored Oct 12, 2022
2 parents 64cdaef + 5647623 commit e154d6c
Show file tree
Hide file tree
Showing 14 changed files with 121 additions and 83 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 11
java-version: 17
- name: Install GLPK and CBC
run: sudo apt install glpk-utils coinor-cbc libglpk-java
- name: Run tests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ protected void configureQSim() {
Network network = getter.getModal(Network.class);
TravelTime travelTime = getter.getModal(TravelTime.class);

return new ParallelLeastCostPathCalculator(drtConfig.getNumberOfThreads(), factory, network,
return new ParallelLeastCostPathCalculator(drtConfig.numberOfThreads, factory, network,
new OnlyTimeDependentTravelDisutility(travelTime), travelTime);
}));

Expand Down Expand Up @@ -295,7 +295,7 @@ protected void configureQSim() {
CongestionMitigationParameters congestionParameters = amConfig.getCongestionMitigationParameters();

return new DefaultAlonsoMoraFunction(travelTimeEstimator, sequenceGeneratorFactory,
drtConfig.getStopDuration(), congestionParameters.getAllowPickupViolations(),
drtConfig.stopDuration, congestionParameters.getAllowPickupViolations(),
congestionParameters.getAllowPickupsWithDropoffViolations(),
amConfig.getCheckDeterminsticTravelTimes(), objective, constraint, amConfig.getViolationFactor(),
amConfig.getViolationOffset(), amConfig.getPreferNonViolation());
Expand All @@ -305,7 +305,7 @@ protected void configureQSim() {
bindModal(Constraint.class).toInstance(new NoopConstraint());

bindModal(StayTaskEndTimeCalculator.class).toProvider(modalProvider(getter -> {
return new DrtStayTaskEndTimeCalculator((dvrpVehicle, dropOffRequests, pickupRequests) -> drtConfig.getStopDuration());
return new DrtStayTaskEndTimeCalculator((dvrpVehicle, dropOffRequests, pickupRequests) -> drtConfig.stopDuration);
}));

bindModal(AlonsoMoraScheduler.class).toProvider(modalProvider(getter -> {
Expand All @@ -318,7 +318,7 @@ protected void configureQSim() {

OperationalVoter operationalVoter = getter.getModal(OperationalVoter.class);

return new DefaultAlonsoMoraScheduler(taskFactory, drtConfig.getStopDuration(),
return new DefaultAlonsoMoraScheduler(taskFactory, drtConfig.stopDuration,
amConfig.getCheckDeterminsticTravelTimes(), amConfig.getRerouteDuringScheduling(), travelTime,
network, endTimeCalculator, router, operationalVoter);
}));
Expand All @@ -329,7 +329,7 @@ protected void configureQSim() {
Double rebalancingInterval = null;

if (drtConfig.getRebalancingParams().isPresent()) {
rebalancingInterval = (double) drtConfig.getRebalancingParams().get().getInterval();
rebalancingInterval = (double) drtConfig.getRebalancingParams().get().interval;
}

return new StandardRebalancer( //
Expand Down Expand Up @@ -361,7 +361,7 @@ protected void configureQSim() {
getter.getModal(AlonsoMoraVehicleFactory.class), //
getter.getModal(QSimScopeForkJoinPoolHolder.class).getPool(), //
getter.getModal(TravelTimeEstimator.class), //
drtConfig.getStopDuration(), //
drtConfig.stopDuration, //
new AlgorithmSettings(amConfig));
}));

Expand All @@ -381,7 +381,7 @@ protected void configureQSim() {
getter.getModal(QSimScopeForkJoinPoolHolder.class).getPool(), //
getter.getModal(LeastCostPathCalculator.class), //
getter.getModal(TravelTime.class), //
drtConfig.getAdvanceRequestPlanningHorizon(), //
drtConfig.advanceRequestPlanningHorizon, //
getter.getModal(InformationCollector.class) //
);
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.matsim.alonso_mora.algorithm.AlonsoMoraTrip;
import org.matsim.alonso_mora.algorithm.assignment.AssignmentSolver.Solution.Status;

/**
* Solves the assignment problem as described by Alonso-Mora et al. using the
* Cbc solver via file transmission. Cbc must be avaialble on the system to use
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
package org.matsim.alonso_mora.example;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Optional;
import java.util.Random;
import java.util.Set;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import java.util.stream.Collectors;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.matsim.api.core.v01.Scenario;
Expand Down
26 changes: 13 additions & 13 deletions core/src/main/java/org/matsim/alonso_mora/example/RunNewYork.java
Original file line number Diff line number Diff line change
Expand Up @@ -202,19 +202,19 @@ static public void main(String[] args) throws CommandLine.ConfigurationException
MultiModeDrtConfigGroup drtConfig = new MultiModeDrtConfigGroup();
config.addModule(drtConfig);

DrtConfigGroup modeConfig = new DrtConfigGroup() //
.setMode(TransportMode.drt) //
.setMaxTravelTimeAlpha(detourFactor) //
.setMaxTravelTimeBeta(stopDuration) //
.setMaxWaitTime(maximumWaitingTime + stopDuration) //
.setStopDuration(stopDuration) //
.setRejectRequestIfMaxWaitOrTravelTimeViolated(true) //
.setUseModeFilteredSubnetwork(false) //
.setIdleVehiclesReturnToDepots(false) //
.setOperationalScheme(DrtConfigGroup.OperationalScheme.door2door) //
.setPlotDetailedCustomerStats(true) //
.setMaxWalkDistance(1000.) //
.setNumberOfThreads(threads);
DrtConfigGroup modeConfig = new DrtConfigGroup();
modeConfig.mode = TransportMode.drt;
modeConfig.maxTravelTimeAlpha = detourFactor;
modeConfig.maxTravelTimeBeta = stopDuration;
modeConfig.maxWaitTime = maximumWaitingTime + stopDuration;
modeConfig.stopDuration = stopDuration;
modeConfig.rejectRequestIfMaxWaitOrTravelTimeViolated = true;
modeConfig.useModeFilteredSubnetwork = false;
modeConfig.idleVehiclesReturnToDepots = false;
modeConfig.operationalScheme = DrtConfigGroup.OperationalScheme.door2door;
modeConfig.plotDetailedCustomerStats = true;
modeConfig.maxWalkDistance = 1000.;
modeConfig.numberOfThreads = threads;

modeConfig.addParameterSet(new ExtensiveInsertionSearchParams());
drtConfig.addParameterSet(modeConfig);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,16 @@
package org.matsim.alonso_mora.scheduling;

import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

import com.google.common.base.Verify;
import org.matsim.alonso_mora.algorithm.AlonsoMoraRequest;
import org.matsim.alonso_mora.algorithm.AlonsoMoraStop;
import org.matsim.alonso_mora.algorithm.AlonsoMoraStop.StopType;
import org.matsim.alonso_mora.algorithm.AlonsoMoraVehicle;
import org.matsim.api.core.v01.network.Link;
import org.matsim.api.core.v01.network.Network;
import org.matsim.contrib.drt.extension.shifts.schedule.WaitForShiftStayTask;
import org.matsim.contrib.drt.extension.operations.shifts.schedule.WaitForShiftStayTask;
import org.matsim.contrib.drt.passenger.AcceptedDrtRequest;
import org.matsim.contrib.drt.passenger.DrtRequest;
import org.matsim.contrib.drt.schedule.DrtDriveTask;
import org.matsim.contrib.drt.schedule.DrtStayTask;
import org.matsim.contrib.drt.schedule.DrtStopTask;
import org.matsim.contrib.drt.schedule.DrtTaskFactory;
import org.matsim.contrib.drt.schedule.DrtTaskType;
import org.matsim.contrib.drt.schedule.*;
import org.matsim.contrib.drt.scheduler.EmptyVehicleRelocator;
import org.matsim.contrib.dvrp.fleet.DvrpVehicle;
import org.matsim.contrib.dvrp.path.VrpPathWithTravelData;
Expand All @@ -35,7 +26,11 @@
import org.matsim.core.router.util.LeastCostPathCalculator;
import org.matsim.core.router.util.TravelTime;

import com.google.common.base.Verify;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

/**
* This class translates a sequence of pickups and dropoffs as proposed by the
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
package org.matsim.alonso_mora.shifts;

import java.util.Collection;
import java.util.List;
import java.util.Optional;

import org.matsim.alonso_mora.algorithm.AlonsoMoraRequest;
import org.matsim.alonso_mora.algorithm.AlonsoMoraStop;
import org.matsim.alonso_mora.algorithm.AlonsoMoraVehicle;
import org.matsim.alonso_mora.algorithm.function.DefaultAlonsoMoraFunction.Constraint;
import org.matsim.alonso_mora.algorithm.function.RouteTracker;
import org.matsim.alonso_mora.travel_time.TravelTimeEstimator;
import org.matsim.api.core.v01.network.Link;
import org.matsim.contrib.drt.extension.shifts.schedule.OperationalStop;
import org.matsim.contrib.drt.extension.operations.shifts.schedule.OperationalStop;
import org.matsim.contrib.dvrp.schedule.Schedule;
import org.matsim.contrib.dvrp.schedule.StayTask;
import org.matsim.contrib.dvrp.schedule.Task;

import java.util.Collection;
import java.util.List;
import java.util.Optional;

/**
* Constraint that makes the Alonso-Mora dispatcher take into account shifts and
* breaks.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
import org.matsim.alonso_mora.scheduling.DefaultAlonsoMoraScheduler.OperationalVoter;
import org.matsim.alonso_mora.travel_time.TravelTimeEstimator;
import org.matsim.api.core.v01.network.Network;
import org.matsim.contrib.drt.extension.shifts.config.DrtWithShiftsConfigGroup;
import org.matsim.contrib.drt.extension.shifts.dispatcher.DrtShiftDispatcher;
import org.matsim.contrib.drt.extension.shifts.optimizer.ShiftDrtOptimizer;
import org.matsim.contrib.drt.extension.shifts.schedule.ShiftDrtStayTaskEndTimeCalculator;
import org.matsim.contrib.drt.extension.operations.DrtWithOperationsConfigGroup;
import org.matsim.contrib.drt.extension.operations.shifts.dispatcher.DrtShiftDispatcher;
import org.matsim.contrib.drt.extension.operations.shifts.optimizer.ShiftDrtOptimizer;
import org.matsim.contrib.drt.extension.operations.shifts.schedule.ShiftDrtStayTaskEndTimeCalculator;
import org.matsim.contrib.drt.optimizer.DrtOptimizer;
import org.matsim.contrib.drt.schedule.DrtStayTaskEndTimeCalculator;
import org.matsim.contrib.drt.schedule.DrtTaskFactory;
Expand All @@ -22,10 +22,10 @@
import org.matsim.core.router.util.TravelTime;

public class ShiftAlonsoMoraModule extends AbstractDvrpModeQSimModule {
private final DrtWithShiftsConfigGroup drtConfig;
private final DrtWithOperationsConfigGroup drtConfig;
private final AlonsoMoraConfigGroup amConfig;

public ShiftAlonsoMoraModule(DrtWithShiftsConfigGroup drtConfig, AlonsoMoraConfigGroup amConfig) {
public ShiftAlonsoMoraModule(DrtWithOperationsConfigGroup drtConfig, AlonsoMoraConfigGroup amConfig) {
super(drtConfig.getMode());
this.drtConfig = drtConfig;
this.amConfig = amConfig;
Expand All @@ -39,8 +39,8 @@ protected void configureQSim() {

// TODO: This can become a general binding in DRT
bindModal(StayTaskEndTimeCalculator.class).toProvider(modalProvider(getter -> {
return new ShiftDrtStayTaskEndTimeCalculator(drtConfig.getDrtShiftParams(),
new DrtStayTaskEndTimeCalculator((dvrpVehicle, dropoffRequests, pickupRequests) -> drtConfig.getStopDuration()));
return new ShiftDrtStayTaskEndTimeCalculator(drtConfig.getDrtOperationsParams().getShiftsParams().orElseThrow(),
new DrtStayTaskEndTimeCalculator((dvrpVehicle, dropoffRequests, pickupRequests) -> drtConfig.stopDuration));
}));

bindModal(OperationalVoter.class).toProvider(modalProvider(getter -> {
Expand Down Expand Up @@ -68,7 +68,7 @@ protected void configureQSim() {

OperationalVoter operationalVoter = getter.getModal(OperationalVoter.class);

return new ShiftAlonsoMoraScheduler(taskFactory, drtConfig.getStopDuration(),
return new ShiftAlonsoMoraScheduler(taskFactory, drtConfig.stopDuration,
amConfig.getCheckDeterminsticTravelTimes(), amConfig.getRerouteDuringScheduling(), travelTime,
network, endTimeCalculator, router, operationalVoter);
}));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
package org.matsim.alonso_mora.shifts;

import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

import com.google.common.base.Verify;
import org.matsim.alonso_mora.algorithm.AlonsoMoraRequest;
import org.matsim.alonso_mora.algorithm.AlonsoMoraStop;
import org.matsim.alonso_mora.algorithm.AlonsoMoraStop.StopType;
Expand All @@ -14,16 +9,12 @@
import org.matsim.alonso_mora.scheduling.WaitForStopTask;
import org.matsim.api.core.v01.network.Link;
import org.matsim.api.core.v01.network.Network;
import org.matsim.contrib.drt.extension.shifts.schedule.ShiftBreakTask;
import org.matsim.contrib.drt.extension.shifts.schedule.ShiftChangeOverTask;
import org.matsim.contrib.drt.extension.shifts.schedule.WaitForShiftStayTask;
import org.matsim.contrib.drt.extension.operations.shifts.schedule.ShiftBreakTask;
import org.matsim.contrib.drt.extension.operations.shifts.schedule.ShiftChangeOverTask;
import org.matsim.contrib.drt.extension.operations.shifts.schedule.WaitForShiftStayTask;
import org.matsim.contrib.drt.passenger.AcceptedDrtRequest;
import org.matsim.contrib.drt.passenger.DrtRequest;
import org.matsim.contrib.drt.schedule.DrtDriveTask;
import org.matsim.contrib.drt.schedule.DrtStayTask;
import org.matsim.contrib.drt.schedule.DrtStopTask;
import org.matsim.contrib.drt.schedule.DrtTaskFactory;
import org.matsim.contrib.drt.schedule.DrtTaskType;
import org.matsim.contrib.drt.schedule.*;
import org.matsim.contrib.drt.scheduler.EmptyVehicleRelocator;
import org.matsim.contrib.dvrp.fleet.DvrpVehicle;
import org.matsim.contrib.dvrp.path.VrpPathWithTravelData;
Expand All @@ -39,7 +30,11 @@
import org.matsim.core.router.util.LeastCostPathCalculator;
import org.matsim.core.router.util.TravelTime;

import com.google.common.base.Verify;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

/**
* This class translates a sequence of pickups and dropoffs as proposed by the
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.matsim.alonso_mora.shifts;

import org.matsim.alonso_mora.algorithm.DefaultAlonsoMoraVehicle;
import org.matsim.contrib.drt.extension.shifts.schedule.OperationalStop;
import org.matsim.contrib.drt.extension.operations.shifts.schedule.OperationalStop;
import org.matsim.contrib.dvrp.fleet.DvrpVehicle;
import org.matsim.contrib.dvrp.schedule.Schedule;
import org.matsim.contrib.dvrp.schedule.Schedule.ScheduleStatus;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package org.matsim.alonso_mora.shifts;

import org.matsim.alonso_mora.scheduling.DefaultAlonsoMoraScheduler.OperationalVoter;
import org.matsim.contrib.drt.extension.shifts.schedule.OperationalStop;
import org.matsim.contrib.drt.extension.shifts.schedule.ShiftBreakTask;
import org.matsim.contrib.drt.extension.shifts.schedule.ShiftChangeOverTask;
import org.matsim.contrib.drt.extension.shifts.scheduler.ShiftTaskScheduler;
import org.matsim.contrib.drt.extension.operations.shifts.schedule.OperationalStop;
import org.matsim.contrib.drt.extension.operations.shifts.schedule.ShiftBreakTask;
import org.matsim.contrib.drt.extension.operations.shifts.schedule.ShiftChangeOverTask;
import org.matsim.contrib.drt.extension.operations.shifts.scheduler.ShiftTaskScheduler;
import org.matsim.contrib.drt.schedule.DrtDriveTask;
import org.matsim.contrib.drt.schedule.DrtTaskType;
import org.matsim.contrib.dvrp.schedule.Task;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@
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.contrib.drt.extension.shifts.config.DrtShiftParams;
import org.matsim.contrib.drt.extension.shifts.config.DrtWithShiftsConfigGroup;
import org.matsim.contrib.drt.extension.shifts.operationFacilities.*;
import org.matsim.contrib.drt.extension.shifts.run.ShiftDrtModeModule;
import org.matsim.contrib.drt.extension.shifts.run.ShiftDrtModeOptimizerQSimModule;
import org.matsim.contrib.drt.extension.shifts.run.ShiftDvrpFleetQsimModule;
import org.matsim.contrib.drt.extension.shifts.shift.*;
import org.matsim.contrib.drt.extension.operations.DrtOperationsParams;
import org.matsim.contrib.drt.extension.operations.DrtWithOperationsConfigGroup;
import org.matsim.contrib.drt.extension.operations.operationFacilities.*;
import org.matsim.contrib.drt.extension.operations.shifts.run.ShiftDrtModeModule;
import org.matsim.contrib.drt.extension.operations.shifts.run.ShiftDrtModeOptimizerQSimModule;
import org.matsim.contrib.drt.extension.operations.shifts.run.ShiftDvrpFleetQsimModule;
import org.matsim.contrib.drt.extension.operations.shifts.shift.*;
import org.matsim.contrib.drt.routing.DrtRoute;
import org.matsim.contrib.drt.routing.DrtRouteFactory;
import org.matsim.contrib.drt.run.DrtConfigGroup;
Expand Down Expand Up @@ -122,7 +122,7 @@ public void testRunAlonsoMora() {
public void testRunAlonsoMoraWithShifts() {
Id.resetCaches();
URL configUrl = IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("mielec"), "mielec_drt_config.xml");
Config config = ConfigUtils.loadConfig(configUrl, new MultiModeDrtConfigGroup(DrtWithShiftsConfigGroup::new), new DvrpConfigGroup(),
Config config = ConfigUtils.loadConfig(configUrl, new MultiModeDrtConfigGroup(DrtWithOperationsConfigGroup::new), new DvrpConfigGroup(),
new MultiModeAlonsoMoraConfigGroup(), new OTFVisConfigGroup());

AlonsoMoraConfigGroup amConfig = new AlonsoMoraConfigGroup();
Expand All @@ -133,10 +133,10 @@ public void testRunAlonsoMoraWithShifts() {
config.controler().setOutputDirectory(utils.getOutputDirectory());

// Remove DRT rebalancer as we want to use AM rebalancer
DrtWithShiftsConfigGroup drtConfig = (DrtWithShiftsConfigGroup) MultiModeDrtConfigGroup.get(config).getModalElements().iterator().next();
DrtWithOperationsConfigGroup drtConfig = (DrtWithOperationsConfigGroup) MultiModeDrtConfigGroup.get(config).getModalElements().iterator().next();
drtConfig.removeParameterSet(drtConfig.getRebalancingParams().get());
ConfigGroup shiftParams = drtConfig.createParameterSet(DrtShiftParams.SET_NAME);
drtConfig.addParameterSet(shiftParams);
DrtOperationsParams operationsParams = (DrtOperationsParams) drtConfig.createParameterSet(DrtOperationsParams.SET_NAME);
drtConfig.addParameterSet(operationsParams);

// Load scenario
Scenario scenario = ScenarioUtils.createScenario(config);
Expand Down Expand Up @@ -226,7 +226,7 @@ public void install() {
});

AlonsoMoraConfigurator.configure(controller, amConfig.getMode());
controller.addOverridingQSimModule(new ShiftAlonsoMoraModule((DrtWithShiftsConfigGroup) drtConfig, amConfig));
controller.addOverridingQSimModule(new ShiftAlonsoMoraModule((DrtWithOperationsConfigGroup) drtConfig, amConfig));
controller.run();

var expectedStats = Stats.newBuilder() //
Expand Down
Loading

0 comments on commit e154d6c

Please sign in to comment.