Class ConjugateDestinationBush
- java.lang.Object
-
- org.goplanit.assignment.ltm.sltm.RootedBush<ConjugateDirectedVertex,ConjugateEdgeSegment>
-
- org.goplanit.assignment.ltm.sltm.conjugate.ConjugateDestinationBush
-
- All Implemented Interfaces:
Comparable<IdAble>
,Bush
,IdAble
public class ConjugateDestinationBush extends RootedBush<ConjugateDirectedVertex,ConjugateEdgeSegment>
A conjugate rooted bush is an acyclic directed graph comprising of implicit paths along a conjugate network, i.e. turn based network (conjugate edge segments). It has a single root based on the original network, i.e. in the ocnjugate network it can represent multiple conjugate nodes since conjugate nodes are edges/edgeSegments on the original network leading to this vertex.The conjugate edge segments in the conjugate bush represent pairs of original link segments, i.e. turns in the physical network
- Author:
- markr
-
-
Field Summary
Fields Modifier and Type Field Description protected ConjugateBushTurnData
bushData
track bush specific dataprotected CentroidVertex
destination
destination of this conjugate bush-
Fields inherited from class org.goplanit.assignment.ltm.sltm.RootedBush
bushGroupingToken, originDemandsPcuH, requireTopologicalSortUpdate
-
-
Constructor Summary
Constructors Constructor Description ConjugateDestinationBush(ConjugateDestinationBush bush, boolean deepCopy)
Copy constructorConjugateDestinationBush(IdGroupingToken idToken, CentroidVertex destination, ConjugateConnectoidNode rootVertex, int maxSubGraphTurns)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description double
addTurnSendingFlow(ConjugateEdgeSegment turn, double addFlowPcuH)
Add turn sending flow to the conjugate bush.double
addTurnSendingFlow(ConjugateEdgeSegment turn, double addFlowPcuH, boolean allowTurnRemoval)
Add turn sending flow to the bush.MinMaxPathResult
computeMinMaxShortestPaths(double[] conjugatelinkSegmentCosts, int totalConjugateVertices)
Compute the min-max path tree rooted in location depending on underlying dag configuration of derived implementation and given the provided conjugate (network wide) costs.double
computeSubPathAcceptedFlow(DirectedVertex startVertex, DirectedVertex endVertex, EdgeSegment[] subPathArray, double[] linkSegmentAcceptanceFactors)
Determine the accepted flow between origin,destination vertex using the subpath given by the subPathArray in order from start to finish.double
computeSubPathSendingFlow(DirectedVertex startVertex, DirectedVertex endVertex, Map<DirectedVertex,EdgeSegment> subPathMap)
Determine the sending flow between origin,destination vertex using the subpath given by the subPathMap, where each vertex provides its exit segment.boolean
containsAnyTurnSegmentOf(ConjugateDirectedEdge conjugateEdge)
Verify if the bush contains any conjugate edge segment (turn) of the conjugate edge in either directionboolean
containsTurnSegment(ConjugateEdgeSegment turnSegment)
Verify if the bush contains the given turn segmentboolean
containsTurnSendingFlow(ConjugateEdgeSegment turn)
Verify if the provided turn has any registered sending flowConjugateDestinationBush
deepClone()
An id entity should always support a deep copy, i.e., all "owned" members will be deep copied when a clone of this instance is created via this call.ConjugateEdgeSegment
determineIntroduceCycle(ConjugateEdgeSegment[] alternative)
Verify if adding the sub-path conjugated edge segments (turns) would introduce a cycle in this bushTreeMap<BushFlowLabel,Double>
determineProportionalFlowCompositionRates(EdgeSegment edgeSegment, Set<BushFlowLabel> pasFlowCompositionLabels)
Find out the portion of the origin attributed flow on the segment that belongs to each available flow composition label proportional to the total flow across all provided labels on this same segmentdouble
determineSubPathSendingFlow(EdgeSegment entrySegment, EdgeSegment[] subPathArray)
Determine the sending flow between origin,destination vertex using the subpath given by the segment + subPathArray in order from start to finish.Pair<DirectedVertex,Map<DirectedVertex,EdgeSegment>>
findBushAlternativeSubpath(DirectedVertex referenceVertex, short[] alternativeSubpathVertexLabels)
The alternative subpath is provided through link segment labels of value -1.protected ConjugateACyclicSubGraph
getDag()
Access to the underlying dagCentroidVertex
getRootZoneVertex()
Each conjugate destination bush is expected to have a single destination zone to which all of its root vertices are connected, which is to be returned heredouble
getSendingFlowPcuH(ConjugateNode conjugateNode)
Collect the sending flow of a conjugate node (original edge segment) in the conjugate bush, if not present, zero flow is returnedShortestSearchType
getShortestSearchType()
determine the search type supported by the bush based on the underlying dag's construction, i.e., a destination-based dag results in All-To-One, whereas an origin based dag results in One-To-All searches.double
getSplittingRate(ConjugateEdgeSegment turn)
Collect the bush splitting rate on the given turndouble[]
getSplittingRates(ConjugateDirectedVertex conjugateVertex)
Collect the bush splitting rates for a given conjugate node (original incoming edge segment).Iterator<ConjugateDirectedVertex>
getTopologicalIterator(boolean originDestinationDirection)
Collect an iterator over topologically sorted bush in origin-destination or destination-origin direction.double
getTurnSendingFlow(ConjugateEdgeSegment turn)
Collect bush turn sending flow (if any)boolean
isEmpty()
Verify if emptyvoid
removeTurn(ConjugateEdgeSegment turn)
Remove a turn from the conjugate bushConjugateDestinationBush
shallowClone()
Create a shallow copy of this entityvoid
syncToNetworkFlows(double[] originalNetworkFlowAcceptanceFactors)
Conduct an update of the bush turn flows based on the network flow acceptance factors by conducting a bush DAG loading and updating the turn sending flows from the root, i.e., scale them back with the flow acceptance factor whenever one is encountered.-
Methods inherited from class org.goplanit.assignment.ltm.sltm.RootedBush
addOriginDemandPcuH, getDirectedVertexIterator, getId, getOriginDemandPcuH, getOriginVertices, getRootVertex, isInverted
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.goplanit.utils.id.IdAble
compareTo, idEquals, idHashCode
-
-
-
-
Field Detail
-
destination
protected final CentroidVertex destination
destination of this conjugate bush
-
bushData
protected final ConjugateBushTurnData bushData
track bush specific data
-
-
Constructor Detail
-
ConjugateDestinationBush
public ConjugateDestinationBush(IdGroupingToken idToken, CentroidVertex destination, ConjugateConnectoidNode rootVertex, int maxSubGraphTurns)
Constructor. It is expected that all provided root vertices represent edges in the orignal network leading to a single root.- Parameters:
idToken
- the token to base the id generation ondestination
- this conjugate destination bush has rooted conjugate vertices forrootVertex
- this conjugate node represents the root vertex as it is the dummy node from which all initial turns enter/exit the conjugate network from theconjugate destinationmaxSubGraphTurns
- The maximum number of conjugate edge segments, i.e. turns, the conjugate bush can at most register given the parent network it is a subset of
-
ConjugateDestinationBush
public ConjugateDestinationBush(ConjugateDestinationBush bush, boolean deepCopy)
Copy constructor- Parameters:
bush
- to copydeepCopy
- when true, create a eep copy, shallow copy otherwise
-
-
Method Detail
-
getDag
protected ConjugateACyclicSubGraph getDag()
Access to the underlying dag- Overrides:
getDag
in classRootedBush<ConjugateDirectedVertex,ConjugateEdgeSegment>
- Returns:
- dag of the bush
-
computeMinMaxShortestPaths
public MinMaxPathResult computeMinMaxShortestPaths(double[] conjugatelinkSegmentCosts, int totalConjugateVertices)
Compute the min-max path tree rooted in location depending on underlying dag configuration of derived implementation and given the provided conjugate (network wide) costs. The provided costs are at the conjugate network level so should contain all the conjugate segments active in the bush- Specified by:
computeMinMaxShortestPaths
in classRootedBush<ConjugateDirectedVertex,ConjugateEdgeSegment>
- Parameters:
conjugatelinkSegmentCosts
- to usetotalConjugateVertices
- needed to be able to create primitive array recording the (partial) subgraph backward conjugate link segment results (efficiently)- Returns:
- minMaxPathResult, null if unable to complete
-
getTopologicalIterator
public Iterator<ConjugateDirectedVertex> getTopologicalIterator(boolean originDestinationDirection)
Collect an iterator over topologically sorted bush in origin-destination or destination-origin direction. Depending on the derived bush implementation this might require inverting the iteration direction. Hence it is an abstract method here- Parameters:
originDestinationDirection
- when true, iterator runs topological order from origin towards destinatino, when false, they other way around- Returns:
- iterator over topologically ordered bush vertices
-
getShortestSearchType
public ShortestSearchType getShortestSearchType()
Description copied from interface:Bush
determine the search type supported by the bush based on the underlying dag's construction, i.e., a destination-based dag results in All-To-One, whereas an origin based dag results in One-To-All searches.- Returns:
- shortest search type compatible with this bush implementation
-
shallowClone
public ConjugateDestinationBush shallowClone()
Create a shallow copy of this entity- Specified by:
shallowClone
in interfaceBush
- Specified by:
shallowClone
in interfaceIdAble
- Specified by:
shallowClone
in classRootedBush<ConjugateDirectedVertex,ConjugateEdgeSegment>
- Returns:
- shallow copy of entity
-
deepClone
public ConjugateDestinationBush deepClone()
An id entity should always support a deep copy, i.e., all "owned" members will be deep copied when a clone of this instance is created via this call. To be used with caution if not called by managed id container related code- Specified by:
deepClone
in interfaceBush
- Specified by:
deepClone
in interfaceIdAble
- Specified by:
deepClone
in classRootedBush<ConjugateDirectedVertex,ConjugateEdgeSegment>
- Returns:
- deep copy of entity
-
determineIntroduceCycle
public ConjugateEdgeSegment determineIntroduceCycle(ConjugateEdgeSegment[] alternative)
Verify if adding the sub-path conjugated edge segments (turns) would introduce a cycle in this bush- Parameters:
alternative
- to verify- Returns:
- edge segment that would introduces a cycle, null otherwise
-
addTurnSendingFlow
public double addTurnSendingFlow(ConjugateEdgeSegment turn, double addFlowPcuH)
Add turn sending flow to the conjugate bush. In case the turn does not yet exist on the bush it is newly registered. If it does exist and there is already flow present, the provided flow is added to it. If by adding the flow (can be negative) the turn no longer has any flow, the turn itself is removed- Parameters:
turn
- the turnaddFlowPcuH
- to add- Returns:
- new labelled turn sending flow after adding given flow
-
addTurnSendingFlow
public double addTurnSendingFlow(ConjugateEdgeSegment turn, double addFlowPcuH, boolean allowTurnRemoval)
Add turn sending flow to the bush. In case the turn does not yet exist on the bush it is newly registered. If it does exist and there is already flow present, the provided flow is added to it. If by adding the flow (can be negative) the turn no longer has any flow, it is rmeoved if allowed- Parameters:
turn
- the turnaddFlowPcuH
- to addallowTurnRemoval
- when true we remove turn when no flow remains after adding (negative) flow, when false, we only change the flow to zero but the bush is not adjusted- Returns:
- new turn sending flow after adding given flow
-
getTurnSendingFlow
public double getTurnSendingFlow(ConjugateEdgeSegment turn)
Collect bush turn sending flow (if any)- Parameters:
turn
- to use- Returns:
- sending flow, zero if unknown
-
getSendingFlowPcuH
public double getSendingFlowPcuH(ConjugateNode conjugateNode)
Collect the sending flow of a conjugate node (original edge segment) in the conjugate bush, if not present, zero flow is returned- Parameters:
conjugateNode
- to collect sending flow for- Returns:
- bush sending flow
-
containsTurnSendingFlow
public boolean containsTurnSendingFlow(ConjugateEdgeSegment turn)
Verify if the provided turn has any registered sending flow- Parameters:
turn
- to use- Returns:
- true when turn sending flow is present, false otherwise
-
getSplittingRate
public double getSplittingRate(ConjugateEdgeSegment turn)
Collect the bush splitting rate on the given turn- Parameters:
turn
- to use- Returns:
- found splitting rate, in case the turn is not used, 0 is returned
-
getSplittingRates
public double[] getSplittingRates(ConjugateDirectedVertex conjugateVertex)
Collect the bush splitting rates for a given conjugate node (original incoming edge segment). If no flow, zero splitting rates are returned- Parameters:
conjugateVertex
- to use- Returns:
- splitting rates in primitive array in order of which one iterates over the outgoing (conjugate) edge segments
-
removeTurn
public void removeTurn(ConjugateEdgeSegment turn)
Remove a turn from the conjugate bush- Parameters:
turn
- of the turn
-
containsTurnSegment
public boolean containsTurnSegment(ConjugateEdgeSegment turnSegment)
Verify if the bush contains the given turn segment- Parameters:
turnSegment
- to verify- Returns:
- true when present, false otherwise
-
containsAnyTurnSegmentOf
public boolean containsAnyTurnSegmentOf(ConjugateDirectedEdge conjugateEdge)
Verify if the bush contains any conjugate edge segment (turn) of the conjugate edge in either direction- Parameters:
conjugateEdge
- to verify- Returns:
- true when present, false otherwise
-
findBushAlternativeSubpath
public Pair<DirectedVertex,Map<DirectedVertex,EdgeSegment>> findBushAlternativeSubpath(DirectedVertex referenceVertex, short[] alternativeSubpathVertexLabels)
The alternative subpath is provided through link segment labels of value -1. The point at which they coincide with the bush is indicated with label 1 at the given reference vertex (passed in). Here we do a breadth-first search on the bush in the direction towards its root to find a location the alternative path reconnects to the bush, which, at the latest, should be at the root and at the earliest directly at the next vertex compared to the reference vertex.Note that the breadth-first approach is a choice not a necessity but the underlying idea is that a shorter PAS (which is likely to be found) is used by more origins and therefore more useful to explore than a really long PAS. This is preferred - in the original TAPAS - over simply backtracking along either the shortest or longest path of the min-max tree which would also be viable options,a s would a depth-first search.
Consider implementing various strategies here in order to explore what works best but for now we adopt a breadth-first search
The returned map contains the next edge segment for each vertex, from the vertex closer to the bush root to the reference vertex where for the reference vertex the edge segment remains null
- Parameters:
referenceVertex
- to start breadth first search from as it is the point of coincidence of the alternative path (via labelled vertices) and bushalternativeSubpathVertexLabels
- indicating the shortest (network) path at the reference vertex but not part of the bush at that point (different edge segment used)- Returns:
- vertex at which the two paths coincided again and the map to extract the path from the this vertex to the reference vertex that was found using the breadth-first method
-
computeSubPathSendingFlow
public double computeSubPathSendingFlow(DirectedVertex startVertex, DirectedVertex endVertex, Map<DirectedVertex,EdgeSegment> subPathMap)
Determine the sending flow between origin,destination vertex using the subpath given by the subPathMap, where each vertex provides its exit segment. This is used to traverse the subpath and extract the portion of the sending flow currently known at the bushes startVertex provided to the end vertex- Parameters:
startVertex
- to useendVertex
- to usesubPathMap
- to extract path from- Returns:
- sendingFlowPcuH between start and end vertex following the found sub-path
-
computeSubPathAcceptedFlow
public double computeSubPathAcceptedFlow(DirectedVertex startVertex, DirectedVertex endVertex, EdgeSegment[] subPathArray, double[] linkSegmentAcceptanceFactors)
Determine the accepted flow between origin,destination vertex using the subpath given by the subPathArray in order from start to finish. We utilise the initial sending flow on the first segment as the base flow which is then reduced by the splitting rates and acceptance factor up to and including the final link segment- Parameters:
startVertex
- to useendVertex
- to usesubPathArray
- to extract path fromlinkSegmentAcceptanceFactors
- the acceptance factor to apply along the path, indexed by link segment id- Returns:
- acceptedFlowPcuH between start and end vertex following the sub-path
-
determineSubPathSendingFlow
public double determineSubPathSendingFlow(EdgeSegment entrySegment, EdgeSegment[] subPathArray)
Determine the sending flow between origin,destination vertex using the subpath given by the segment + subPathArray in order from start to finish. We utilise the initial sending flow on the entry segment as the base flow which is then followed along the subpath through the bush splitting rates up to the final link segment- Parameters:
entrySegment
- to start subpath fromsubPathArray
- to append to entry segment to extract path from- Returns:
- sendingFlowPcuH between start and end vertex following the sub-path
-
determineProportionalFlowCompositionRates
public TreeMap<BushFlowLabel,Double> determineProportionalFlowCompositionRates(EdgeSegment edgeSegment, Set<BushFlowLabel> pasFlowCompositionLabels)
Find out the portion of the origin attributed flow on the segment that belongs to each available flow composition label proportional to the total flow across all provided labels on this same segment- Parameters:
edgeSegment
- to determine the label rates forpasFlowCompositionLabels
- to determine relative proportions for based on total flow across provided labels on the link segment- Returns:
- the rates at hand for each found composition label
-
syncToNetworkFlows
public void syncToNetworkFlows(double[] originalNetworkFlowAcceptanceFactors)
Conduct an update of the bush turn flows based on the network flow acceptance factors by conducting a bush DAG loading and updating the turn sending flows from the root, i.e., scale them back with the flow acceptance factor whenever one is encountered.- Specified by:
syncToNetworkFlows
in classRootedBush<ConjugateDirectedVertex,ConjugateEdgeSegment>
- Parameters:
originalNetworkFlowAcceptanceFactors
- to use
-
isEmpty
public boolean isEmpty()
Verify if empty- Returns:
- true when empty, false otherwise
-
getRootZoneVertex
public CentroidVertex getRootZoneVertex()
Each conjugate destination bush is expected to have a single destination zone to which all of its root vertices are connected, which is to be returned here- Specified by:
getRootZoneVertex
in classRootedBush<ConjugateDirectedVertex,ConjugateEdgeSegment>
- Returns:
- destination zone
-
-