-
-
Save MayuriAnn/6bdb03ce4e739fc93e7ea2e07ccc7971 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.eqasim.examples.sao_paulo_drt; | |
import java.io.IOException; | |
import java.net.URL; | |
import java.util.Arrays; | |
import java.util.Collection; | |
import java.util.HashSet; | |
import java.util.List; | |
import java.util.Set; | |
import org.eqasim.core.components.config.EqasimConfigGroup; | |
import org.eqasim.core.components.transit.EqasimTransitQSimModule; | |
import org.eqasim.core.simulation.EqasimConfigurator; | |
import org.eqasim.core.simulation.analysis.EqasimAnalysisModule; | |
import org.eqasim.core.simulation.mode_choice.AbstractEqasimExtension; | |
import org.eqasim.core.simulation.mode_choice.EqasimModeChoiceModule; | |
import org.eqasim.core.simulation.mode_choice.parameters.ModeParameters; | |
import org.eqasim.core.simulation.modes.drt.analysis.DrtAnalysisModule; | |
import org.eqasim.core.simulation.modes.drt.utils.AdaptConfigForDrt; | |
import org.eqasim.core.simulation.modes.drt.utils.CreateDrtVehicles; | |
import org.eqasim.core.simulation.modes.feeder_drt.MultiModeFeederDrtModule; | |
import org.eqasim.core.simulation.modes.feeder_drt.analysis.run.RunFeederDrtPassengerAnalysis; | |
import org.eqasim.core.simulation.modes.feeder_drt.config.MultiModeFeederDrtConfigGroup; | |
import org.eqasim.core.simulation.modes.feeder_drt.mode_choice.FeederDrtModeAvailabilityWrapper; | |
import org.eqasim.core.simulation.modes.feeder_drt.utils.AdaptConfigForFeederDrt; | |
import org.eqasim.core.simulation.modes.transit_with_abstract_access.mode_choice.TransitWithAbstractAccessModeAvailabilityWrapper; | |
import org.eqasim.examples.sao_paulo_drt.mode_choice.SaoPauloDrtModeAvailability; | |
import org.eqasim.examples.sao_paulo_drt.mode_choice.SaoPauloFeederOnlyModeAvailability; | |
import org.eqasim.examples.sao_paulo_drt.mode_choice.SaoPauloFeederEDrtModeAvailability; | |
import org.eqasim.examples.sao_paulo_drt.rejections.RejectionConstraint; | |
import org.eqasim.examples.sao_paulo_drt.rejections.RejectionModule; | |
import org.eqasim.sao_paulo.SaoPauloConfigurator; | |
import org.eqasim.sao_paulo.mode_choice.SaoPauloModeChoiceModule; | |
import org.matsim.api.core.v01.Scenario; | |
import org.matsim.api.core.v01.TransportMode; | |
import org.matsim.api.core.v01.population.Person; | |
import org.matsim.contrib.drt.analysis.zonal.DrtZonalSystemParams; | |
import org.matsim.contrib.drt.optimizer.insertion.DrtInsertionSearchParams; | |
import org.matsim.contrib.drt.optimizer.insertion.selective.SelectiveInsertionSearchParams; | |
import org.matsim.contrib.drt.optimizer.rebalancing.RebalancingParams; | |
import org.matsim.contrib.drt.optimizer.rebalancing.mincostflow.MinCostFlowRebalancingStrategyParams; | |
import org.matsim.contrib.drt.routing.DrtRoute; | |
import org.matsim.contrib.drt.routing.DrtRouteFactory; | |
import org.matsim.contrib.drt.run.DrtConfigGroup; | |
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.dvrp.run.DvrpConfigGroup; | |
import org.matsim.contrib.dvrp.run.DvrpQSimComponents; | |
import org.matsim.contrib.dvrp.run.MultiModal; | |
import org.matsim.contribs.discrete_mode_choice.model.DiscreteModeChoiceTrip; | |
import org.matsim.contribs.discrete_mode_choice.model.mode_availability.ModeAvailability; | |
import org.matsim.contribs.discrete_mode_choice.modules.config.DiscreteModeChoiceConfigGroup; | |
import org.matsim.core.config.CommandLine; | |
import org.matsim.core.config.CommandLine.ConfigurationException; | |
import org.matsim.core.config.Config; | |
import org.matsim.core.config.ConfigGroup; | |
import org.matsim.core.config.ConfigUtils; | |
import org.matsim.core.config.groups.ScoringConfigGroup.ModeParams; | |
import org.matsim.core.config.groups.ControllerConfigGroup; | |
import org.matsim.core.config.groups.QSimConfigGroup.StarttimeInterpretation; | |
import org.matsim.core.controler.Controler; | |
import org.matsim.core.scenario.ScenarioUtils; | |
import com.google.common.io.Resources; | |
import com.google.inject.Inject; | |
import com.google.inject.Provider; | |
/** | |
* This is an example run script that runs the scenario with an | |
* on-demand vehicle fleet using DRT. | |
* | |
*/ | |
public class RunSaoPauloFeederDrtSim { | |
static public void main(String[] args) throws ConfigurationException, IOException{ | |
if (args.length != 2) { | |
System.out.println("Require 2 arguments: Scenario number and Execution type: (feeder or feederdrt)"); | |
} | |
String feederConfig = "/mnt/config/sao_paulo_feeder_config"+args[0]+".xml"; | |
runSaoPauloSimulation(args, feederConfig, "/output", null, 50); | |
} | |
private static void runSaoPauloSimulation(String[] args, String configPath, String outputPath, String inputPlansFile, Integer lastIteration) throws ConfigurationException, IOException{ | |
CommandLine cmd = new CommandLine.Builder(args) // | |
.allowOptions("use-rejection-constraint") // | |
.allowPrefixes("mode-parameter", "cost-parameter") // | |
.build(); | |
SaoPauloConfigurator eqasimConfigurator = new SaoPauloConfigurator(); | |
Config config = ConfigUtils.loadConfig(configPath, eqasimConfigurator.getConfigGroups()); | |
((ControllerConfigGroup) config.getModules().get(ControllerConfigGroup.GROUP_NAME)).setOutputDirectory(outputPath); | |
if(inputPlansFile != null) { | |
config.plans().setInputFile(inputPlansFile); | |
} | |
if(lastIteration != null) { | |
config.controller().setLastIteration(lastIteration); | |
} | |
eqasimConfigurator.addOptionalConfigGroups(config); | |
cmd.applyConfiguration(config); | |
Scenario scenario = ScenarioUtils.createScenario(config); | |
eqasimConfigurator.configureScenario(scenario); | |
ScenarioUtils.loadScenario(scenario); | |
eqasimConfigurator.adjustScenario(scenario); | |
Controler controller = new Controler(scenario); | |
eqasimConfigurator.configureController(controller); | |
controller.addOverridingModule(new EqasimModeChoiceModule()); | |
controller.addOverridingModule(new EqasimAnalysisModule()); | |
controller.addOverridingModule(new SaoPauloModeChoiceModule(cmd)); | |
controller.addOverridingModule(new SaoPauloDrtModule(cmd)); | |
controller.addOverridingModule(new RejectionModule(Arrays.asList("drt"))); | |
controller.addOverridingModule(new DrtAnalysisModule()); | |
if (args[1].equals("feeder")){ | |
System.out.println("Entrou Feeder"); | |
controller.addOverridingModule(new AbstractEqasimExtension() { | |
@Override | |
protected void installEqasimExtension() { | |
bind(ModeParameters.class); | |
bindModeAvailability("SaoPauloFeederDRTModeAvailability").toProvider(new Provider<>() { | |
@Inject | |
private Config config; | |
@Override | |
public ModeAvailability get() { | |
FeederDrtModeAvailabilityWrapper feederDrtModeAvailabilityWrapper = new FeederDrtModeAvailabilityWrapper(config, new SaoPauloFeederOnlyModeAvailability()); | |
return new TransitWithAbstractAccessModeAvailabilityWrapper(config, feederDrtModeAvailabilityWrapper); | |
} | |
}).asEagerSingleton(); | |
} | |
}); | |
} | |
if (args[1].equals("feederdrt")){ | |
System.out.println("Entrou Feederdrt"); | |
controller.addOverridingModule(new AbstractEqasimExtension() { | |
@Override | |
protected void installEqasimExtension() { | |
bind(ModeParameters.class); | |
bindModeAvailability("SaoPauloFeederDRTModeAvailability").toProvider(new Provider<>() { | |
@Inject | |
private Config config; | |
@Override | |
public ModeAvailability get() { | |
FeederDrtModeAvailabilityWrapper feederDrtModeAvailabilityWrapper = new FeederDrtModeAvailabilityWrapper(config, new SaoPauloFeederEDrtModeAvailability()); | |
return new TransitWithAbstractAccessModeAvailabilityWrapper(config, feederDrtModeAvailabilityWrapper); | |
} | |
}).asEagerSingleton(); | |
} | |
}); | |
} | |
controller.run(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment