Package org.goplanit.assignment.ltm.sltm
Class BushTurnData
- java.lang.Object
-
- org.goplanit.assignment.ltm.sltm.BushTurnData
-
public class BushTurnData extends Object
Track turn based data of a bush.For now we only track turn sending flows to minimise bookkeeping and memory usage, splitting rates are deduced from the turn sending flows when needed.
- Author:
- markr
-
-
Constructor Summary
Constructors Constructor Description BushTurnData(BushTurnData bushTurnData)
copy constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description double
addTurnSendingFlow(EdgeSegment from, EdgeSegment to, double flowPcuH)
Add turn sending flow for a given turn (can be negative), turn will not be removed if no flow remainsdouble
addTurnSendingFlow(EdgeSegment from, EdgeSegment to, double flowPcuH, boolean allowTurnRemoval)
Add turn sending flow for a given turn (can be negative), flow can be removed if desired depending on flags set if desiredboolean
containsTurnSendingFlow(EdgeSegment fromSegment, EdgeSegment toSegment)
Verify if the turn sending flow for a given turn is positivedouble
getSplittingRate(EdgeSegment fromSegment, EdgeSegment toSegment)
Collect the splitting rate for a given link segment.double[]
getSplittingRates(EdgeSegment fromSegment)
Collect the splitting rates for a given link segment and composition.double
getTotalAcceptedFlowToPcuH(EdgeSegment edgeSegment, double[] flowAcceptanceFactors)
Collect the accepted flow towards an edge segment in the bush with the specified label, if not present, zero flow is returneddouble
getTotalSendingFlowFromPcuH(EdgeSegment edgeSegment)
Total sending flows s_a from given segmentdouble
getTurnSendingFlowPcuH(EdgeSegment fromSegment, EdgeSegment toSegment)
Get the turn sending flow for a given turnboolean
hasTurnFlows()
Verify if any turn flows have been registeredvoid
removeTurn(EdgeSegment fromEdgeSegment, EdgeSegment toEdgeSegment)
Remove the turn entirelyboolean
setTurnSendingFlow(EdgeSegment fromSegment, EdgeSegment toSegment, double turnSendingFlow, boolean allowTurnRemoval)
Update the turn sending flow for a given turn
-
-
-
Constructor Detail
-
BushTurnData
public BushTurnData(BushTurnData bushTurnData)
copy constructor.- Parameters:
bushTurnData
- to copy
-
-
Method Detail
-
setTurnSendingFlow
public boolean setTurnSendingFlow(EdgeSegment fromSegment, EdgeSegment toSegment, double turnSendingFlow, boolean allowTurnRemoval)
Update the turn sending flow for a given turn- Parameters:
fromSegment
- of turntoSegment
- of turnturnSendingFlow
- to updateallowTurnRemoval
- when true we allow for removal of turn/edge segment when no flow remains, when false we keep regardless of the remaining flow- Returns:
- true when turn has any turn sending flow left after setting flow, false when turn sending flow no longer exists
-
addTurnSendingFlow
public double addTurnSendingFlow(EdgeSegment from, EdgeSegment to, double flowPcuH)
Add turn sending flow for a given turn (can be negative), turn will not be removed if no flow remains- Parameters:
from
- of turnto
- of turnflowPcuH
- to add- Returns:
- the new turn sending flow after adding the given flow
-
addTurnSendingFlow
public double addTurnSendingFlow(EdgeSegment from, EdgeSegment to, double flowPcuH, boolean allowTurnRemoval)
Add turn sending flow for a given turn (can be negative), flow can be removed if desired depending on flags set if desired- Parameters:
from
- of turnto
- of turnflowPcuH
- to addallowTurnRemoval
- when true we allow for removal of turn/edge segment when no flow remains, when false we keep regardless of the remaining flow- Returns:
- the new labelled turn sending flow after adding the given flow
-
removeTurn
public void removeTurn(EdgeSegment fromEdgeSegment, EdgeSegment toEdgeSegment)
Remove the turn entirely- Parameters:
fromEdgeSegment
- of turntoEdgeSegment
- of turn
-
getTurnSendingFlowPcuH
public double getTurnSendingFlowPcuH(EdgeSegment fromSegment, EdgeSegment toSegment)
Get the turn sending flow for a given turn- Parameters:
fromSegment
- of turntoSegment
- of turn- Returns:
- turn sending flow, 0 if not present
-
getTotalSendingFlowFromPcuH
public double getTotalSendingFlowFromPcuH(EdgeSegment edgeSegment)
Total sending flows s_a from given segment- Parameters:
edgeSegment
- to use- Returns:
- sending flow s_a
-
getTotalAcceptedFlowToPcuH
public double getTotalAcceptedFlowToPcuH(EdgeSegment edgeSegment, double[] flowAcceptanceFactors)
Collect the accepted flow towards an edge segment in the bush with the specified label, if not present, zero flow is returned- Parameters:
edgeSegment
- to collect sending flow towards toflowAcceptanceFactors
- to convert sending flow to accepted flow- Returns:
- bush sending flow found
-
containsTurnSendingFlow
public boolean containsTurnSendingFlow(EdgeSegment fromSegment, EdgeSegment toSegment)
Verify if the turn sending flow for a given turn is positive- Parameters:
fromSegment
- of turntoSegment
- of turn- Returns:
- true when present, false otherwise
-
getSplittingRates
public double[] getSplittingRates(EdgeSegment fromSegment)
Collect the splitting rates for a given link segment and composition. Splitting rates are based on the current (labelled) turn sending flows s_ab. In case no flows are present for the given composition label, zero splitting rates for all turns are returned.- Parameters:
fromSegment
- to collect bush splitting rates for- Returns:
- splitting rates in primitive array in order of which one iterates over the outgoing edge segments of the downstream from segment vertex
-
getSplittingRate
public double getSplittingRate(EdgeSegment fromSegment, EdgeSegment toSegment)
Collect the splitting rate for a given link segment. Splitting rates are based on the current turn sending flows s_ab.When collecting multiple splitting rates with the same in link, do not use this method but instead collect all splitting rates at once and then filter the ones you require it is computationally more efficient.
- Parameters:
fromSegment
- of turn to collect splitting rate fortoSegment
- of turn to collect splitting rate for- Returns:
- splitting rate, when turn is not present or not used, zero is returned
-
hasTurnFlows
public boolean hasTurnFlows()
Verify if any turn flows have been registered- Returns:
- true if so, false otherwise
-
-