Package org.goplanit.output.formatter
Class MemoryOutputFormatter
- java.lang.Object
-
- org.goplanit.output.formatter.BaseOutputFormatter
-
- org.goplanit.output.formatter.MemoryOutputFormatter
-
- All Implemented Interfaces:
OutputFormatter
public class MemoryOutputFormatter extends BaseOutputFormatter
OutputFormatter which stores data in memory, using specified keys and output properties.- Author:
- gman6028
-
-
Field Summary
Fields Modifier and Type Field Description MemoryOutputIterator
iterator
Iterator to loop over results contained in this formatter-
Fields inherited from class org.goplanit.output.formatter.BaseOutputFormatter
id, initialCostsLocation, outputKeyProperties, outputTimeUnit, outputTypeKeysLocked, outputTypes, outputTypeValuesLocked, outputValueProperties
-
Fields inherited from interface org.goplanit.output.formatter.OutputFormatter
MEMORY_OUTPUT_FORMATTER, NOT_SPECIFIED, PLANIT_OUTPUT_FORMATTER
-
-
Constructor Summary
Constructors Constructor Description MemoryOutputFormatter(IdGroupingToken groupId)
Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
canHandleMultipleIterations()
Flag to indicate whether an implementation can handle multiple iterations If this returns false, acts as though OutputConfiguration.setPersistOnlyFinalIteration() is set to truevoid
finaliseAfterSimulation(OutputConfiguration outputConfiguration, OutputAdapter outputAdapter)
Close all resources used in this formatterMemoryOutputIterator
getIterator(Mode mode, TimePeriod timePeriod, Integer iterationIndex, OutputType outputType)
Returns a MemoryOutputIterator for the contents of the specified MultiKeyPlanItData mapint
getLastIteration()
Returns the value of the last iteration of recorded dataObject
getOutputDataValue(Mode mode, TimePeriod timePeriod, Integer iterationIndex, OutputType outputType, OutputPropertyType outputProperty, Object[] keyValues)
Get a specified data valueOutputProperty[]
getOutputKeyProperties(OutputType outputType)
Returns the array of output properties representing the output types of the keys for the current output typeOutputProperty[]
getOutputValueProperties(OutputType outputType)
Returns the array of output properties representing the output types of the data values for the current output typeint
getPositionOfOutputKeyProperty(OutputType outputType, OutputPropertyType outputKeyProperty)
Returns the position of a property type in the output key property arrayint
getPositionOfOutputValueProperty(OutputType outputType, OutputPropertyType outputValueProperty)
Returns the position of a property type in the output values property arrayvoid
initialiseBeforeSimulation(OutputConfiguration outputConfiguration, long runId)
Opens all resources used in the formatterprotected void
writeGeneralResultsForCurrentTimePeriod(OutputConfiguration outputConfiguration, OutputTypeConfiguration outputTypeConfiguration, OutputTypeEnum currentOutputType, OutputAdapter outputAdapter, Set<Mode> modes, TimePeriod timePeriod, int iterationIndex)
Write General results for the current time period to the CSV fileprotected void
writeLinkResultsForCurrentTimePeriod(OutputConfiguration outputConfiguration, OutputTypeConfiguration outputTypeConfiguration, OutputTypeEnum currentOutputType, OutputAdapter outputAdapter, Set<Mode> modes, TimePeriod timePeriod, int iterationIndex)
Write link results for the current time period to Map in memoryprotected void
writeOdResultsForCurrentTimePeriod(OutputConfiguration outputConfiguration, OutputTypeConfiguration outputTypeConfiguration, OutputTypeEnum currentOutputType, OutputAdapter outputAdapter, Set<Mode> modes, TimePeriod timePeriod, int iterationIndex)
Write Origin-Destination results for the time period to the Map in memoryprotected void
writePathResultsForCurrentTimePeriod(OutputConfiguration outputConfiguration, OutputTypeConfiguration outputTypeConfiguration, OutputTypeEnum currentOutputType, OutputAdapter outputAdapter, Set<Mode> modes, TimePeriod timePeriod, int iterationIndex)
Write Path results for the time period to the CSV fileprotected void
writeSimulationResultsForCurrentTimePeriod(OutputConfiguration outputConfiguration, OutputTypeConfiguration outputTypeConfiguration, OutputTypeEnum currentOutputType, OutputAdapter outputAdapter, Set<Mode> modes, TimePeriod timePeriod, int iterationIndex)
Write Simulation results for the current time period to the CSV file-
Methods inherited from class org.goplanit.output.formatter.BaseOutputFormatter
getId, lockOutputProperties, persist
-
-
-
-
Field Detail
-
iterator
public MemoryOutputIterator iterator
Iterator to loop over results contained in this formatter
-
-
Constructor Detail
-
MemoryOutputFormatter
public MemoryOutputFormatter(IdGroupingToken groupId)
Constructor- Parameters:
groupId
- , contiguous id generation within this group for instances of this class
-
-
Method Detail
-
writeSimulationResultsForCurrentTimePeriod
protected void writeSimulationResultsForCurrentTimePeriod(OutputConfiguration outputConfiguration, OutputTypeConfiguration outputTypeConfiguration, OutputTypeEnum currentOutputType, OutputAdapter outputAdapter, Set<Mode> modes, TimePeriod timePeriod, int iterationIndex) throws PlanItException
Write Simulation results for the current time period to the CSV file- Specified by:
writeSimulationResultsForCurrentTimePeriod
in classBaseOutputFormatter
- Parameters:
outputConfiguration
- output configurationoutputTypeConfiguration
- OutputTypeConfiguration for current persistencecurrentOutputType
- , the active output type of the configuration we are persisting for (can be a suboutputtype)outputAdapter
- OutputAdapter for current persistencemodes
- Set of modes of traveltimePeriod
- current time perioditerationIndex
- the iterationIndex we are persisting for- Throws:
PlanItException
- thrown if there is an error
-
writeGeneralResultsForCurrentTimePeriod
protected void writeGeneralResultsForCurrentTimePeriod(OutputConfiguration outputConfiguration, OutputTypeConfiguration outputTypeConfiguration, OutputTypeEnum currentOutputType, OutputAdapter outputAdapter, Set<Mode> modes, TimePeriod timePeriod, int iterationIndex) throws PlanItException
Write General results for the current time period to the CSV file- Specified by:
writeGeneralResultsForCurrentTimePeriod
in classBaseOutputFormatter
- Parameters:
outputConfiguration
- output configurationoutputTypeConfiguration
- OutputTypeConfiguration for current persistencecurrentOutputType
- , the active output type of the configuration we are persisting for (can be a suboutputtype)outputAdapter
- OutputAdapter for current persistencemodes
- Set of modes of traveltimePeriod
- current time perioditerationIndex
- the iteration index we are persisting for- Throws:
PlanItException
- thrown if there is an error
-
writeLinkResultsForCurrentTimePeriod
protected void writeLinkResultsForCurrentTimePeriod(OutputConfiguration outputConfiguration, OutputTypeConfiguration outputTypeConfiguration, OutputTypeEnum currentOutputType, OutputAdapter outputAdapter, Set<Mode> modes, TimePeriod timePeriod, int iterationIndex) throws PlanItException
Write link results for the current time period to Map in memory- Specified by:
writeLinkResultsForCurrentTimePeriod
in classBaseOutputFormatter
- Parameters:
outputConfiguration
- outputConfigurationoutputTypeConfiguration
- OutputTypeConfiguration for current persistencecurrentOutputType
- , the active output type of the configuration we are persisting for (can be a suboutputtype)outputAdapter
- OutputAdapter for current persistencemodes
- Set of modes of traveltimePeriod
- current time perioditerationIndex
- the iteration index we are persisting for- Throws:
PlanItException
- thrown if there is an error
-
writeOdResultsForCurrentTimePeriod
protected void writeOdResultsForCurrentTimePeriod(OutputConfiguration outputConfiguration, OutputTypeConfiguration outputTypeConfiguration, OutputTypeEnum currentOutputType, OutputAdapter outputAdapter, Set<Mode> modes, TimePeriod timePeriod, int iterationIndex) throws PlanItException
Write Origin-Destination results for the time period to the Map in memory- Specified by:
writeOdResultsForCurrentTimePeriod
in classBaseOutputFormatter
- Parameters:
outputConfiguration
- outputConfigurationoutputTypeConfiguration
- OutputTypeConfiguration for current persistencecurrentOutputType
- , the active output type of the configuration we are persisting for (can be a suboutputtype)outputAdapter
- OutputAdapter for current persistencemodes
- Set of modes of traveltimePeriod
- current time perioditerationIndex
- the iteration index we are persisting for- Throws:
PlanItException
- thrown if there is an error
-
writePathResultsForCurrentTimePeriod
protected void writePathResultsForCurrentTimePeriod(OutputConfiguration outputConfiguration, OutputTypeConfiguration outputTypeConfiguration, OutputTypeEnum currentOutputType, OutputAdapter outputAdapter, Set<Mode> modes, TimePeriod timePeriod, int iterationIndex) throws PlanItException
Write Path results for the time period to the CSV file- Specified by:
writePathResultsForCurrentTimePeriod
in classBaseOutputFormatter
- Parameters:
outputConfiguration
- outputConfigurationoutputTypeConfiguration
- OutputTypeConfiguration for current persistencecurrentOutputType
- the output type we are persisting foroutputAdapter
- OutputAdapter for the current persistencemodes
- Set of modes of traveltimePeriod
- current time perioditerationIndex
- current iteration index- Throws:
PlanItException
- thrown if there is an error
-
getOutputDataValue
public Object getOutputDataValue(Mode mode, TimePeriod timePeriod, Integer iterationIndex, OutputType outputType, OutputPropertyType outputProperty, Object[] keyValues) throws PlanItException
Get a specified data value- Parameters:
mode
- value of mode keytimePeriod
- value of time period keyiterationIndex
- value of iteration index keyoutputType
- value of output type keyoutputProperty
- output property to identify the columnkeyValues
- values of keys to identify the row- Returns:
- data map for the specified keys
- Throws:
PlanItException
- thrown if there is an error
-
initialiseBeforeSimulation
public void initialiseBeforeSimulation(OutputConfiguration outputConfiguration, long runId) throws PlanItException
Opens all resources used in the formatter- Parameters:
outputConfiguration
- OutputTypeConfiguration for the assignmentrunId
- the traffic assignments runId- Throws:
PlanItException
- thrown if there is an error
-
finaliseAfterSimulation
public void finaliseAfterSimulation(OutputConfiguration outputConfiguration, OutputAdapter outputAdapter) throws PlanItException
Close all resources used in this formatter- Parameters:
outputConfiguration
- OutputConfiguration of the assignmentoutputAdapter
- the outputAdapter- Throws:
PlanItException
- thrown if there is an error
-
getOutputKeyProperties
public OutputProperty[] getOutputKeyProperties(OutputType outputType)
Returns the array of output properties representing the output types of the keys for the current output type- Parameters:
outputType
- the current output type- Returns:
- array of output properties of the keys
-
getOutputValueProperties
public OutputProperty[] getOutputValueProperties(OutputType outputType)
Returns the array of output properties representing the output types of the data values for the current output type- Parameters:
outputType
- the current output type- Returns:
- array of output properties of the data values for the current output type
-
getLastIteration
public int getLastIteration()
Returns the value of the last iteration of recorded data- Returns:
- the last iteration of recorded data
-
canHandleMultipleIterations
public boolean canHandleMultipleIterations()
Flag to indicate whether an implementation can handle multiple iterations If this returns false, acts as though OutputConfiguration.setPersistOnlyFinalIteration() is set to true- Returns:
- flag to indicate whether the OutputFormatter can handle multiple iterations
-
getIterator
public MemoryOutputIterator getIterator(Mode mode, TimePeriod timePeriod, Integer iterationIndex, OutputType outputType)
Returns a MemoryOutputIterator for the contents of the specified MultiKeyPlanItData map- Parameters:
mode
- value of mode keytimePeriod
- value of time period keyiterationIndex
- value of iteration index keyoutputType
- value of output type key- Returns:
- map iterator storing the keys and values of this map, null when one or more inputs are invalid
-
getPositionOfOutputValueProperty
public int getPositionOfOutputValueProperty(OutputType outputType, OutputPropertyType outputValueProperty) throws PlanItException
Returns the position of a property type in the output values property array- Parameters:
outputType
- value of output type keyoutputValueProperty
- the output value property whose position is required- Returns:
- the position of the output value property
- Throws:
PlanItException
- thrown if the output property type is not in the output value property array
-
getPositionOfOutputKeyProperty
public int getPositionOfOutputKeyProperty(OutputType outputType, OutputPropertyType outputKeyProperty) throws PlanItException
Returns the position of a property type in the output key property array- Parameters:
outputType
- value of output type keyoutputKeyProperty
- the output key property whose position is required- Returns:
- the position of the output key property
- Throws:
PlanItException
- thrown if the output property type is not in the output key property array
-
-