CSVExporter

class CSVExporter<T, P : Position<P>> @JvmOverloads constructor(fileNameRoot: String = "", val interval: Double = DEFAULT_INTERVAL, val exportPath: String = createTempDirectory("alchemist-export").absolutePathString() .also { logger.warn("No output folder specified but export required. Alchemist will export data in $it") }, val fileExtension: String = "csv", appendTime: Boolean = false) : AbstractExporter<T, P>

Writes on file data provided by a number of {@link Extractor}s. Produces a CSV with '#' as comment character.e

Parameters

fileNameRoot

the starting name of the file to export data to.

interval

the sampling time, defaults to AbstractExporter.DEFAULT_INTERVAL.

exportPath

if no path is specified it will generate the file inside a temporary folder.

appendTime

if true it will always generate a new file, false to overwrite.

fileExtension

the extension for the exported files, by default 'csv'

Constructors

Link copied to clipboard
constructor(fileNameRoot: String = "", interval: Double = DEFAULT_INTERVAL, exportPath: String = createTempDirectory("alchemist-export").absolutePathString() .also { logger.warn("No output folder specified but export required. Alchemist will export data in $it") }, fileExtension: String = "csv", appendTime: Boolean = false)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
lateinit override var dataExtractors: List<Extractor<*>>

The List of Extractor used to export simulations data.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
override fun bindDataExtractors(dataExtractors: List<Extractor<*>>)

Assign the list of dataExtractors to the selected Exporter.

Link copied to clipboard
override fun bindVariables(variables: Map<String, *>)

Assign the map of variables to the selected Exporter.

Link copied to clipboard
open override fun close(environment: Environment<T, P>, time: Time, step: Long)

Close the export environment. This method is called when the simulation finishes.

Link copied to clipboard
open override fun exportData(environment: Environment<T, P>, reaction: Actionable<T>?, time: Time, step: Long)

Delegates the concrete implementation of this method to his subclasses.

Link copied to clipboard
open override fun setup(environment: Environment<T, P>)

Prepare the export environment. This method is called only once upon simulation initialization.

Link copied to clipboard
override fun update(environment: Environment<T, P>, reaction: Actionable<T>?, time: Time, step: Long)

Every step of the simulation check if is time to export data depending on the sampling interval. Converts the division of the current time and the interval to Long in order to export data only when the difference between steps is as big as the sampling interval.