![JAR search and dependency download from the Maven repository](/logo.png)
org.opentrafficsim.kpi.sampling.indicator.MeanDensity Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ots-kpi Show documentation
Show all versions of ots-kpi Show documentation
OpenTrafficSim KPI Module without dependencies to ots-road or ots-core
package org.opentrafficsim.kpi.sampling.indicator;
import java.util.List;
import org.djunits.unit.LinearDensityUnit;
import org.djunits.value.vdouble.scalar.LinearDensity;
import org.djunits.value.vdouble.scalar.Time;
import org.opentrafficsim.kpi.interfaces.GtuData;
import org.opentrafficsim.kpi.sampling.Query;
import org.opentrafficsim.kpi.sampling.TrajectoryGroup;
/**
* Total travel time divided by the sum of areas (X * T).
*
* Copyright (c) 2013-2023 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
* BSD-style license. See OpenTrafficSim License.
*
* @author Alexander Verbraeck
* @author Peter Knoppers
* @author Wouter Schakel
*/
public class MeanDensity extends AbstractIndicator
{
/** Travel time indicator. */
private final TotalTravelTime travelTime;
/**
* @param travelTime TotalTravelTime; travel time indicator
*/
public MeanDensity(final TotalTravelTime travelTime)
{
this.travelTime = travelTime;
}
/** {@inheritDoc} */
@Override
// @docs/07-output/indicators.md
protected LinearDensity calculate(final Query query, final Time startTime,
final Time endTime, final List> trajectoryGroups)
{
double ttt = this.travelTime.getValue(query, startTime, endTime, trajectoryGroups).si;
double area = 0;
for (TrajectoryGroup> trajectoryGroup : trajectoryGroups)
{
area += trajectoryGroup.getLength().si * (endTime.si - startTime.si);
}
return new LinearDensity(ttt / area, LinearDensityUnit.SI);
}
/** {@inheritDoc} */
@Override
public final String toString()
{
return "MeanDensity [travelTime=" + this.travelTime + "]";
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy