MATSim笔记01-controler结构梳理

MATSim学习笔记

1、controler源码学习

org.matsim.core.controler.NewControler
control.run(){
	super.run(this.config);
}
AbstractController.run(final Config config){
	prepareForSim();
}
NewControler 重写了父类的prepareForSim(){
	this.prepareForSim.run();
}
实现类:PrepareForSimImpl.run(){
	XY2LinksForFacilities.run(carOnlyNetwork, this.activityFacilities);
	createAndAddVehiclesForEveryNetworkMode();
	adaptOutdatedPlansForRoutingMode();
	ParallelPersonAlgorithmUtils.run(population, globalConfigGroup.getNumberOfThreads(),
				() -> new PersonPrepareForSim(new PlanRouter(tripRouterProvider.get(), activityFacilities, timeInterpretation), scenario,
						carOnlyNetwork)
}
核心接口:org.matsim.core.population.algorithms.ParallelPersonAlgorithmUtils.run(final Population population, final int numberOfThreads, final PersonAlgorithmProvider algoProvider){
	1、设置多线程,每个线程包含处理PersonAlgorithm算法、计数器、人口
	2、把所有人口均衡分配到每个线程中
	for (Person person : population.getPersons().values()) {
			algoThreads[i % numOfThreads].handlePerson(person);
			i++;
	}
}
线程启动PersonAlgoThread.run(){
	1、对线程中的每个人用PersonAlgorithm算法进行处理(实现类:PersonPrepareForSim)
	2、计数器更新
}
下面是对PersonPrepareForSim的学习

你可能感兴趣的:(工作经验,MATSim)