Class LinearFundamentalDiagramBranch
- java.lang.Object
-
- org.goplanit.supply.fundamentaldiagram.LinearFundamentalDiagramBranch
-
- All Implemented Interfaces:
Cloneable
,FundamentalDiagramBranch
public class LinearFundamentalDiagramBranch extends Object implements FundamentalDiagramBranch
A linear fundamental diagram branch implementation- Author:
- markr
-
-
Constructor Summary
Constructors Constructor Description LinearFundamentalDiagramBranch(double characteristicWaveSpeedKmHour, double densityAtZeroFlowPcuKm)
ConstructorLinearFundamentalDiagramBranch(LinearFundamentalDiagramBranch linearFundamentalDiagramBranch)
Copy constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description LinearFundamentalDiagramBranch
clone()
Clone a branchdouble
getCharateristicWaveSpeedKmHour()
The characteristic wave speed of the linear branch in km/hourdouble
getDensityPcuKm(double flowPcuHour)
The flow at a given densitydouble
getFlowPcuHour(double densityPcuKm)
The flow at a given densitydouble
getFlowTangent(double flowPcuHour)
The derivative of flow towards a change in density given a particualr flowdouble
getSpeedKmHourAtZeroDensity()
speed at zero density is the same as the characteristic wave speeddouble
getSpeedKmHourAtZeroFlow()
speed at zero flow is the same as the characteristic wave speedboolean
isLinear()
Verify if the branch is linear or notint
relaxedHashCode(int scale)
A fundamental diagram branch is based on a limited number of double variables to define it.protected void
setCharacteristicWaveSpeedKmHour(double characteristicWaveSpeedKmHour)
Set the characteristic wave speed in km/hprotected void
setDensityAtZeroFlow(double densityAtZeroFlowPcuKm)
Set the density at zero flow in Pcu/km-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.goplanit.supply.fundamentaldiagram.FundamentalDiagramBranch
getDensityTangent, getSpeedKmHourByDensity, getSpeedKmHourByFlow
-
-
-
-
Constructor Detail
-
LinearFundamentalDiagramBranch
public LinearFundamentalDiagramBranch(double characteristicWaveSpeedKmHour, double densityAtZeroFlowPcuKm)
Constructor- Parameters:
characteristicWaveSpeedKmHour
- to use (either free flow speed to use or backward wave speed)densityAtZeroFlowPcuKm
- to use
-
LinearFundamentalDiagramBranch
public LinearFundamentalDiagramBranch(LinearFundamentalDiagramBranch linearFundamentalDiagramBranch)
Copy constructor- Parameters:
linearFundamentalDiagramBranch
- to copy
-
-
Method Detail
-
setCharacteristicWaveSpeedKmHour
protected void setCharacteristicWaveSpeedKmHour(double characteristicWaveSpeedKmHour)
Set the characteristic wave speed in km/h- Parameters:
characteristicWaveSpeedKmHour
- to set
-
setDensityAtZeroFlow
protected void setDensityAtZeroFlow(double densityAtZeroFlowPcuKm)
Set the density at zero flow in Pcu/km- Parameters:
densityAtZeroFlowPcuKm
- to set
-
getFlowPcuHour
public double getFlowPcuHour(double densityPcuKm)
The flow at a given density- Specified by:
getFlowPcuHour
in interfaceFundamentalDiagramBranch
- Parameters:
densityPcuKm
- to use- Returns:
- flowPcuHour found
-
getDensityPcuKm
public double getDensityPcuKm(double flowPcuHour)
The flow at a given density- Specified by:
getDensityPcuKm
in interfaceFundamentalDiagramBranch
- Parameters:
flowPcuHour
- to use- Returns:
- densityPcuKm found
-
getFlowTangent
public double getFlowTangent(double flowPcuHour)
The derivative of flow towards a change in density given a particualr flow- Specified by:
getFlowTangent
in interfaceFundamentalDiagramBranch
- Parameters:
flowPcuHour
- to use- Returns:
- tangent of flow
-
getCharateristicWaveSpeedKmHour
public double getCharateristicWaveSpeedKmHour()
The characteristic wave speed of the linear branch in km/hour- Returns:
- wave speed
-
relaxedHashCode
public int relaxedHashCode(int scale)
A fundamental diagram branch is based on a limited number of double variables to define it. In case we want to reuse the same branch for extremely similar variables, then we can use this relaxed hash code that ensures that for the given precision level identical hashes are created even if the underlying floating point variables differ beyond this precision.- Specified by:
relaxedHashCode
in interfaceFundamentalDiagramBranch
- Parameters:
scale
- indicating how many decimals to consider, e.g., 2 considers 2 decimals for precision- Returns:
- the created relaxed hash code
-
clone
public LinearFundamentalDiagramBranch clone()
Clone a branch- Specified by:
clone
in interfaceFundamentalDiagramBranch
- Overrides:
clone
in classObject
- Returns:
- cloned branch
-
getSpeedKmHourAtZeroFlow
public double getSpeedKmHourAtZeroFlow()
speed at zero flow is the same as the characteristic wave speed- Specified by:
getSpeedKmHourAtZeroFlow
in interfaceFundamentalDiagramBranch
- Returns:
- speedKmHour
-
getSpeedKmHourAtZeroDensity
public double getSpeedKmHourAtZeroDensity()
speed at zero density is the same as the characteristic wave speed- Specified by:
getSpeedKmHourAtZeroDensity
in interfaceFundamentalDiagramBranch
- Returns:
- speedKmHour found
-
isLinear
public boolean isLinear()
Verify if the branch is linear or not- Specified by:
isLinear
in interfaceFundamentalDiagramBranch
- Returns:
- true when linear, false otherwise
-
-