edu.kit.ifv.mobitopp.simulation.tour.RandomModeChangeWithinTour Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mobitopp Show documentation
Show all versions of mobitopp Show documentation
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);
}
}