Class CSVOutputFormatter
- java.lang.Object
-
- org.goplanit.output.formatter.BaseOutputFormatter
-
- org.goplanit.output.formatter.FileOutputFormatter
-
- org.goplanit.output.formatter.CsvFileOutputFormatter
-
- org.goplanit.tntp.output.formatter.CSVOutputFormatter
-
- All Implemented Interfaces:
CsvTextFileOutputFormatter
,OutputFormatter
public class CSVOutputFormatter extends CsvFileOutputFormatter implements CsvTextFileOutputFormatter
Output formatter for CSV output, i.e. this class is capable of persisting output in the CSV data type- Author:
- markr
-
-
Field Summary
-
Fields inherited from class org.goplanit.output.formatter.CsvFileOutputFormatter
csvFileNameMap
-
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 CSVOutputFormatter(IdGroupingToken groupId)
Base 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 output CSV file for a specified output type configurationList<String>
getCsvFileName(OutputType outputType)
Returns the name of the CSV output file for a specified output typevoid
initialiseBeforeSimulation(OutputConfiguration outputConfiguration, long runId)
Open output CSV file for specified output type configuration.void
setCsvDirectory(String csvOutputDirectory)
Sets the name of the CSAV output file directoryvoid
setCsvNameExtension(String csvNameExtension)
Sets the extension of the CSV output filevoid
setCsvNameRoot(String csvNameRoot)
Sets the root name of the CSV output fileprotected 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 the CSV fileprotected 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 CSV fileprotected 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.CsvFileOutputFormatter
addCsvFileNamePerOutputType, openCsvFileAndWriteHeaders, writeLinkResultsForCurrentTimePeriodToCsvPrinter, writeOdResultsForCurrentTimePeriodToCsvPrinter, writePathResultsForCurrentTimePeriodToCsvPrinter
-
Methods inherited from class org.goplanit.output.formatter.FileOutputFormatter
generateOutputFileName, generateOutputFileName
-
Methods inherited from class org.goplanit.output.formatter.BaseOutputFormatter
getId, lockOutputProperties, persist
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.goplanit.output.formatter.CsvTextFileOutputFormatter
addCsvFileNamePerOutputType
-
-
-
-
Constructor Detail
-
CSVOutputFormatter
public CSVOutputFormatter(IdGroupingToken groupId) throws PlanItException
Base constructor- Parameters:
groupId
- contiguous id generation within this group for instances of this class- Throws:
PlanItException
- thrown if there is an error
-
-
Method Detail
-
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 the CSV file- Specified by:
writeLinkResultsForCurrentTimePeriod
in classBaseOutputFormatter
- Parameters:
outputConfiguration
- output configurationoutputTypeConfiguration
- OutputTypeConfiguration for current persistencecurrentOutputType
- active OutputTypeEnum of the configuration we are persisting for (can be a SubOutputTypeEnum or an OutputType)outputAdapter
- OutputAdapter for current persistencemodes
- Set of modes of traveltimePeriod
- current time perioditerationIndex
- current iteration index- 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 CSV file- Specified by:
writeOdResultsForCurrentTimePeriod
in classBaseOutputFormatter
- Parameters:
outputConfiguration
- output configurationoutputTypeConfiguration
- OutputTypeConfiguration for current persistencecurrentOutputType
- active OutputTypeEnum of the configuration we are persisting for (can be a SubOutputTypeEnum or an OutputType)outputAdapter
- OutputAdapter for current persistencemodes
- Set of modes of traveltimePeriod
- current time perioditerationIndex
- current iteration index- 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
- output configurationoutputTypeConfiguration
- OutputTypeConfiguration for current persistencecurrentOutputType
- active OutputTypeEnum of the configuration we are persisting for (can be a SubOutputTypeEnum or an OutputType)outputAdapter
- OutputAdapter for current persistencemodes
- Set of modes of traveltimePeriod
- current time perioditerationIndex
- current iteration index- 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
- active OutputTypeEnum of the configuration we are persisting for (can be a SubOutputTypeEnum or an OutputType)outputAdapter
- OutputAdapter for current persistencemodes
- Set of modes of traveltimePeriod
- current time perioditerationIndex
- current iteration index- Throws:
PlanItException
- thrown if there is an error
-
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
- active OutputTypeEnum of the configuration we are persisting for (can be a SubOutputTypeEnum or an OutputType)outputAdapter
- OutputAdapter for current persistencemodes
- Set of modes of traveltimePeriod
- current time perioditerationIndex
- current iteration index- Throws:
PlanItException
- thrown if there is an error
-
finaliseAfterSimulation
public void finaliseAfterSimulation(OutputConfiguration outputConfiguration, OutputAdapter outputAdapter) throws PlanItException
Close output CSV file for a specified output type configuration- Specified by:
finaliseAfterSimulation
in interfaceOutputFormatter
- Parameters:
outputConfiguration
- OutputConfiguration of the assignmentoutputAdapter
- the outputAdapter- Throws:
PlanItException
- thrown if the the output file cannot be closed
-
initialiseBeforeSimulation
public void initialiseBeforeSimulation(OutputConfiguration outputConfiguration, long runId) throws PlanItException
Open output CSV file for specified output type configuration. This method also creates the output file directory if it does not already exist.- Specified by:
initialiseBeforeSimulation
in interfaceOutputFormatter
- Parameters:
outputConfiguration
- OutputConfiguration of the assignmentrunId
- the id number of the run- Throws:
PlanItException
- thrown if output file or directory cannot be opened
-
setCsvDirectory
public void setCsvDirectory(String csvOutputDirectory)
Sets the name of the CSAV output file directory- Specified by:
setCsvDirectory
in interfaceCsvTextFileOutputFormatter
- Parameters:
csvOutputDirectory
- the name of the output file directory
-
setCsvNameExtension
public void setCsvNameExtension(String csvNameExtension)
Sets the extension of the CSV output file- Specified by:
setCsvNameExtension
in interfaceCsvTextFileOutputFormatter
- Parameters:
csvNameExtension
- the extension of the CSV output file
-
setCsvNameRoot
public void setCsvNameRoot(String csvNameRoot)
Sets the root name of the CSV output file- Specified by:
setCsvNameRoot
in interfaceCsvTextFileOutputFormatter
- Parameters:
csvNameRoot
- root name of CSV output file
-
getCsvFileName
public List<String> getCsvFileName(OutputType outputType)
Returns the name of the CSV output file for a specified output type- Specified by:
getCsvFileName
in interfaceCsvTextFileOutputFormatter
- Parameters:
outputType
- the specified output type- Returns:
- the name of the output file
-
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- Specified by:
canHandleMultipleIterations
in interfaceOutputFormatter
- Returns:
- flag to indicate whether the OutputFormatter can handle multiple iterations
-
-