Package org.planit.project
Class CustomPlanItProject
- java.lang.Object
-
- org.planit.project.CustomPlanItProject
-
- Direct Known Subclasses:
PlanItProject
,PlanItSimpleProject
public class CustomPlanItProject extends Object
The top-level class which hosts a single project. A project can consist of multiple networks, demands and traffic assignments all based on a single configuration (user classes, modes etc.)- Author:
- markr
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
CustomPlanItProject.ProjectAssignments
Internal class for registered traffic assignments
-
Field Summary
Fields Modifier and Type Field Description protected TrafficAssignmentComponentFactory<NetworkLoading>
assignmentFactory
Object factory for network loading objectPlanItProjectInput.ProjectDemands
demands
The registered demandsprotected long
id
unique identifier for this project across all projects in the JVMprotected InputBuilderListener
inputBuilderListener
the listener that we register on each traffic assignment component creation event for external initializationprotected PlanItProjectInput
inputs
The input container holding all traffic assignment input components and related functionality with respect to project managementPlanItProjectInput.ProjectODRouteSets
odRouteSets
The registered OD route setsprotected TreeMap<Long,OutputFormatter>
outputFormatters
The output formatter(s) registered on this projectPlanItProjectInput.ProjectNetworks
physicalNetworks
The registered physical networksprotected IdGroupingToken
projectToken
id generation using this token will be contiguous and unique for all instances created with this token.CustomPlanItProject.ProjectAssignments
trafficAssignments
The registered assignmentsPlanItProjectInput.ProjectZonings
zonings
The registered zonings
-
Constructor Summary
Constructors Constructor Description CustomPlanItProject(InputBuilderListener inputBuilderListener)
Constructor which reads in the input builder listener and instantiates the object factory classes.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Demands
createAndRegisterDemands(Zoning zoning, PhysicalNetwork physicalNetwork)
Create and register demands to the projectInitialLinkSegmentCost
createAndRegisterInitialLinkSegmentCost(PhysicalNetwork network, String fileName)
Create and register initial link segment costs from a (single) file which we assume are available in the native xml/csv output format as provided in this projectList<InitialLinkSegmentCostPeriod>
createAndRegisterInitialLinkSegmentCost(PhysicalNetwork network, String fileName, Demands demands)
Create and register initial link segment costs from a (single) file for all time periods in Demands objectInitialLinkSegmentCostPeriod
createAndRegisterInitialLinkSegmentCost(PhysicalNetwork network, String fileName, TimePeriod timePeriod)
Create and register initial link segment costs from a (single) file and register it to the provided time periodODRouteSets
createAndRegisterODRouteSets(PhysicalNetwork physicalNetwork, Zoning zoning, String odRouteSetInputPath)
Create and register the OD route sets as populated by the input builder through the path sourceOutputFormatter
createAndRegisterOutputFormatter(String outputFormatterType)
Create and register an output formatter instance of a given typePhysicalNetwork
createAndRegisterPhysicalNetwork(String physicalNetworkType)
Create and register a physical network on the projectTrafficAssignmentBuilder
createAndRegisterTrafficAssignment(String trafficAssignmentType, Demands theDemands, Zoning theZoning, PhysicalNetwork thePhysicalNetwork)
Create and register a deterministic traffic assignment instance of a given typeZoning
createAndRegisterZoning(PhysicalNetwork physicalNetwork)
Create and register the zoning system on the networkvoid
executeAllTrafficAssignments()
Execute all registered traffic assignments Top-level error recording is done in this class.protected void
executeTrafficAssignment(TrafficAssignment ta)
Execute a particular traffic assignmentList<InitialLinkSegmentCost>
getInitialLinkSegmentCost(PhysicalNetwork network)
Return the initial link segment costs for a networkOutputFormatter
getOutputFormatter(long id)
Retrieve an output formatter object given its idprotected void
initialiseFactories()
Instantiate the factories and register the event manager on themvoid
registerEligibleTrafficComponentClass(Class<? extends TrafficAssignmentComponent<?>> theClazz)
Register a class that we allow to be instantiated as a concrete implementation of a traffic assignment component that can be used in PLANit
-
-
-
Field Detail
-
id
protected final long id
unique identifier for this project across all projects in the JVM
-
projectToken
protected IdGroupingToken projectToken
id generation using this token will be contiguous and unique for all instances created with this token. This token is related to the current instance of this class, i.e., the project
-
inputs
protected final PlanItProjectInput inputs
The input container holding all traffic assignment input components and related functionality with respect to project management
-
inputBuilderListener
protected final InputBuilderListener inputBuilderListener
the listener that we register on each traffic assignment component creation event for external initialization
-
outputFormatters
protected final TreeMap<Long,OutputFormatter> outputFormatters
The output formatter(s) registered on this project
-
assignmentFactory
protected TrafficAssignmentComponentFactory<NetworkLoading> assignmentFactory
Object factory for network loading object
-
physicalNetworks
public final PlanItProjectInput.ProjectNetworks physicalNetworks
The registered physical networks
-
demands
public final PlanItProjectInput.ProjectDemands demands
The registered demands
-
zonings
public final PlanItProjectInput.ProjectZonings zonings
The registered zonings
-
odRouteSets
public final PlanItProjectInput.ProjectODRouteSets odRouteSets
The registered OD route sets
-
trafficAssignments
public final CustomPlanItProject.ProjectAssignments trafficAssignments
The registered assignments
-
-
Constructor Detail
-
CustomPlanItProject
public CustomPlanItProject(InputBuilderListener inputBuilderListener)
Constructor which reads in the input builder listener and instantiates the object factory classes. This constructor instantiates the EventManager, which must be a singleton class for the whole application.- Parameters:
inputBuilderListener
- InputBuilderListener used to read in data
-
-
Method Detail
-
initialiseFactories
protected void initialiseFactories()
Instantiate the factories and register the event manager on them
-
executeTrafficAssignment
protected void executeTrafficAssignment(TrafficAssignment ta)
Execute a particular traffic assignment- Parameters:
ta
- TrafficAssignment to be run
-
registerEligibleTrafficComponentClass
public void registerEligibleTrafficComponentClass(Class<? extends TrafficAssignmentComponent<?>> theClazz) throws PlanItException
Register a class that we allow to be instantiated as a concrete implementation of a traffic assignment component that can be used in PLANit- Parameters:
theClazz
- the class that we want to mark as eligible from an outside source- Throws:
PlanItException
- thrown if class cannot be registered
-
createAndRegisterPhysicalNetwork
public PhysicalNetwork createAndRegisterPhysicalNetwork(String physicalNetworkType) throws PlanItException
Create and register a physical network on the project- Parameters:
physicalNetworkType
- name of physical network class to register- Returns:
- the generated physical network
- Throws:
PlanItException
- thrown if there is an error
-
createAndRegisterZoning
public Zoning createAndRegisterZoning(PhysicalNetwork physicalNetwork) throws PlanItException
Create and register the zoning system on the network- Parameters:
physicalNetwork
- the physical network on which the zoning will be based- Returns:
- the generated zoning object
- Throws:
PlanItException
- thrown if there is an error
-
createAndRegisterDemands
public Demands createAndRegisterDemands(Zoning zoning, PhysicalNetwork physicalNetwork) throws PlanItException
Create and register demands to the project- Parameters:
zoning
- Zoning object which defines the zones which will be used in the demand matrix to be createdphysicalNetwork
- the physical network which stores the modes (demands can different for each mode)- Returns:
- the generated demands object
- Throws:
PlanItException
- thrown if there is an error
-
createAndRegisterODRouteSets
public ODRouteSets createAndRegisterODRouteSets(PhysicalNetwork physicalNetwork, Zoning zoning, String odRouteSetInputPath) throws PlanItException
Create and register the OD route sets as populated by the input builder through the path source- Parameters:
physicalNetwork
- network the routes must be compatible withzoning
- zoning to match od routes toodRouteSetInputPath
- path to collect the routes from- Returns:
- od route sets that have been parsed
- Throws:
PlanItException
- thrown if there is an error
-
createAndRegisterTrafficAssignment
public TrafficAssignmentBuilder createAndRegisterTrafficAssignment(String trafficAssignmentType, Demands theDemands, Zoning theZoning, PhysicalNetwork thePhysicalNetwork) throws PlanItException
Create and register a deterministic traffic assignment instance of a given type- Parameters:
trafficAssignmentType
- the class name of the traffic assignment type object to be createdtheDemands
- the demandstheZoning
- the zoningthePhysicalNetwork
- the physical network- Returns:
- the traffic assignment builder object
- Throws:
PlanItException
- thrown if there is an error
-
createAndRegisterInitialLinkSegmentCost
public InitialLinkSegmentCost createAndRegisterInitialLinkSegmentCost(PhysicalNetwork network, String fileName) throws PlanItException
Create and register initial link segment costs from a (single) file which we assume are available in the native xml/csv output format as provided in this project- Parameters:
network
- physical network the InitialLinkSegmentCost object will be registered forfileName
- file containing the initial link segment cost values- Returns:
- the InitialLinkSegmentCost object
- Throws:
PlanItException
- thrown if there is an error
-
createAndRegisterInitialLinkSegmentCost
public InitialLinkSegmentCostPeriod createAndRegisterInitialLinkSegmentCost(PhysicalNetwork network, String fileName, TimePeriod timePeriod) throws PlanItException
Create and register initial link segment costs from a (single) file and register it to the provided time period- Parameters:
network
- physical network the InitialLinkSegmentCost object will be registered forfileName
- location of file containing the initial link segment cost valuestimePeriod
- to register the initial cost on- Returns:
- the InitialLinkSegmentCostPeriod object
- Throws:
PlanItException
- thrown if there is an error
-
createAndRegisterInitialLinkSegmentCost
public List<InitialLinkSegmentCostPeriod> createAndRegisterInitialLinkSegmentCost(PhysicalNetwork network, String fileName, Demands demands) throws PlanItException
Create and register initial link segment costs from a (single) file for all time periods in Demands object- Parameters:
network
- physical network the InitialLinkSegmentCost object will be registered forfileName
- location of file containing the initial link segment cost valuesdemands
- the Demands object to extract all eligible time periods from- Returns:
- the InitialLinkSegmentCostPeriod objects
- Throws:
PlanItException
- thrown if there is an error
-
createAndRegisterOutputFormatter
public OutputFormatter createAndRegisterOutputFormatter(String outputFormatterType) throws PlanItException
Create and register an output formatter instance of a given type- Parameters:
outputFormatterType
- the class name of the output formatter type object to be created- Returns:
- the generated output formatter object
- Throws:
PlanItException
- thrown if there is an error
-
getInitialLinkSegmentCost
public List<InitialLinkSegmentCost> getInitialLinkSegmentCost(PhysicalNetwork network)
Return the initial link segment costs for a network- Parameters:
network
- the specified physical network- Returns:
- the initial link segment costs for the specified physical network
-
getOutputFormatter
public OutputFormatter getOutputFormatter(long id)
Retrieve an output formatter object given its id- Parameters:
id
- the id of the output formatter object- Returns:
- the retrieved output formatter object
-
executeAllTrafficAssignments
public void executeAllTrafficAssignments() throws PlanItException
Execute all registered traffic assignments Top-level error recording is done in this class. If several traffic assignments are registered and one fails, we record its error and continue with the next assignment.- Throws:
PlanItException
- required for subclasses which override this method and generate an exception before the runs start
-
-