Package org.goplanit.assignment.ltm.sltm
Class StaticLtmBushStrategyBase<B extends RootedBush<?,?>>
- java.lang.Object
-
- org.goplanit.assignment.ltm.sltm.StaticLtmAssignmentStrategy
-
- org.goplanit.assignment.ltm.sltm.StaticLtmBushStrategyBase<B>
-
- Direct Known Subclasses:
StaticLtmBushStrategyRootLabelled
,StaticLtmStrategyConjugateBush
public abstract class StaticLtmBushStrategyBase<B extends RootedBush<?,?>> extends StaticLtmAssignmentStrategy
Base implementation to support a bush based solution for sLTM- Author:
- markr
-
-
Field Summary
Fields Modifier and Type Field Description protected B[]
bushes
tracked bushes (with non-zero demand)protected Set<Pas>
equalFlowDistributedPass
track all PASs where we are attempting to distribute flow equally to obtain unique solution under unequal flow but equal cost/cost-derivativeprotected PasManager
pasManager
track all unique PASs
-
Constructor Summary
Constructors Modifier Constructor Description protected
StaticLtmBushStrategyBase(IdGroupingToken idGroupingToken, long assignmentId, TransportModelNetwork transportModelNetwork, StaticLtmSettings settings, TrafficAssignmentComponentAccessee taComponents)
Constructor
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract B[]
createEmptyBushes()
Let derived implementations create the empty bushes as desired before populating themvoid
createInitialSolution(double[] initialLinkSegmentCosts)
Create initial bushes, where for each origin the bush is initialised with the shortest path onlyprotected abstract StaticLtmLoadingBushBase<B>
createNetworkLoading()
Create bush based network loading implementationprotected ShortestBushGeneralised
createNetworkShortestBushAlgo(double[] linkSegmentCosts)
Create a network wide shortest bush algorithm based on provided costsprotected ShortestPathDijkstra
createNetworkShortestPathAlgo(double[] linkSegmentCosts)
Create a network wide Dijkstra shortest path algorithm based on provided costsprotected abstract PasFlowShiftExecutor
createPasFlowShiftExecutor(Pas pas, StaticLtmSettings settings)
protected StaticLtmLoadingBushBase<B>
getLoading()
The network loading to applyboolean
hasConverged(GapFunction gapFunction, int iterationIndex)
Unlike the default convergence check, we also see if the solution is proportional if relevant; in a bush setting with a triangular fundamental diagram we do not obtain a unique solution if a PAS has equal cost with an equal derivative but unequal flow distribution along its two segments, e.g.protected abstract void
initialiseBush(B bush, Zoning zoning, OdDemands odDemands, ShortestBushGeneralised shortestBushAlgorithm)
Initialise the sLTM bush by including the relevant DAGs based on available demand and bush layout.protected void
initialiseBushes(double[] linkSegmentCosts)
Initialise bushes.protected boolean
isSolutionFlowEntropyMaximised(double gapEpsilon)
Verify if solution is flow proportionalboolean
performIteration(Mode theMode, double[] costsToUpdate, int iterationIndex)
Perform an iteration by: 1.protected void
syncBushFlowsToNetworkFlows()
Based on the network loading results, update the bush' turn sending flowsprotected abstract Collection<Pas>
updateBushPass(double[] linkSegmentCosts)
Update the PASs for bushes given the network costs and current bushes DAGsprotected void
updateGap(LinkBasedRelativeDualityGapFunction gapFunction, Pas pas, double s1SendingFlow, double s2SendingFlow)
Update gap.-
Methods inherited from class org.goplanit.assignment.ltm.sltm.StaticLtmAssignmentStrategy
executeNetworkCostsUpdate, executeNetworkLoading, findCentroidVertex, getAssignmentId, getDescription, getIdGroupingToken, getInfrastructureNetwork, getOdDemands, getSettings, getTrafficAssignmentComponent, getTransportNetwork, setOdDemands, updateTimePeriod, verifyNetworkLoadingConvergenceProgress
-
-
-
-
Field Detail
-
bushes
protected B extends RootedBush<?,?>[] bushes
tracked bushes (with non-zero demand)
-
pasManager
protected final PasManager pasManager
track all unique PASs
-
-
Constructor Detail
-
StaticLtmBushStrategyBase
protected StaticLtmBushStrategyBase(IdGroupingToken idGroupingToken, long assignmentId, TransportModelNetwork transportModelNetwork, StaticLtmSettings settings, TrafficAssignmentComponentAccessee taComponents)
Constructor- Parameters:
idGroupingToken
- to use for internal managed idsassignmentId
- of parent assignmenttransportModelNetwork
- to usesettings
- to usetaComponents
- to use for access to user configured assignment components
-
-
Method Detail
-
updateGap
protected void updateGap(LinkBasedRelativeDualityGapFunction gapFunction, Pas pas, double s1SendingFlow, double s2SendingFlow)
Update gap. Unconventional gap function where we update the GAP based on PAS cost discrepancy. This is due to the impossibility of efficiently determining the network and minimum path costs in a capacity constrained bush based setting. Instead we:minimumCost PAS : s1 cost * SUM(s1 sending flow, s2 sending flow) measuredCost PAS: s1 sending flow * s1 cost + s2 sending flow * s2 cost
Sum the above over all PASs. Note that PASs can (partially) overlap, so the measured cost does likely not add up to the network cost
- Parameters:
gapFunction
- to usepas
- to compute fors1SendingFlow
- of the PAS s1 segments2SendingFlow
- of the PAS s2 segment
-
syncBushFlowsToNetworkFlows
protected void syncBushFlowsToNetworkFlows()
Based on the network loading results, update the bush' turn sending flows
-
updateBushPass
protected abstract Collection<Pas> updateBushPass(double[] linkSegmentCosts) throws PlanItException
Update the PASs for bushes given the network costs and current bushes DAGs- Parameters:
linkSegmentCosts
- to use- Returns:
- newly created PASs
- Throws:
PlanItException
- thrown if error
-
isSolutionFlowEntropyMaximised
protected boolean isSolutionFlowEntropyMaximised(double gapEpsilon)
Verify if solution is flow proportional- Parameters:
gapEpsilon
- to use- Returns:
- true when flow proportional, false otherwise
-
createEmptyBushes
protected abstract B[] createEmptyBushes()
Let derived implementations create the empty bushes as desired before populating them- Returns:
- created empty bushes suitable for this strategy
-
initialiseBush
protected abstract void initialiseBush(B bush, Zoning zoning, OdDemands odDemands, ShortestBushGeneralised shortestBushAlgorithm)
Initialise the sLTM bush by including the relevant DAGs based on available demand and bush layout. When equal costs are found between alternative paths OD demand is to be split proportionallyAdd the edge segments to the bush and update the turn sending flow accordingly.
- Parameters:
bush
- to usezoning
- to useodDemands
- to useshortestBushAlgorithm
- to use
-
createPasFlowShiftExecutor
protected abstract PasFlowShiftExecutor createPasFlowShiftExecutor(Pas pas, StaticLtmSettings settings)
- Parameters:
pas
- to create flow shift executor forsettings
- to use- Returns:
- created executor
-
initialiseBushes
protected void initialiseBushes(double[] linkSegmentCosts) throws PlanItException
Initialise bushes. Find shortest bush for each origin and add the links, flow, and destination labelling to the bush- Parameters:
linkSegmentCosts
- costs to use- Throws:
PlanItException
- thrown when error
-
createNetworkShortestBushAlgo
protected ShortestBushGeneralised createNetworkShortestBushAlgo(double[] linkSegmentCosts)
Create a network wide shortest bush algorithm based on provided costs- Parameters:
linkSegmentCosts
- to use- Returns:
- one-to-all shortest bush algorithm
-
createNetworkShortestPathAlgo
protected ShortestPathDijkstra createNetworkShortestPathAlgo(double[] linkSegmentCosts)
Create a network wide Dijkstra shortest path algorithm based on provided costs- Parameters:
linkSegmentCosts
- to use- Returns:
- Dijkstra shortest path algorithm
-
createNetworkLoading
protected abstract StaticLtmLoadingBushBase<B> createNetworkLoading()
Create bush based network loading implementation- Specified by:
createNetworkLoading
in classStaticLtmAssignmentStrategy
- Returns:
- created loading implementation supporting bush-based approach
-
getLoading
protected StaticLtmLoadingBushBase<B> getLoading()
The network loading to apply- Overrides:
getLoading
in classStaticLtmAssignmentStrategy
- Returns:
- network loading
-
createInitialSolution
public void createInitialSolution(double[] initialLinkSegmentCosts)
Create initial bushes, where for each origin the bush is initialised with the shortest path only- Specified by:
createInitialSolution
in classStaticLtmAssignmentStrategy
- Parameters:
initialLinkSegmentCosts
- costs to use
-
performIteration
public boolean performIteration(Mode theMode, double[] costsToUpdate, int iterationIndex)
Perform an iteration by: 1. Identify new PASs and shift flow from affected bushes 2. Conduct another loading update based on adjusted PASs and bushes 3. Update Bushes by shifting flow between existing PASs 4. Conducting a loading to obtain network costs- Specified by:
performIteration
in classStaticLtmAssignmentStrategy
- Parameters:
theMode
- to usecostsToUpdate
- to place updated costs in (output)iterationIndex
- we're at- Returns:
- true when iteration could be successfully completed, false otherwise
-
hasConverged
public boolean hasConverged(GapFunction gapFunction, int iterationIndex)
Unlike the default convergence check, we also see if the solution is proportional if relevant; in a bush setting with a triangular fundamental diagram we do not obtain a unique solution if a PAS has equal cost with an equal derivative but unequal flow distribution along its two segments, e.g. in free flow conditions we expect equal flow along both alternatives if equal cost. When the settings indicate so, we verify if the solution is proportional or not and only if so we indicate convergence has been reached.- Overrides:
hasConverged
in classStaticLtmAssignmentStrategy
- Parameters:
gapFunction
- to use for regular convergence check on costiterationIndex
- at hand- Returns:
- true when converged, false otherwise
-
-