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

edu.kit.ifv.mobitopp.simulation.publictransport.profilescan.TransferTimeFunction 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).

There is a newer version: 0.3.580
Show newest version
package edu.kit.ifv.mobitopp.simulation.publictransport.profilescan;

import static edu.kit.ifv.mobitopp.time.Time.future;
import static java.util.Optional.empty;
import static java.util.Optional.of;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Optional;

import edu.kit.ifv.mobitopp.time.Time;

public class TransferTimeFunction {

	private final List entries;

	public TransferTimeFunction() {
		super();
		entries = new ArrayList<>();
		entries.add(new TransferEntry(future, future));
	}

	public void update(TransferEntry entry) {
		LinkedList before = new LinkedList<>();
		TransferEntry earlyEntry = entries.get(0);
		while (earlyEntry.departure().isBefore(entry.departure())) {
			if (earlyEntry.arrival().isBefore(entry.arrival())) {
				before.push(earlyEntry);
			}
			entries.remove(0);
			earlyEntry = entries.get(0);
		}
		if (entry.arrival().isBefore(earlyEntry.arrival())) {
			if (entry.departure().equals(earlyEntry.departure())) {
				entries.set(0, entry);
			} else {
				entries.add(0, entry);
			}
		}
		for (TransferEntry old : before) {
			entries.add(0, old);
		}
	}

	public Optional




© 2015 - 2024 Weber Informatics LLC | Privacy Policy