Package org.planit.tntp.output.formatter
Class CSVOutputFormatter
- java.lang.Object
-
- org.planit.output.formatter.BaseOutputFormatter
-
- org.planit.output.formatter.FileOutputFormatter
-
- org.planit.output.formatter.CsvFileOutputFormatter
-
- org.planit.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.planit.output.formatter.CsvFileOutputFormatter
csvFileNameMap
-
Fields inherited from class org.planit.output.formatter.BaseOutputFormatter
id, initialCostsLocation, outputKeyProperties, outputTimeUnit, outputTypeKeysLocked, outputTypes, outputTypeValuesLocked, outputValueProperties
-
Fields inherited from interface org.planit.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 booleancanHandleMultipleIterations()Flag to indicate whether an implementation can handle multiple iterations If this returns false, acts as though OutputConfiguration.setPersistOnlyFinalIteration() is set to truevoidfinaliseAfterSimulation(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 typevoidinitialiseBeforeSimulation(OutputConfiguration outputConfiguration, long runId)Open output CSV file for specified output type configuration.voidsetCsvDirectory(String csvOutputDirectory)Sets the name of the CSAV output file directoryvoidsetCsvNameExtension(String csvNameExtension)Sets the extension of the CSV output filevoidsetCsvNameRoot(String csvNameRoot)Sets the root name of the CSV output fileprotected voidwriteGeneralResultsForCurrentTimePeriod(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 voidwriteLinkResultsForCurrentTimePeriod(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 voidwriteOdResultsForCurrentTimePeriod(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 voidwritePathResultsForCurrentTimePeriod(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 voidwriteSimulationResultsForCurrentTimePeriod(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.planit.output.formatter.CsvFileOutputFormatter
addCsvFileNamePerOutputType, openCsvFileAndWriteHeaders, writeLinkResultsForCurrentTimePeriodToCsvPrinter, writeOdResultsForCurrentTimePeriodToCsvPrinter, writePathResultsForCurrentTimePeriodToCsvPrinter
-
Methods inherited from class org.planit.output.formatter.FileOutputFormatter
generateOutputFileName, generateOutputFileName
-
Methods inherited from class org.planit.output.formatter.BaseOutputFormatter
getId, getOutputTimeUnit, getOutputTimeUnitString, lockOutputProperties, persist, setOutputTimeUnit
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.planit.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:
writeLinkResultsForCurrentTimePeriodin 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:
writeOdResultsForCurrentTimePeriodin 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:
writePathResultsForCurrentTimePeriodin 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:
writeGeneralResultsForCurrentTimePeriodin 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:
writeSimulationResultsForCurrentTimePeriodin 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:
finaliseAfterSimulationin 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:
initialiseBeforeSimulationin 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:
setCsvDirectoryin 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:
setCsvNameExtensionin 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:
setCsvNameRootin 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:
getCsvFileNamein 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:
canHandleMultipleIterationsin interfaceOutputFormatter- Returns:
- flag to indicate whether the OutputFormatter can handle multiple iterations
-
-