All Downloads are FREE. Search and download functionalities are using the official Maven repository.

edu.kit.ifv.mobitopp.simulation.tour.RandomModeChangeWithinTour Maven / Gradle / Ivy

Go to download

mobiTopp (http://mobitopp.ifv.kit.edu/) is an agent-based travel demand model developed at the Institute for transport studies at the Karlsruhe Institute of Technology (http://www.ifv.kit.edu/english/index.php). Publications about mobiTopp can be found on the project site (http://mobitopp.ifv.kit.edu/28.php).

The newest version!
package edu.kit.ifv.mobitopp.simulation.tour;

import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;

import edu.kit.ifv.mobitopp.data.Zone;
import edu.kit.ifv.mobitopp.simulation.Mode;
import edu.kit.ifv.mobitopp.simulation.Person;
import edu.kit.ifv.mobitopp.simulation.activityschedule.ActivityIfc;
import edu.kit.ifv.mobitopp.util.randomvariable.DiscreteRandomVariable;

public class RandomModeChangeWithinTour implements WithinTourModeChoiceModel {

	@Override
	public Mode selectMode(
		Tour tour, 
		Mode tourMode, 
		Person person, 
		Zone source, 
		Zone destination,
		ActivityIfc previousActivity, 
		ActivityIfc nextActivity, 
		Set choiceSet, 
		double randomNumber
	) {
		
		assert choiceSet.size() > 0;
		
		Map distribution = new LinkedHashMap();
		
		float probability = 1.0f / choiceSet.size();
		
		for (Mode mode : choiceSet) {
			distribution.put(mode, probability);
		}
		
		return new DiscreteRandomVariable(distribution).realization(randomNumber);
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy