Package org.planit.trafficassignment
Class TrafficAssignment
- java.lang.Object
-
- org.djutils.event.EventProducer
-
- org.planit.trafficassignment.TrafficAssignmentComponent<NetworkLoading>
-
- org.planit.supply.networkloading.NetworkLoading
-
- org.planit.trafficassignment.TrafficAssignment
-
- All Implemented Interfaces:
Serializable
,org.djutils.event.EventProducerInterface
- Direct Known Subclasses:
CapacityConstrainedAssignment
,TraditionalStaticAssignment
public abstract class TrafficAssignment extends NetworkLoading
Traffic assignment class which simultaneously is responsible for the loading hence it is also considered as a traffic assignment component of this type- Author:
- markr
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected Demands
demands
The demand to useprotected InitialLinkSegmentCost
initialLinkSegmentCost
The initial link segment costprotected Map<TimePeriod,InitialLinkSegmentCost>
initialLinkSegmentCostByTimePeriod
Map storing InitialLinkSegmentCost objects for each time periodprotected int
numberOfNetworkSegments
holds the count of all link segments in the transport networkprotected int
numberOfNetworkVertices
holds the count of all vertices in the transport networkprotected OutputManager
outputManager
Output manager deals with all the output configurations for the registered traffic assignmentsprotected PhysicalCost
physicalCost
The physical generalized cost approachprotected PhysicalNetwork
physicalNetwork
Physical network to useprotected Smoothing
smoothing
the smoothing to usestatic String
TRADITIONAL_STATIC_ASSIGNMENT
protected TrafficAssignmentBuilder
trafficAssignmentBuilder
The builder for all traffic assignment instancesprotected TransportNetwork
transportNetwork
The transport network to use which is an adaptor around the physical network and the zoningprotected VirtualCost
virtualCost
The virtual cost function-
Fields inherited from class org.planit.trafficassignment.TrafficAssignmentComponent
groupId, id, trafficComponentType
-
-
Constructor Summary
Constructors Constructor Description TrafficAssignment(IdGroupingToken groupId)
Constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description OutputTypeConfiguration
activateOutput(OutputType outputType)
Method that allows one to activate specific output types for persistence which is passed on to the output managerprotected abstract void
addRegisteredEventTypeListeners(org.djutils.event.EventType eventType)
register all the known listeners for the passed in eventType on this producer for this event typeprotected void
checkForEmptyComponents()
Check if any components are undefined, if so throw exceptionTrafficAssignmentBuilder
collectBuilder(InputBuilderListener trafficComponentCreateListener, Demands theDemands, Zoning theZoning, PhysicalNetwork thePhysicalNetwork)
Each traffic assignment class can have its own builder which reveals what components need to be registered on the traffic assignment instance in order to function properly.protected String
createLoggingPrefix(int iterationIndex)
create the logging prefix for logging statements during equilibrationabstract OutputTypeAdapter
createOutputTypeAdapter(OutputType outputType)
Create the output type adapter for the current output typeprotected abstract TrafficAssignmentBuilder
createTrafficAssignmentBuilder(InputBuilderListener trafficComponentCreateListener, Demands demands, Zoning zoning, PhysicalNetwork physicalNetwork)
create the traffic assignment builder for this traffic assignmentprotected void
createTransportNetwork()
Initialize the transport network by combining the physical and virtual componentsvoid
deactivateOutput(OutputType outputType)
Deactivate the specified output typeprotected void
disbandTransportNetwork()
detach the virtual and physical transport network againvoid
execute()
Execute assignment, including initializing resources, running equilibration and then closing resourcesabstract void
executeEquilibration()
Run equilibration after resources initialized, including saving resultsprotected void
finalizeAfterExecution()
Finalize all relevant traffic assignment components after execution of the assignment has endedGapFunction
getGapFunction()
Collect the gap function which is to be set by a derived class of TrafficAssignment via the initialiseDefaults() right after constructionOutputConfiguration
getOutputConfiguration()
Provide the output configuration for user access (via the output manager)List<OutputFormatter>
getOutputFormatters()
Returns a list of output formatters registered on this assignmentPhysicalCost
getPhysicalCost()
Get the dynamic physical cost object for the current assignmentabstract SimulationData
getSimulationData()
Return the simulation data for the current iterationSmoothing
getSmoothing()
Collect the smoothing object for the current traffic assignmentTransportNetwork
getTransportNetwork()
Get the TransportNetwork used in the current assignmentVirtualCost
getVirtualCost()
Returns the virtual cost object for the current assignmentprotected void
initialiseBeforeExecution()
Initialize all relevant traffic assignment components before execution of the assignment commencesboolean
isOutputTypeActive(OutputType outputType)
Verify if a given output type is activevoid
registerOutputFormatter(OutputFormatter outputFormatter)
Register the output formatter on the assignmentvoid
setDemands(Demands demands)
Set the Demands object for the current assignmentvoid
setGapFunction(GapFunction gapfunction)
Collect the gap function which is to be set by a derived class of TrafficAssignment via the initialiseDefaults() right after constructionvoid
setInitialLinkSegmentCost(InitialLinkSegmentCost initialLinkSegmentCost)
Set the initial link segment cost unrelated to any particular time period, i.e., used for all time periods that do not have designated initial costs specified for themvoid
setInitialLinkSegmentCost(TimePeriod timePeriod, InitialLinkSegmentCost initialLinkSegmentCost)
Set the initial link segment cost for a specified time period, otherwise revert to the general initial link segment cost (if any)void
setPhysicalCost(PhysicalCost physicalCost)
Set the physical cost where in case the cost is an InteractorAccessor will trigger an event to get access to the required data via requesting an InteractorAccesseevoid
setPhysicalNetwork(PhysicalNetwork physicalNetwork)
Set the PhysicalNetwork for the current assignmentvoid
setSmoothing(Smoothing smoothing)
Set the Smoothing object for the current assignmentvoid
setVirtualCost(VirtualCost virtualCost)
Set the virtual cost where in case the cost is an InteractorAccessor will trigger an event to get access to the required data via requesting an InteractorAccesseevoid
setZoning(Zoning zoning)
Set the zoning object for the current assignmentvoid
unregisterOutputFormatter(OutputFormatter outputFormatter)
Unregister an output formatterprotected void
verifyComponentCompatibility()
Verify if the traffic assignment components are compatible and nonnull-
Methods inherited from class org.planit.trafficassignment.TrafficAssignmentComponent
getId, getIdGroupingtoken, getSourceId, getTrafficComponentType
-
Methods inherited from class org.djutils.event.EventProducer
addListener, addListener, addListener, addListener, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, getEventTypesWithListeners, hasListeners, numberOfListeners, removeAllListeners, removeAllListeners, removeListener
-
-
-
-
Field Detail
-
trafficAssignmentBuilder
protected TrafficAssignmentBuilder trafficAssignmentBuilder
The builder for all traffic assignment instances
-
physicalNetwork
protected PhysicalNetwork physicalNetwork
Physical network to use
-
outputManager
protected OutputManager outputManager
Output manager deals with all the output configurations for the registered traffic assignments
-
transportNetwork
protected TransportNetwork transportNetwork
The transport network to use which is an adaptor around the physical network and the zoning
-
virtualCost
protected VirtualCost virtualCost
The virtual cost function
-
numberOfNetworkSegments
protected int numberOfNetworkSegments
holds the count of all link segments in the transport network
-
numberOfNetworkVertices
protected int numberOfNetworkVertices
holds the count of all vertices in the transport network
-
smoothing
protected Smoothing smoothing
the smoothing to use
-
demands
protected Demands demands
The demand to use
-
initialLinkSegmentCost
protected InitialLinkSegmentCost initialLinkSegmentCost
The initial link segment cost
-
physicalCost
protected PhysicalCost physicalCost
The physical generalized cost approach
-
initialLinkSegmentCostByTimePeriod
protected Map<TimePeriod,InitialLinkSegmentCost> initialLinkSegmentCostByTimePeriod
Map storing InitialLinkSegmentCost objects for each time period
-
TRADITIONAL_STATIC_ASSIGNMENT
public static String TRADITIONAL_STATIC_ASSIGNMENT
-
-
Constructor Detail
-
TrafficAssignment
public TrafficAssignment(IdGroupingToken groupId)
Constructor. Note that defaults that partly depend on derived classes are assumed to be invoked by the calling method via this.initialiseDefaults()- Parameters:
groupId
- contiguous id generation within this group for instances of this class
-
-
Method Detail
-
createTrafficAssignmentBuilder
protected abstract TrafficAssignmentBuilder createTrafficAssignmentBuilder(InputBuilderListener trafficComponentCreateListener, Demands demands, Zoning zoning, PhysicalNetwork physicalNetwork) throws PlanItException
create the traffic assignment builder for this traffic assignment- Parameters:
trafficComponentCreateListener
- listener to register on all traffic assignment components that this builder can builddemands
- the demands this assignment works onzoning
- the zoning this assignment works onphysicalNetwork
- the physical network this assignment works on- Returns:
- created traffic assignment builder
- Throws:
PlanItException
- thrown if there is an error
-
addRegisteredEventTypeListeners
protected abstract void addRegisteredEventTypeListeners(org.djutils.event.EventType eventType)
register all the known listeners for the passed in eventType on this producer for this event type- Parameters:
eventType
- the event type to register
-
createLoggingPrefix
protected String createLoggingPrefix(int iterationIndex)
create the logging prefix for logging statements during equilibration- Parameters:
iterationIndex
- the iteration- Returns:
- prefix for logging of traffic assignment messages
-
checkForEmptyComponents
protected void checkForEmptyComponents() throws PlanItException
Check if any components are undefined, if so throw exception- Throws:
PlanItException
- thrown if any components are undefined
-
verifyComponentCompatibility
protected void verifyComponentCompatibility() throws PlanItException
Verify if the traffic assignment components are compatible and nonnull- Throws:
PlanItException
- thrown if the components are not compatible
-
createTransportNetwork
protected void createTransportNetwork() throws PlanItException
Initialize the transport network by combining the physical and virtual components- Throws:
PlanItException
- thrown if there is an error
-
disbandTransportNetwork
protected void disbandTransportNetwork() throws PlanItException
detach the virtual and physical transport network again- Throws:
PlanItException
- thrown if there is an error
-
initialiseBeforeExecution
protected void initialiseBeforeExecution() throws PlanItException
Initialize all relevant traffic assignment components before execution of the assignment commences- Throws:
PlanItException
- thrown if there is an error
-
finalizeAfterExecution
protected void finalizeAfterExecution() throws PlanItException
Finalize all relevant traffic assignment components after execution of the assignment has ended- Throws:
PlanItException
- thrown if there is an error
-
collectBuilder
public TrafficAssignmentBuilder collectBuilder(InputBuilderListener trafficComponentCreateListener, Demands theDemands, Zoning theZoning, PhysicalNetwork thePhysicalNetwork) throws PlanItException
Each traffic assignment class can have its own builder which reveals what components need to be registered on the traffic assignment instance in order to function properly.- Parameters:
trafficComponentCreateListener
- , the listener should be registered on all traffic component factories the traffic assignment utilisestheDemands
- this assignment works ontheZoning
- this assignment works onthePhysicalNetwork
- this assignment works on- Returns:
- trafficAssignmentBuilder to use
- Throws:
PlanItException
- thrown if there is an error
-
executeEquilibration
public abstract void executeEquilibration() throws PlanItException
Run equilibration after resources initialized, including saving results- Throws:
PlanItException
- thrown if there is an error
-
createOutputTypeAdapter
public abstract OutputTypeAdapter createOutputTypeAdapter(OutputType outputType)
Create the output type adapter for the current output type- Parameters:
outputType
- the current output type- Returns:
- the output type adapter corresponding to the current traffic assignment and output type
-
activateOutput
public OutputTypeConfiguration activateOutput(OutputType outputType) throws PlanItException
Method that allows one to activate specific output types for persistence which is passed on to the output manager- Parameters:
outputType
- OutputType object to be used- Returns:
- outputTypeConfiguration the output type configuration that is now active
- Throws:
PlanItException
- thrown if there is an error activating the output
-
deactivateOutput
public void deactivateOutput(OutputType outputType)
Deactivate the specified output type- Parameters:
outputType
- the output type to be deactivated
-
isOutputTypeActive
public boolean isOutputTypeActive(OutputType outputType)
Verify if a given output type is active- Parameters:
outputType
- the output type to check if active- Returns:
- true if active, false otherwise
-
execute
public void execute() throws PlanItException
Execute assignment, including initializing resources, running equilibration and then closing resources- Throws:
PlanItException
- thrown if there is an error
-
getTransportNetwork
public TransportNetwork getTransportNetwork()
Get the TransportNetwork used in the current assignment- Returns:
- TransportNetwork used in current assignment
-
getOutputConfiguration
public OutputConfiguration getOutputConfiguration()
Provide the output configuration for user access (via the output manager)- Returns:
- outputConfiguration for this traffic assignment
-
setSmoothing
public void setSmoothing(Smoothing smoothing)
Set the Smoothing object for the current assignment- Parameters:
smoothing
- Smoothing object for the current assignment
-
getSmoothing
public Smoothing getSmoothing()
Collect the smoothing object for the current traffic assignment- Returns:
- smoothing
-
getGapFunction
public GapFunction getGapFunction()
Collect the gap function which is to be set by a derived class of TrafficAssignment via the initialiseDefaults() right after construction- Returns:
- gapFunction
-
setGapFunction
public void setGapFunction(GapFunction gapfunction)
Collect the gap function which is to be set by a derived class of TrafficAssignment via the initialiseDefaults() right after construction- Parameters:
gapfunction
- the gap function to set
-
setPhysicalNetwork
public void setPhysicalNetwork(PhysicalNetwork physicalNetwork)
Set the PhysicalNetwork for the current assignment- Parameters:
physicalNetwork
- the PhysicalNetwork object for the current assignment
-
setDemands
public void setDemands(Demands demands)
Set the Demands object for the current assignment- Parameters:
demands
- the Demands object for the current assignment
-
setZoning
public void setZoning(Zoning zoning)
Set the zoning object for the current assignment- Parameters:
zoning
- the Zoning object for the current assignment
-
setInitialLinkSegmentCost
public void setInitialLinkSegmentCost(InitialLinkSegmentCost initialLinkSegmentCost)
Set the initial link segment cost unrelated to any particular time period, i.e., used for all time periods that do not have designated initial costs specified for them- Parameters:
initialLinkSegmentCost
- the initial link segment cost
-
setInitialLinkSegmentCost
public void setInitialLinkSegmentCost(TimePeriod timePeriod, InitialLinkSegmentCost initialLinkSegmentCost)
Set the initial link segment cost for a specified time period, otherwise revert to the general initial link segment cost (if any)- Parameters:
timePeriod
- the specified time periodinitialLinkSegmentCost
- the initial link segment cost
-
getPhysicalCost
public PhysicalCost getPhysicalCost()
Get the dynamic physical cost object for the current assignment- Returns:
- the physical cost object for the current assignment
-
setPhysicalCost
public void setPhysicalCost(PhysicalCost physicalCost) throws PlanItException
Set the physical cost where in case the cost is an InteractorAccessor will trigger an event to get access to the required data via requesting an InteractorAccessee- Parameters:
physicalCost
- the physical cost object for the current assignment- Throws:
PlanItException
- thrown if there is an error
-
getVirtualCost
public VirtualCost getVirtualCost()
Returns the virtual cost object for the current assignment- Returns:
- the virtual cost object for the current assignments
-
setVirtualCost
public void setVirtualCost(VirtualCost virtualCost) throws PlanItException
Set the virtual cost where in case the cost is an InteractorAccessor will trigger an event to get access to the required data via requesting an InteractorAccessee- Parameters:
virtualCost
- the virtual cost object to be assigned- Throws:
PlanItException
- thrown if there is an error
-
registerOutputFormatter
public void registerOutputFormatter(OutputFormatter outputFormatter)
Register the output formatter on the assignment- Parameters:
outputFormatter
- OutputFormatter to be registered
-
unregisterOutputFormatter
public void unregisterOutputFormatter(OutputFormatter outputFormatter)
Unregister an output formatter- Parameters:
outputFormatter
- the output formatter to be removed
-
getOutputFormatters
public List<OutputFormatter> getOutputFormatters()
Returns a list of output formatters registered on this assignment- Returns:
- List of OutputFormatter objects registered on this assignment
-
getSimulationData
public abstract SimulationData getSimulationData()
Return the simulation data for the current iteration- Returns:
- the simulation data for the current iteration
-
-