diff --git a/examples/src/main/java/org/eqasim/examples/corsica_drt/CorsicaDrtModule.java b/examples/src/main/java/org/eqasim/examples/corsica_drt/CorsicaDrtModule.java index 1c9d277a3..88d06f8ee 100644 --- a/examples/src/main/java/org/eqasim/examples/corsica_drt/CorsicaDrtModule.java +++ b/examples/src/main/java/org/eqasim/examples/corsica_drt/CorsicaDrtModule.java @@ -8,15 +8,13 @@ import org.eqasim.core.simulation.mode_choice.AbstractEqasimExtension; import org.eqasim.core.simulation.mode_choice.ParameterDefinition; import org.eqasim.core.simulation.mode_choice.cost.CostModel; -import org.eqasim.core.simulation.mode_choice.parameters.ModeParameters; +import org.eqasim.core.simulation.modes.drt.mode_choice.predictors.DefaultDrtPredictor; +import org.eqasim.core.simulation.modes.drt.mode_choice.predictors.DrtPredictor; +import org.eqasim.core.simulation.modes.drt.mode_choice.utilities.estimators.DrtUtilityEstimator; import org.eqasim.examples.corsica_drt.mode_choice.CorsicaDrtModeAvailability; import org.eqasim.examples.corsica_drt.mode_choice.cost.DrtCostModel; import org.eqasim.examples.corsica_drt.mode_choice.parameters.CorsicaDrtCostParameters; -import org.eqasim.examples.corsica_drt.mode_choice.parameters.CorsicaDrtModeParameters; -import org.eqasim.examples.corsica_drt.mode_choice.utilities.DrtPredictor; -import org.eqasim.examples.corsica_drt.mode_choice.utilities.DrtUtilityEstimator; import org.eqasim.ile_de_france.mode_choice.parameters.IDFCostParameters; -import org.eqasim.ile_de_france.mode_choice.parameters.IDFModeParameters; import org.matsim.core.config.CommandLine; import com.google.inject.Provider; @@ -39,14 +37,12 @@ protected void installEqasimExtension() { // Configure choice alternative for DRT bindUtilityEstimator("drt").to(DrtUtilityEstimator.class); bindCostModel("drt").to(DrtCostModel.class); - bind(DrtPredictor.class); + bind(DrtPredictor.class).to(DefaultDrtPredictor.class); // Define filter for trip analysis bind(PersonAnalysisFilter.class).to(DrtPersonAnalysisFilter.class); // Override parameter bindings - bind(ModeParameters.class).to(CorsicaDrtModeParameters.class); - bind(IDFModeParameters.class).to(CorsicaDrtModeParameters.class); bind(IDFCostParameters.class).to(CorsicaDrtCostParameters.class); } @@ -69,19 +65,6 @@ public CorsicaDrtCostParameters provideCostParameters(EqasimConfigGroup config) return parameters; } - @Provides - @Singleton - public CorsicaDrtModeParameters provideModeParameters(EqasimConfigGroup config) { - CorsicaDrtModeParameters parameters = CorsicaDrtModeParameters.buildDefault(); - - if (config.getModeParametersPath() != null) { - ParameterDefinition.applyFile(new File(config.getModeParametersPath()), parameters); - } - - ParameterDefinition.applyCommandLine("mode-parameter", commandLine, parameters); - return parameters; - } - @Provides @Named("drt") public CostModel provideCarCostModel(Map> factory, EqasimConfigGroup config) { diff --git a/examples/src/main/java/org/eqasim/examples/corsica_drt/RunCorsicaDrtSimulation.java b/examples/src/main/java/org/eqasim/examples/corsica_drt/RunCorsicaDrtSimulation.java index 69c99c01d..4ae8e557a 100644 --- a/examples/src/main/java/org/eqasim/examples/corsica_drt/RunCorsicaDrtSimulation.java +++ b/examples/src/main/java/org/eqasim/examples/corsica_drt/RunCorsicaDrtSimulation.java @@ -9,7 +9,7 @@ import org.eqasim.core.components.transit.EqasimTransitQSimModule; import org.eqasim.core.simulation.analysis.EqasimAnalysisModule; import org.eqasim.core.simulation.mode_choice.EqasimModeChoiceModule; -import org.eqasim.examples.corsica_drt.analysis.DvrpAnalsisModule; +import org.eqasim.core.simulation.modes.drt.analysis.DrtAnalysisModule; import org.eqasim.examples.corsica_drt.mode_choice.CorsicaDrtModeAvailability; import org.eqasim.examples.corsica_drt.rejections.RejectionConstraint; import org.eqasim.examples.corsica_drt.rejections.RejectionModule; @@ -24,9 +24,7 @@ import org.matsim.contrib.drt.run.DrtConfigGroup.OperationalScheme; import org.matsim.contrib.drt.run.DrtConfigs; import org.matsim.contrib.drt.run.MultiModeDrtConfigGroup; -import org.matsim.contrib.drt.run.MultiModeDrtModule; import org.matsim.contrib.dvrp.run.DvrpConfigGroup; -import org.matsim.contrib.dvrp.run.DvrpModule; import org.matsim.contrib.dvrp.run.DvrpQSimComponents; import org.matsim.contribs.discrete_mode_choice.modules.config.DiscreteModeChoiceConfigGroup; import org.matsim.core.config.CommandLine; @@ -156,7 +154,7 @@ static public void main(String[] args) throws ConfigurationException { { // Add overrides for Corsica + DRT controller.addOverridingModule(new CorsicaDrtModule(cmd)); controller.addOverridingModule(new RejectionModule(Arrays.asList("drt"))); - controller.addOverridingModule(new DvrpAnalsisModule()); + controller.addOverridingModule(new DrtAnalysisModule()); } controller.run(); diff --git a/examples/src/main/java/org/eqasim/examples/corsica_drt/analysis/DvrpAnalsisModule.java b/examples/src/main/java/org/eqasim/examples/corsica_drt/analysis/DvrpAnalsisModule.java deleted file mode 100644 index c594d27b2..000000000 --- a/examples/src/main/java/org/eqasim/examples/corsica_drt/analysis/DvrpAnalsisModule.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.eqasim.examples.corsica_drt.analysis; - -import org.matsim.core.controler.AbstractModule; - -import com.google.inject.Singleton; - -public class DvrpAnalsisModule extends AbstractModule { - @Override - public void install() { - bind(DvrpAnalysisListener.class).in(Singleton.class); - addControlerListenerBinding().to(DvrpAnalysisListener.class); - } -} diff --git a/examples/src/main/java/org/eqasim/examples/corsica_drt/analysis/DvrpAnalysisListener.java b/examples/src/main/java/org/eqasim/examples/corsica_drt/analysis/DvrpAnalysisListener.java deleted file mode 100644 index 438536607..000000000 --- a/examples/src/main/java/org/eqasim/examples/corsica_drt/analysis/DvrpAnalysisListener.java +++ /dev/null @@ -1,124 +0,0 @@ -package org.eqasim.examples.corsica_drt.analysis; - -import java.io.File; -import java.io.IOException; -import java.nio.file.Files; -import java.util.stream.Collectors; - -import org.eqasim.core.components.config.EqasimConfigGroup; -import org.eqasim.examples.corsica_drt.analysis.passengers.PassengerAnalysisListener; -import org.eqasim.examples.corsica_drt.analysis.passengers.PassengerAnalysisWriter; -import org.eqasim.examples.corsica_drt.analysis.utils.LinkFinder; -import org.eqasim.examples.corsica_drt.analysis.utils.VehicleRegistry; -import org.eqasim.examples.corsica_drt.analysis.vehicles.VehicleAnalysisListener; -import org.eqasim.examples.corsica_drt.analysis.vehicles.VehicleAnalysisWriter; -import org.matsim.api.core.v01.network.Network; -import org.matsim.contrib.drt.run.MultiModeDrtConfigGroup; -import org.matsim.core.controler.OutputDirectoryHierarchy; -import org.matsim.core.controler.events.IterationEndsEvent; -import org.matsim.core.controler.events.IterationStartsEvent; -import org.matsim.core.controler.events.ShutdownEvent; -import org.matsim.core.controler.listener.IterationEndsListener; -import org.matsim.core.controler.listener.IterationStartsListener; -import org.matsim.core.controler.listener.ShutdownListener; - -import com.google.inject.Inject; -import com.google.inject.Singleton; - -@Singleton -public class DvrpAnalysisListener implements IterationStartsListener, IterationEndsListener, ShutdownListener { - private static final String PASSENGER_RIDES_FILE_NAME = "eqasim_drt_passenger_rides.csv"; - private static final String VEHICLE_MOVEMENTS_FILE_NAME = "eqasim_drt_vehicle_movements.csv"; - private static final String VEHICLE_ACTIVITIES_FILE_NAME = "eqasim_drt_vehicle_activities.csv"; - - private final OutputDirectoryHierarchy outputDirectory; - - private final int analysisInterval; - private boolean isActive = false; - - private final PassengerAnalysisListener passengerAnalysisListener; - private final VehicleAnalysisListener vehicleAnalysisListener; - - private final VehicleRegistry vehicleRegistry; - - @Inject - public DvrpAnalysisListener(EqasimConfigGroup config, MultiModeDrtConfigGroup drtConfig, - OutputDirectoryHierarchy outputDirectory, Network network) { - this.outputDirectory = outputDirectory; - this.analysisInterval = config.getAnalysisInterval(); - - LinkFinder linkFinder = new LinkFinder(network); - this.vehicleRegistry = new VehicleRegistry(); - - this.passengerAnalysisListener = new PassengerAnalysisListener( - drtConfig.getModalElements().stream().map(e -> e.getMode()).collect(Collectors.toSet()), linkFinder, - vehicleRegistry); - this.vehicleAnalysisListener = new VehicleAnalysisListener(linkFinder, vehicleRegistry); - } - - @Override - public void notifyIterationStarts(IterationStartsEvent event) { - if (analysisInterval > 0) { - isActive = event.getIteration() % analysisInterval == 0 || event.isLastIteration(); - } - - if (isActive) { - event.getServices().getEvents().addHandler(passengerAnalysisListener); - event.getServices().getEvents().addHandler(vehicleAnalysisListener); - event.getServices().getEvents().addHandler(vehicleRegistry); - } - } - - @Override - public void notifyIterationEnds(IterationEndsEvent event) { - try { - if (isActive) { - event.getServices().getEvents().removeHandler(vehicleRegistry); - - event.getServices().getEvents().removeHandler(passengerAnalysisListener); - - String path = outputDirectory.getIterationFilename(event.getIteration(), PASSENGER_RIDES_FILE_NAME); - new PassengerAnalysisWriter(passengerAnalysisListener).writeRides(new File(path)); - - event.getServices().getEvents().removeHandler(vehicleAnalysisListener); - - String movementsPath = outputDirectory.getIterationFilename(event.getIteration(), - VEHICLE_MOVEMENTS_FILE_NAME); - new VehicleAnalysisWriter(vehicleAnalysisListener).writeMovements(new File(movementsPath)); - - String activitiesPath = outputDirectory.getIterationFilename(event.getIteration(), - VEHICLE_ACTIVITIES_FILE_NAME); - new VehicleAnalysisWriter(vehicleAnalysisListener).writeActivities(new File(activitiesPath)); - } - } catch (IOException e) { - throw new RuntimeException(e); - } - } - - @Override - public void notifyShutdown(ShutdownEvent event) { - try { - File iterationPath = new File( - outputDirectory.getIterationFilename(event.getIteration(), PASSENGER_RIDES_FILE_NAME)); - File outputPath = new File(outputDirectory.getOutputFilename(PASSENGER_RIDES_FILE_NAME)); - Files.copy(iterationPath.toPath(), outputPath.toPath()); - } catch (IOException e) { - } - - try { - File iterationPath = new File( - outputDirectory.getIterationFilename(event.getIteration(), VEHICLE_MOVEMENTS_FILE_NAME)); - File outputPath = new File(outputDirectory.getOutputFilename(VEHICLE_MOVEMENTS_FILE_NAME)); - Files.copy(iterationPath.toPath(), outputPath.toPath()); - } catch (IOException e) { - } - - try { - File iterationPath = new File( - outputDirectory.getIterationFilename(event.getIteration(), VEHICLE_ACTIVITIES_FILE_NAME)); - File outputPath = new File(outputDirectory.getOutputFilename(VEHICLE_ACTIVITIES_FILE_NAME)); - Files.copy(iterationPath.toPath(), outputPath.toPath()); - } catch (IOException e) { - } - } -} diff --git a/examples/src/main/java/org/eqasim/examples/corsica_drt/analysis/passengers/PassengerAnalysisListener.java b/examples/src/main/java/org/eqasim/examples/corsica_drt/analysis/passengers/PassengerAnalysisListener.java deleted file mode 100644 index 26122c46c..000000000 --- a/examples/src/main/java/org/eqasim/examples/corsica_drt/analysis/passengers/PassengerAnalysisListener.java +++ /dev/null @@ -1,125 +0,0 @@ -package org.eqasim.examples.corsica_drt.analysis.passengers; - -import java.util.Collection; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; - -import org.eqasim.examples.corsica_drt.analysis.utils.LinkFinder; -import org.eqasim.examples.corsica_drt.analysis.utils.PassengerTracker; -import org.eqasim.examples.corsica_drt.analysis.utils.VehicleRegistry; -import org.matsim.api.core.v01.Id; -import org.matsim.api.core.v01.events.LinkEnterEvent; -import org.matsim.api.core.v01.events.PersonArrivalEvent; -import org.matsim.api.core.v01.events.PersonDepartureEvent; -import org.matsim.api.core.v01.events.PersonEntersVehicleEvent; -import org.matsim.api.core.v01.events.PersonLeavesVehicleEvent; -import org.matsim.api.core.v01.events.handler.LinkEnterEventHandler; -import org.matsim.api.core.v01.events.handler.PersonArrivalEventHandler; -import org.matsim.api.core.v01.events.handler.PersonDepartureEventHandler; -import org.matsim.api.core.v01.events.handler.PersonEntersVehicleEventHandler; -import org.matsim.api.core.v01.events.handler.PersonLeavesVehicleEventHandler; -import org.matsim.api.core.v01.population.Person; - -public class PassengerAnalysisListener implements PersonDepartureEventHandler, PersonArrivalEventHandler, - LinkEnterEventHandler, PersonEntersVehicleEventHandler, PersonLeavesVehicleEventHandler { - private final LinkFinder linkFinder; - private final VehicleRegistry vehicleRegistry; - private final Collection modes; - private final PassengerTracker passengers = new PassengerTracker(); - - private final List rides = new LinkedList<>(); - private final Map, PassengerRideItem> currentRides = new HashMap<>(); - - public PassengerAnalysisListener(Collection modes, LinkFinder linkFinder, VehicleRegistry vehicleRegistry) { - this.linkFinder = linkFinder; - this.modes = modes; - this.vehicleRegistry = vehicleRegistry; - } - - @Override - public void handleEvent(PersonDepartureEvent event) { - if (!vehicleRegistry.isFleet(event.getPersonId())) { - if (modes.contains(event.getLegMode())) { - PassengerRideItem ride = new PassengerRideItem(); - rides.add(ride); - - ride.personId = event.getPersonId(); - ride.mode = event.getLegMode(); - - ride.departureTime = event.getTime(); - ride.originLink = linkFinder.getLink(event.getLinkId()); - - currentRides.put(event.getPersonId(), ride); - } - } - } - - @Override - public void handleEvent(LinkEnterEvent event) { - if (vehicleRegistry.isFleet(event.getVehicleId())) { - double distance = linkFinder.getDistance(event.getLinkId()); - - for (Id passengerId : passengers.getPassengerIds(event.getVehicleId())) { - PassengerRideItem ride = currentRides.get(passengerId); - - if (ride == null) { - throw new IllegalStateException("Found vehicle enter link without departure"); - } - - ride.distance += distance; - } - } - } - - @Override - public void handleEvent(PersonEntersVehicleEvent event) { - if (!vehicleRegistry.isFleet(event.getPersonId())) { - if (vehicleRegistry.isFleet(event.getVehicleId())) { - PassengerRideItem ride = currentRides.get(event.getPersonId()); - - if (ride == null) { - throw new IllegalStateException("Found vehicle enter event without departure"); - } - - ride.vehicleId = event.getVehicleId(); - ride.waitingTime = event.getTime() - ride.departureTime; - - passengers.addPassenger(event.getVehicleId(), event.getPersonId()); - } - } - } - - @Override - public void handleEvent(PersonLeavesVehicleEvent event) { - if (!vehicleRegistry.isFleet(event.getPersonId())) { - if (vehicleRegistry.isFleet(event.getVehicleId())) { - passengers.removePassenger(event.getVehicleId(), event.getPersonId()); - } - } - } - - @Override - public void handleEvent(PersonArrivalEvent event) { - if (!vehicleRegistry.isFleet(event.getPersonId())) { - PassengerRideItem ride = currentRides.remove(event.getPersonId()); - - if (ride != null) { - ride.arrivalTime = event.getTime(); - ride.destinationLink = linkFinder.getLink(event.getLinkId()); - } - } - } - - @Override - public void reset(int iteration) { - passengers.clear(); - rides.clear(); - currentRides.clear(); - } - - public List getRides() { - return rides; - } -} diff --git a/examples/src/main/java/org/eqasim/examples/corsica_drt/analysis/passengers/PassengerAnalysisWriter.java b/examples/src/main/java/org/eqasim/examples/corsica_drt/analysis/passengers/PassengerAnalysisWriter.java deleted file mode 100644 index 3dc814657..000000000 --- a/examples/src/main/java/org/eqasim/examples/corsica_drt/analysis/passengers/PassengerAnalysisWriter.java +++ /dev/null @@ -1,63 +0,0 @@ -package org.eqasim.examples.corsica_drt.analysis.passengers; - -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStreamWriter; - -public class PassengerAnalysisWriter { - private final PassengerAnalysisListener listener; - - public PassengerAnalysisWriter(PassengerAnalysisListener listener) { - this.listener = listener; - } - - public void writeRides(File path) throws IOException { - BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(path))); - - writer.write(String.join(";", new String[] { // - "person_id", // - "operator_id", // - "vehicle_id", // - - "origin_link_id", // - "origin_x", // - "origin_y", // - - "destination_link_id", // - "destination_x", // - "destination_y", // - - "departure_time", // - "arrival_time", // - "waiting_time", // - - "distance" // - }) + "\n"); - - for (PassengerRideItem ride : listener.getRides()) { - writer.write(String.join(";", new String[] { // - String.valueOf(ride.personId), // - ride.mode == null ? "NaN" : String.valueOf(ride.mode), // - ride.vehicleId == null ? "NaN" : String.valueOf(ride.vehicleId), // - - ride.originLink == null ? "null" : String.valueOf(ride.originLink.getId()), // - ride.originLink == null ? "NaN" : String.valueOf(ride.originLink.getCoord().getX()), // - ride.originLink == null ? "NaN" : String.valueOf(ride.originLink.getCoord().getY()), // - - ride.destinationLink == null ? "null" : String.valueOf(ride.destinationLink.getId()), // - ride.destinationLink == null ? "NaN" : String.valueOf(ride.destinationLink.getCoord().getX()), // - ride.destinationLink == null ? "NaN" : String.valueOf(ride.destinationLink.getCoord().getY()), // - - String.valueOf(ride.departureTime), // - String.valueOf(ride.arrivalTime), // - String.valueOf(ride.waitingTime), // - - String.valueOf(ride.distance) // - }) + "\n"); - } - - writer.close(); - } -} diff --git a/examples/src/main/java/org/eqasim/examples/corsica_drt/analysis/passengers/PassengerRideItem.java b/examples/src/main/java/org/eqasim/examples/corsica_drt/analysis/passengers/PassengerRideItem.java deleted file mode 100644 index 8da7877e4..000000000 --- a/examples/src/main/java/org/eqasim/examples/corsica_drt/analysis/passengers/PassengerRideItem.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.eqasim.examples.corsica_drt.analysis.passengers; - -import org.matsim.api.core.v01.Id; -import org.matsim.api.core.v01.network.Link; -import org.matsim.api.core.v01.population.Person; -import org.matsim.vehicles.Vehicle; - -public class PassengerRideItem { - public String mode; - - public Id personId; - public Id vehicleId; - - public Link originLink; - public Link destinationLink; - - public double departureTime = Double.NaN; - public double arrivalTime = Double.NaN; - public double waitingTime = Double.NaN; - - public double distance = 0.0; -} diff --git a/examples/src/main/java/org/eqasim/examples/corsica_drt/analysis/run/RunPassengerAnalysis.java b/examples/src/main/java/org/eqasim/examples/corsica_drt/analysis/run/RunPassengerAnalysis.java deleted file mode 100644 index a59bf302a..000000000 --- a/examples/src/main/java/org/eqasim/examples/corsica_drt/analysis/run/RunPassengerAnalysis.java +++ /dev/null @@ -1,52 +0,0 @@ -package org.eqasim.examples.corsica_drt.analysis.run; - -import java.io.File; -import java.io.IOException; -import java.util.Arrays; -import java.util.Set; -import java.util.stream.Collectors; - -import org.eqasim.examples.corsica_drt.analysis.passengers.PassengerAnalysisListener; -import org.eqasim.examples.corsica_drt.analysis.passengers.PassengerAnalysisWriter; -import org.eqasim.examples.corsica_drt.analysis.utils.LinkFinder; -import org.eqasim.examples.corsica_drt.analysis.utils.VehicleRegistry; -import org.matsim.api.core.v01.network.Network; -import org.matsim.core.api.experimental.events.EventsManager; -import org.matsim.core.config.CommandLine; -import org.matsim.core.config.CommandLine.ConfigurationException; -import org.matsim.core.events.EventsUtils; -import org.matsim.core.events.MatsimEventsReader; -import org.matsim.core.network.NetworkUtils; -import org.matsim.core.network.io.MatsimNetworkReader; - -public class RunPassengerAnalysis { - static public void main(String[] args) throws ConfigurationException, IOException { - CommandLine cmd = new CommandLine.Builder(args) // - .requireOptions("events-path", "network-path", "output-path", "modes") // - .build(); - - String eventsPath = cmd.getOptionStrict("events-path"); - String networkPath = cmd.getOptionStrict("network-path"); - String outputPath = cmd.getOptionStrict("output-path"); - - String rawModes = cmd.getOptionStrict("modes"); - Set modes = Arrays.asList(rawModes.split(",")).stream().map(String::trim).collect(Collectors.toSet()); - - Network network = NetworkUtils.createNetwork(); - new MatsimNetworkReader(network).readFile(networkPath); - - LinkFinder linkFinder = new LinkFinder(network); - VehicleRegistry vehicleRegistry = new VehicleRegistry(); - PassengerAnalysisListener listener = new PassengerAnalysisListener(modes, linkFinder, vehicleRegistry); - - EventsManager eventsManager = EventsUtils.createEventsManager(); - eventsManager.addHandler(vehicleRegistry); - eventsManager.addHandler(listener); - - eventsManager.initProcessing(); - new MatsimEventsReader(eventsManager).readFile(eventsPath); - eventsManager.finishProcessing(); - - new PassengerAnalysisWriter(listener).writeRides(new File(outputPath)); - } -} diff --git a/examples/src/main/java/org/eqasim/examples/corsica_drt/analysis/run/RunVehicleAnalysis.java b/examples/src/main/java/org/eqasim/examples/corsica_drt/analysis/run/RunVehicleAnalysis.java deleted file mode 100644 index 5b1c1a43e..000000000 --- a/examples/src/main/java/org/eqasim/examples/corsica_drt/analysis/run/RunVehicleAnalysis.java +++ /dev/null @@ -1,48 +0,0 @@ -package org.eqasim.examples.corsica_drt.analysis.run; - -import java.io.File; -import java.io.IOException; - -import org.eqasim.examples.corsica_drt.analysis.utils.LinkFinder; -import org.eqasim.examples.corsica_drt.analysis.utils.VehicleRegistry; -import org.eqasim.examples.corsica_drt.analysis.vehicles.VehicleAnalysisListener; -import org.eqasim.examples.corsica_drt.analysis.vehicles.VehicleAnalysisWriter; -import org.matsim.api.core.v01.network.Network; -import org.matsim.core.api.experimental.events.EventsManager; -import org.matsim.core.config.CommandLine; -import org.matsim.core.config.CommandLine.ConfigurationException; -import org.matsim.core.events.EventsUtils; -import org.matsim.core.events.MatsimEventsReader; -import org.matsim.core.network.NetworkUtils; -import org.matsim.core.network.io.MatsimNetworkReader; - -public class RunVehicleAnalysis { - static public void main(String[] args) throws ConfigurationException, IOException { - CommandLine cmd = new CommandLine.Builder(args) // - .requireOptions("events-path", "network-path", "movements-output-path", "activities-output-path") // - .build(); - - String eventsPath = cmd.getOptionStrict("events-path"); - String networkPath = cmd.getOptionStrict("network-path"); - String movementsOutputPath = cmd.getOptionStrict("movements-output-path"); - String activitiesOutputPath = cmd.getOptionStrict("activities-output-path"); - - Network network = NetworkUtils.createNetwork(); - new MatsimNetworkReader(network).readFile(networkPath); - - LinkFinder linkFinder = new LinkFinder(network); - VehicleRegistry vehicleRegistry = new VehicleRegistry(); - VehicleAnalysisListener listener = new VehicleAnalysisListener(linkFinder, vehicleRegistry); - - EventsManager eventsManager = EventsUtils.createEventsManager(); - eventsManager.addHandler(vehicleRegistry); - eventsManager.addHandler(listener); - - eventsManager.initProcessing(); - new MatsimEventsReader(eventsManager).readFile(eventsPath); - eventsManager.finishProcessing(); - - new VehicleAnalysisWriter(listener).writeMovements(new File(movementsOutputPath)); - new VehicleAnalysisWriter(listener).writeActivities(new File(activitiesOutputPath)); - } -} diff --git a/examples/src/main/java/org/eqasim/examples/corsica_drt/analysis/utils/LinkFinder.java b/examples/src/main/java/org/eqasim/examples/corsica_drt/analysis/utils/LinkFinder.java deleted file mode 100644 index e3cb3037a..000000000 --- a/examples/src/main/java/org/eqasim/examples/corsica_drt/analysis/utils/LinkFinder.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.eqasim.examples.corsica_drt.analysis.utils; - -import org.matsim.api.core.v01.Id; -import org.matsim.api.core.v01.network.Link; -import org.matsim.api.core.v01.network.Network; - -public class LinkFinder { - private final Network network; - - public LinkFinder(Network network) { - this.network = network; - } - - public Link getLink(Id linkId) { - Link link = network.getLinks().get(linkId); - - if (link == null) { - throw new IllegalStateException("Cannot find link: " + linkId); - } - - return link; - } - - public double getDistance(Id linkId) { - return getLink(linkId).getLength(); - } -} diff --git a/examples/src/main/java/org/eqasim/examples/corsica_drt/analysis/utils/PassengerTracker.java b/examples/src/main/java/org/eqasim/examples/corsica_drt/analysis/utils/PassengerTracker.java deleted file mode 100644 index 16c8eb8b7..000000000 --- a/examples/src/main/java/org/eqasim/examples/corsica_drt/analysis/utils/PassengerTracker.java +++ /dev/null @@ -1,58 +0,0 @@ -package org.eqasim.examples.corsica_drt.analysis.utils; - -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import org.matsim.api.core.v01.Id; -import org.matsim.api.core.v01.population.Person; -import org.matsim.vehicles.Vehicle; - -public class PassengerTracker { - private final Map, Set>> passengers = new HashMap<>(); - - private void ensurePassengers(Id vehicleId) { - if (!passengers.containsKey(vehicleId)) { - passengers.put(vehicleId, new HashSet<>()); - } - } - - public boolean hasPassenger(Id vehicleId, Id passengerId) { - ensurePassengers(vehicleId); - return passengers.get(vehicleId).contains(passengerId); - } - - public void addPassenger(Id vehicleId, Id passengerId) { - ensurePassengers(vehicleId); - - if (!passengers.get(vehicleId).add(passengerId)) { - throw new IllegalStateException(String.format("Passenger '%s' is already in vehicle '%s'", passengerId, vehicleId)); - } - } - - public void removePassenger(Id vehicleId, Id passengerId) { - ensurePassengers(vehicleId); - - if (!passengers.get(vehicleId).remove(passengerId)) { - throw new IllegalStateException(String.format("Passenger '%s' is not in vehicle '%s'", passengerId, vehicleId)); - } - } - - public int getNumberOfPassengers(Id vehicleId) { - ensurePassengers(vehicleId); - return passengers.get(vehicleId).size(); - } - - public Collection> getPassengerIds(Id vehicleId) { - ensurePassengers(vehicleId); - return passengers.get(vehicleId); - } - - public void clear() { - for (Set> passengerList : passengers.values()) { - passengerList.clear(); - } - } -} diff --git a/examples/src/main/java/org/eqasim/examples/corsica_drt/analysis/utils/VehicleRegistry.java b/examples/src/main/java/org/eqasim/examples/corsica_drt/analysis/utils/VehicleRegistry.java deleted file mode 100644 index 8a6833b8d..000000000 --- a/examples/src/main/java/org/eqasim/examples/corsica_drt/analysis/utils/VehicleRegistry.java +++ /dev/null @@ -1,24 +0,0 @@ -package org.eqasim.examples.corsica_drt.analysis.utils; - -import org.matsim.api.core.v01.Id; -import org.matsim.api.core.v01.IdMap; -import org.matsim.contrib.dvrp.fleet.DvrpVehicle; -import org.matsim.contrib.dvrp.vrpagent.TaskStartedEvent; -import org.matsim.contrib.dvrp.vrpagent.TaskStartedEventHandler; - -public class VehicleRegistry implements TaskStartedEventHandler { - private final IdMap vehicleModes = new IdMap<>(DvrpVehicle.class); - - @Override - public void handleEvent(TaskStartedEvent event) { - vehicleModes.computeIfAbsent(event.getDvrpVehicleId(), id -> event.getDvrpMode()); - } - - public boolean isFleet(Id id) { - return vehicleModes.containsKey(Id.create(id, DvrpVehicle.class)); - } - - public String getMode(Id id) { - return vehicleModes.get(Id.create(id, DvrpVehicle.class)); - } -} diff --git a/examples/src/main/java/org/eqasim/examples/corsica_drt/analysis/vehicles/VehicleActivityItem.java b/examples/src/main/java/org/eqasim/examples/corsica_drt/analysis/vehicles/VehicleActivityItem.java deleted file mode 100644 index 02e0c0f63..000000000 --- a/examples/src/main/java/org/eqasim/examples/corsica_drt/analysis/vehicles/VehicleActivityItem.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.eqasim.examples.corsica_drt.analysis.vehicles; - -import org.matsim.api.core.v01.Id; -import org.matsim.api.core.v01.network.Link; -import org.matsim.vehicles.Vehicle; - -public class VehicleActivityItem { - public String mode; - - public Id vehicleId; - public Link link; - - public double startTime = Double.NaN; - public double endTime = Double.NaN; - - public String type; -} diff --git a/examples/src/main/java/org/eqasim/examples/corsica_drt/analysis/vehicles/VehicleAnalysisListener.java b/examples/src/main/java/org/eqasim/examples/corsica_drt/analysis/vehicles/VehicleAnalysisListener.java deleted file mode 100644 index 463f0229e..000000000 --- a/examples/src/main/java/org/eqasim/examples/corsica_drt/analysis/vehicles/VehicleAnalysisListener.java +++ /dev/null @@ -1,176 +0,0 @@ -package org.eqasim.examples.corsica_drt.analysis.vehicles; - -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; - -import org.eqasim.examples.corsica_drt.analysis.utils.LinkFinder; -import org.eqasim.examples.corsica_drt.analysis.utils.PassengerTracker; -import org.eqasim.examples.corsica_drt.analysis.utils.VehicleRegistry; -import org.matsim.api.core.v01.Id; -import org.matsim.api.core.v01.events.ActivityEndEvent; -import org.matsim.api.core.v01.events.ActivityStartEvent; -import org.matsim.api.core.v01.events.LinkEnterEvent; -import org.matsim.api.core.v01.events.PersonArrivalEvent; -import org.matsim.api.core.v01.events.PersonDepartureEvent; -import org.matsim.api.core.v01.events.PersonEntersVehicleEvent; -import org.matsim.api.core.v01.events.PersonLeavesVehicleEvent; -import org.matsim.api.core.v01.events.handler.ActivityEndEventHandler; -import org.matsim.api.core.v01.events.handler.ActivityStartEventHandler; -import org.matsim.api.core.v01.events.handler.LinkEnterEventHandler; -import org.matsim.api.core.v01.events.handler.PersonArrivalEventHandler; -import org.matsim.api.core.v01.events.handler.PersonDepartureEventHandler; -import org.matsim.api.core.v01.events.handler.PersonEntersVehicleEventHandler; -import org.matsim.api.core.v01.events.handler.PersonLeavesVehicleEventHandler; -import org.matsim.vehicles.Vehicle; - -public class VehicleAnalysisListener implements PersonDepartureEventHandler, PersonArrivalEventHandler, ActivityStartEventHandler, ActivityEndEventHandler, LinkEnterEventHandler, - PersonEntersVehicleEventHandler, PersonLeavesVehicleEventHandler { - private final LinkFinder linkFinder; - private final VehicleRegistry vehicleRegistry; - private final PassengerTracker passengers = new PassengerTracker(); - - private final List movements = new LinkedList<>(); - private final List activities = new LinkedList<>(); - - private final Map, VehicleMovementItem> currentMovements = new HashMap<>(); - private final Map, VehicleActivityItem> currentActivities = new HashMap<>(); - - public VehicleAnalysisListener(LinkFinder linkFinder, VehicleRegistry vehicleRegistry) { - this.linkFinder = linkFinder; - this.vehicleRegistry = vehicleRegistry; - } - - @Override - public void handleEvent(PersonDepartureEvent event) { - if (vehicleRegistry.isFleet(event.getPersonId())) { - String mode = vehicleRegistry.getMode(event.getPersonId()); - Id vehicleId = Id.createVehicleId(event.getPersonId()); - - VehicleMovementItem movement = new VehicleMovementItem(); - movements.add(movement); - - movement.mode = mode; - movement.vehicleId = vehicleId; - - movement.originLink = linkFinder.getLink(event.getLinkId()); - movement.departureTime = event.getTime(); - - currentMovements.put(vehicleId, movement); - } - } - - @Override - public void handleEvent(LinkEnterEvent event) { - if (vehicleRegistry.isFleet(event.getVehicleId())) { - VehicleMovementItem movement = currentMovements.get(event.getVehicleId()); - - if (movement == null) { - throw new IllegalStateException("Found link enter event without departure"); - } - - movement.distance += linkFinder.getDistance(event.getLinkId()); - } - } - - @Override - public void handleEvent(PersonEntersVehicleEvent event) { - if (!vehicleRegistry.isFleet(event.getPersonId())) { - if (vehicleRegistry.isFleet(event.getVehicleId())) { - passengers.addPassenger(event.getVehicleId(), event.getPersonId()); - } - } - } - - @Override - public void handleEvent(PersonLeavesVehicleEvent event) { - if (!vehicleRegistry.isFleet(event.getPersonId())) { - if (vehicleRegistry.isFleet(event.getVehicleId())) { - passengers.removePassenger(event.getVehicleId(), event.getPersonId()); - } - } - } - - @Override - public void handleEvent(PersonArrivalEvent event) { - if (vehicleRegistry.isFleet(event.getPersonId())) { - Id vehicleId = Id.createVehicleId(event.getPersonId()); - - VehicleMovementItem movement = currentMovements.remove(vehicleId); - - if (movement == null) { - throw new IllegalStateException("Found arrival without departure"); - } - - movement.destinationLink = linkFinder.getLink(event.getLinkId()); - movement.arrivalTime = event.getTime(); - - movement.numberOfPassengers = passengers.getNumberOfPassengers(vehicleId); - } - } - - @Override - public void handleEvent(ActivityStartEvent event) { - if (vehicleRegistry.isFleet(event.getPersonId())) { - String mode = vehicleRegistry.getMode(event.getPersonId()); - Id vehicleId = Id.createVehicleId(event.getPersonId()); - - VehicleActivityItem activity = new VehicleActivityItem(); - activities.add(activity); - - activity.mode = mode; - activity.vehicleId = vehicleId; - - activity.link = linkFinder.getLink(event.getLinkId()); - activity.type = event.getActType(); - - activity.startTime = event.getTime(); - - currentActivities.put(vehicleId, activity); - } - } - - @Override - public void handleEvent(ActivityEndEvent event) { - if (vehicleRegistry.isFleet(event.getPersonId())) { - String mode = vehicleRegistry.getMode(event.getPersonId()); - Id vehicleId = Id.createVehicleId(event.getPersonId()); - - VehicleActivityItem activity = currentActivities.remove(vehicleId); - boolean isStarted = activity != null; - - if (!isStarted) { - activity = new VehicleActivityItem(); - activities.add(activity); - } - - activity.mode = mode; - activity.vehicleId = vehicleId; - - activity.link = linkFinder.getLink(event.getLinkId()); - activity.type = event.getActType(); - - activity.endTime = event.getTime(); - } - } - - @Override - public void reset(int iteration) { - passengers.clear(); - - currentActivities.clear(); - currentMovements.clear(); - - activities.clear(); - movements.clear(); - } - - public List getActivities() { - return activities; - } - - public List getMovements() { - return movements; - } -} diff --git a/examples/src/main/java/org/eqasim/examples/corsica_drt/analysis/vehicles/VehicleAnalysisWriter.java b/examples/src/main/java/org/eqasim/examples/corsica_drt/analysis/vehicles/VehicleAnalysisWriter.java deleted file mode 100644 index 9abcae6ac..000000000 --- a/examples/src/main/java/org/eqasim/examples/corsica_drt/analysis/vehicles/VehicleAnalysisWriter.java +++ /dev/null @@ -1,97 +0,0 @@ -package org.eqasim.examples.corsica_drt.analysis.vehicles; - -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStreamWriter; - -public class VehicleAnalysisWriter { - private final VehicleAnalysisListener listener; - - public VehicleAnalysisWriter(VehicleAnalysisListener listener) { - this.listener = listener; - } - - public void writeMovements(File path) throws IOException { - BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(path))); - - writer.write(String.join(";", new String[] { // - "operator_id", // - "vehicle_id", // - - "origin_link_id", // - "origin_x", // - "origin_y", // - - "destination_link_id", // - "destination_x", // - "destination_y", // - - "departure_time", // - "arrival_time", // - - "distance", // - "number_of_passengers" // - }) + "\n"); - - for (VehicleMovementItem movement : listener.getMovements()) { - writer.write(String.join(";", new String[] { // - String.valueOf(movement.mode), // - String.valueOf(movement.vehicleId), // - - String.valueOf(movement.originLink.getId()), // - String.valueOf(movement.originLink.getCoord().getX()), // - String.valueOf(movement.originLink.getCoord().getY()), // - - movement.destinationLink == null ? "null" : String.valueOf(movement.destinationLink.getId()), // - movement.destinationLink == null ? "NaN" : String.valueOf(movement.destinationLink.getCoord().getX()), // - movement.destinationLink == null ? "NaN" : String.valueOf(movement.destinationLink.getCoord().getY()), // - - String.valueOf(movement.departureTime), // - String.valueOf(movement.arrivalTime), // - - String.valueOf(movement.distance), // - String.valueOf(movement.numberOfPassengers) // - }) + "\n"); - } - - writer.close(); - } - - public void writeActivities(File path) throws IOException { - BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(path))); - - writer.write(String.join(";", new String[] { // - "operator_id", // - "vehicle_id", // - - "link_id", // - "x", // - "y", // - - "start_time", // - "end_time", // - - "type" // - }) + "\n"); - - for (VehicleActivityItem activity : listener.getActivities()) { - writer.write(String.join(";", new String[] { // - String.valueOf(activity.mode), // - String.valueOf(activity.vehicleId), // - - String.valueOf(activity.link.getId()), // - String.valueOf(activity.link.getCoord().getX()), // - String.valueOf(activity.link.getCoord().getY()), // - - String.valueOf(activity.startTime), // - String.valueOf(activity.endTime), // - - activity.type // - }) + "\n"); - } - - writer.close(); - } -} diff --git a/examples/src/main/java/org/eqasim/examples/corsica_drt/analysis/vehicles/VehicleMovementItem.java b/examples/src/main/java/org/eqasim/examples/corsica_drt/analysis/vehicles/VehicleMovementItem.java deleted file mode 100644 index b3c226659..000000000 --- a/examples/src/main/java/org/eqasim/examples/corsica_drt/analysis/vehicles/VehicleMovementItem.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.eqasim.examples.corsica_drt.analysis.vehicles; - -import org.matsim.api.core.v01.Id; -import org.matsim.api.core.v01.network.Link; -import org.matsim.vehicles.Vehicle; - -public class VehicleMovementItem { - public String mode; - public Id vehicleId; - - public Link originLink; - public Link destinationLink; - - public double departureTime = Double.NaN; - public double arrivalTime = Double.NaN; - - public double distance = 0; - public int numberOfPassengers = 0; -} diff --git a/examples/src/main/java/org/eqasim/examples/corsica_drt/mode_choice/parameters/CorsicaDrtModeParameters.java b/examples/src/main/java/org/eqasim/examples/corsica_drt/mode_choice/parameters/CorsicaDrtModeParameters.java deleted file mode 100644 index e9dbd24ee..000000000 --- a/examples/src/main/java/org/eqasim/examples/corsica_drt/mode_choice/parameters/CorsicaDrtModeParameters.java +++ /dev/null @@ -1,61 +0,0 @@ -package org.eqasim.examples.corsica_drt.mode_choice.parameters; - -import org.eqasim.ile_de_france.mode_choice.parameters.IDFModeParameters; - -public class CorsicaDrtModeParameters extends IDFModeParameters { - public class ParisDrtParameters { - public double alpha_u = 0.0; - public double betaTravelTime_u_min = 0.0; - public double betaWaitingTime_u_min = 0.0; - public double betaAccessEgressTime_u_min = 0.0; - } - - public ParisDrtParameters drt = new ParisDrtParameters(); - - public static CorsicaDrtModeParameters buildDefault() { - // This is a copy & paste - - CorsicaDrtModeParameters parameters = new CorsicaDrtModeParameters(); - - // Cost - parameters.betaCost_u_MU = -0.206; - parameters.lambdaCostEuclideanDistance = -0.4; - parameters.referenceEuclideanDistance_km = 40.0; - - // Car - parameters.car.alpha_u = 1.35; - parameters.car.betaTravelTime_u_min = -0.06; - - parameters.car.additionalAccessEgressWalkTime_min = 4.0; - parameters.car.constantParkingSearchPenalty_min = 4.0; - - parameters.idfCar.betaInsideUrbanArea = -0.5; - parameters.idfCar.betaCrossingUrbanArea = -1.0; - - // PT - parameters.pt.alpha_u = 0.0; - parameters.pt.betaLineSwitch_u = -0.17; - parameters.pt.betaInVehicleTime_u_min = -0.017; - parameters.pt.betaWaitingTime_u_min = -0.0484; - parameters.pt.betaAccessEgressTime_u_min = -0.0804; - - // Bike - parameters.bike.alpha_u = -2.0; - parameters.bike.betaTravelTime_u_min = -0.05; - parameters.bike.betaAgeOver18_u_a = -0.0496; - - parameters.idfBike.betaInsideUrbanArea = 1.5; - - // Walk - parameters.walk.alpha_u = 1.43; - parameters.walk.betaTravelTime_u_min = -0.15; - - // DRT (adapted from public transport) - parameters.drt.alpha_u = 0.0; - parameters.drt.betaWaitingTime_u_min = -0.0484; - parameters.drt.betaTravelTime_u_min = -0.017; - parameters.drt.betaAccessEgressTime_u_min = -0.0804; - - return parameters; - } -} diff --git a/examples/src/main/java/org/eqasim/examples/corsica_drt/mode_choice/utilities/DrtPredictor.java b/examples/src/main/java/org/eqasim/examples/corsica_drt/mode_choice/utilities/DrtPredictor.java deleted file mode 100644 index 24a42799b..000000000 --- a/examples/src/main/java/org/eqasim/examples/corsica_drt/mode_choice/utilities/DrtPredictor.java +++ /dev/null @@ -1,58 +0,0 @@ -package org.eqasim.examples.corsica_drt.mode_choice.utilities; - -import java.util.List; - -import org.eqasim.core.simulation.mode_choice.cost.CostModel; -import org.eqasim.core.simulation.mode_choice.utilities.predictors.CachedVariablePredictor; -import org.eqasim.core.simulation.mode_choice.utilities.predictors.PredictorUtils; -import org.matsim.api.core.v01.TransportMode; -import org.matsim.api.core.v01.population.Leg; -import org.matsim.api.core.v01.population.Person; -import org.matsim.api.core.v01.population.PlanElement; -import org.matsim.contrib.drt.routing.DrtRoute; -import org.matsim.contribs.discrete_mode_choice.model.DiscreteModeChoiceTrip; -import org.matsim.core.router.TripStructureUtils; - -import com.google.inject.Inject; -import com.google.inject.name.Named; - -public class DrtPredictor extends CachedVariablePredictor { - private CostModel costModel; - - @Inject - public DrtPredictor(@Named("drt") CostModel costModel) { - this.costModel = costModel; - } - - @Override - public DrtVariables predict(Person person, DiscreteModeChoiceTrip trip, List elements) { - double travelTime_min = 0.0; - double accessEgressTime_min = 0.0; - double cost_MU = 0.0; - double waitingTime_min = 0.0; - - for (Leg leg : TripStructureUtils.getLegs(elements)) { - switch (leg.getMode()) { - case TransportMode.walk: - accessEgressTime_min += leg.getTravelTime().seconds() / 60.0; - break; - case "drt": - DrtRoute route = (DrtRoute) leg.getRoute(); - - // We use worst case here - travelTime_min = route.getMaxTravelTime() / 60.0; - waitingTime_min = route.getMaxWaitTime() / 60.0; - - cost_MU = costModel.calculateCost_MU(person, trip, elements); - - break; - default: - throw new IllegalStateException("Encountered unknown mode in DrtPredictor: " + leg.getMode()); - } - } - - double euclideanDistance_km = PredictorUtils.calculateEuclideanDistance_km(trip); - - return new DrtVariables(travelTime_min, cost_MU, euclideanDistance_km, waitingTime_min, accessEgressTime_min); - } -} diff --git a/examples/src/main/java/org/eqasim/examples/corsica_drt/mode_choice/utilities/DrtUtilityEstimator.java b/examples/src/main/java/org/eqasim/examples/corsica_drt/mode_choice/utilities/DrtUtilityEstimator.java deleted file mode 100644 index 1a2b1bbd9..000000000 --- a/examples/src/main/java/org/eqasim/examples/corsica_drt/mode_choice/utilities/DrtUtilityEstimator.java +++ /dev/null @@ -1,59 +0,0 @@ -package org.eqasim.examples.corsica_drt.mode_choice.utilities; - -import java.util.List; - -import org.eqasim.core.simulation.mode_choice.utilities.UtilityEstimator; -import org.eqasim.core.simulation.mode_choice.utilities.estimators.EstimatorUtils; -import org.eqasim.examples.corsica_drt.mode_choice.parameters.CorsicaDrtModeParameters; -import org.matsim.api.core.v01.population.Person; -import org.matsim.api.core.v01.population.PlanElement; -import org.matsim.contribs.discrete_mode_choice.model.DiscreteModeChoiceTrip; - -import com.google.inject.Inject; - -public class DrtUtilityEstimator implements UtilityEstimator { - private final CorsicaDrtModeParameters parameters; - private final DrtPredictor predictor; - - @Inject - public DrtUtilityEstimator(CorsicaDrtModeParameters parameters, DrtPredictor predictor) { - this.parameters = parameters; - this.predictor = predictor; - } - - protected double estimateConstantUtility() { - return parameters.drt.alpha_u; - } - - protected double estimateTravelTimeUtility(DrtVariables variables) { - return parameters.drt.betaTravelTime_u_min * variables.travelTime_min; - } - - protected double estimateWaitingTimeUtility(DrtVariables variables) { - return parameters.drt.betaWaitingTime_u_min * variables.waitingTime_min; - } - - protected double estimateMonetaryCostUtility(DrtVariables variables) { - return parameters.betaCost_u_MU * EstimatorUtils.interaction(variables.euclideanDistance_km, - parameters.referenceEuclideanDistance_km, parameters.lambdaCostEuclideanDistance) * variables.cost_MU; - } - - protected double estimateAccessEgressTimeUtility(DrtVariables variables) { - return parameters.drt.betaAccessEgressTime_u_min * variables.accessEgressTime_min; - } - - @Override - public double estimateUtility(Person person, DiscreteModeChoiceTrip trip, List elements) { - DrtVariables variables = predictor.predict(person, trip, elements); - - double utility = 0.0; - - utility += estimateConstantUtility(); - utility += estimateTravelTimeUtility(variables); - utility += estimateWaitingTimeUtility(variables); - utility += estimateMonetaryCostUtility(variables); - utility += estimateAccessEgressTimeUtility(variables); - - return utility; - } -} diff --git a/examples/src/main/java/org/eqasim/examples/corsica_drt/mode_choice/utilities/DrtVariables.java b/examples/src/main/java/org/eqasim/examples/corsica_drt/mode_choice/utilities/DrtVariables.java deleted file mode 100644 index 34b322fae..000000000 --- a/examples/src/main/java/org/eqasim/examples/corsica_drt/mode_choice/utilities/DrtVariables.java +++ /dev/null @@ -1,20 +0,0 @@ -package org.eqasim.examples.corsica_drt.mode_choice.utilities; - -import org.eqasim.core.simulation.mode_choice.utilities.variables.BaseVariables; - -public class DrtVariables implements BaseVariables { - final public double travelTime_min; - final public double cost_MU; - final public double euclideanDistance_km; - final public double waitingTime_min; - final public double accessEgressTime_min; - - public DrtVariables(double travelTime_min, double cost_MU, double euclideanDistance_km, double waitingTime_min, - double accessEgressTime_min) { - this.travelTime_min = travelTime_min; - this.cost_MU = cost_MU; - this.euclideanDistance_km = euclideanDistance_km; - this.waitingTime_min = waitingTime_min; - this.accessEgressTime_min = accessEgressTime_min; - } -}