Skip to content

Commit

Permalink
add vdf
Browse files Browse the repository at this point in the history
  • Loading branch information
sebhoerl committed Oct 21, 2024
1 parent b685880 commit 36b5aea
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,16 @@

import org.eqasim.core.simulation.vdf.travel_time.VDFLinkSpeedCalculator;
import org.eqasim.core.simulation.vdf.travel_time.VDFTravelTime;
import org.matsim.api.core.v01.Scenario;
import org.matsim.api.core.v01.population.Population;
import org.matsim.core.api.experimental.events.EventsManager;
import org.matsim.core.mobsim.qsim.AbstractQSimModule;
import org.matsim.core.mobsim.qsim.qnetsimengine.ConfigurableQNetworkFactory;
import org.matsim.core.mobsim.qsim.qnetsimengine.QNetworkFactory;

import com.google.inject.Provides;
import com.google.inject.Singleton;

public class VDFQSimModule extends AbstractQSimModule {
@Override
protected void configureQSim() {
}

@Provides
@Singleton
public QNetworkFactory provideQNetworkFactory(EventsManager events, Scenario scenario,
VDFLinkSpeedCalculator linkSpeedCalculator) {
ConfigurableQNetworkFactory networkFactory = new ConfigurableQNetworkFactory(events, scenario);
networkFactory.setLinkSpeedCalculator(linkSpeedCalculator);
return networkFactory;
addLinkSpeedCalculator().to(VDFLinkSpeedCalculator.class);
}

@Provides
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import org.eqasim.core.scenario.validation.VehiclesValidator;
import org.eqasim.core.simulation.analysis.EqasimAnalysisModule;
import org.eqasim.core.simulation.mode_choice.EqasimModeChoiceModule;
import org.eqasim.core.simulation.vdf.VDFConfigGroup;
import org.eqasim.core.simulation.vdf.engine.VDFEngineConfigGroup;
import org.eqasim.ile_de_france.mode_choice.IDFModeChoiceModule;
import org.matsim.api.core.v01.Id;
import org.matsim.api.core.v01.Scenario;
Expand Down Expand Up @@ -39,11 +41,26 @@ public class RunSimulation {
static public void main(String[] args) throws ConfigurationException {
CommandLine cmd = new CommandLine.Builder(args) //
.requireOptions("config-path") //
.allowPrefixes("mode-choice-parameter", "cost-parameter") //
.allowPrefixes("mode-choice-parameter", "cost-parameter", "use-vdf") //
.build();

IDFConfigurator configurator = new IDFConfigurator();
Config config = ConfigUtils.loadConfig(cmd.getOptionStrict("config-path"), configurator.getConfigGroups());

if (cmd.getOption("use-vdf").map(Boolean::parseBoolean).orElse(false)) {
EqasimConfigGroup eqasimConfig = EqasimConfigGroup.get(config);

VDFConfigGroup vdfConfig = new VDFConfigGroup();
config.addModule(vdfConfig);

vdfConfig.setCapacityFactor(eqasimConfig.getSampleSize());
vdfConfig.setModes(Set.of("car", "car_passenger"));

VDFEngineConfigGroup engineConfig = new VDFEngineConfigGroup();
engineConfig.setModes(Set.of("car", "car_passenger"));
engineConfig.setGenerateNetworkEvents(false);
}

configurator.addOptionalConfigGroups(config);
cmd.applyConfiguration(config);
VehiclesValidator.validate(config);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ static public void adaptConfiguration(Config config, String prefix) {
config.routing().setAccessEgressType(AccessEgressType.accessEgressModeToLink);

Set<String> networkModes = new HashSet<>(config.routing().getNetworkModes());
networkModes.add("passenger");
networkModes.add(IDFModeChoiceModule.CAR_PASSENGER);
config.routing().setNetworkModes(networkModes);

TeleportedModeParams bicycleRouteParams = new TeleportedModeParams();
Expand Down Expand Up @@ -70,7 +70,7 @@ static public void adaptConfiguration(Config config, String prefix) {
.get(DiscreteModeChoiceConfigGroup.GROUP_NAME);

dmcConfig.setModeAvailability(IDFModeChoiceModule.MODE_AVAILABILITY_NAME);
dmcConfig.setCachedModes(Arrays.asList("car", "bicycle", "pt", "walk", "car_passenger", "truck"));
dmcConfig.setCachedModes(Arrays.asList("car", "bicycle", "pt", "walk", IDFModeChoiceModule.CAR_PASSENGER, "truck"));

Set<String> tripConstraints = new HashSet<>(dmcConfig.getTripConstraints());
tripConstraints.remove(EqasimModeChoiceModule.PASSENGER_CONSTRAINT_NAME);
Expand Down

0 comments on commit 36b5aea

Please sign in to comment.