Class SimulationReporter


  • public class SimulationReporter
    extends java.lang.Object
    This class facilitates simulation output reporting. There are two main reporting functions: within replication statistics and across replication statistics. To collect within replication statistics you must use turnOnReplicationCSVStatisticalReporting() before running the simulation. This needs to be done before the simulation is run because the statistics are collected after each replication is completed. This method attaches a CSVReplicationReport to the model for collection purposes. If the simulation is run multiple times, then statistical data continues to be observed by the CSVReplicationReport. Thus, data across many experiments can be captured in this manner. This produces a comma separated value file containing all end of replication statistical summaries for every counter and response variable in the model. There are a number of options available if you want to capture across replication statistics. 1) turnOnAcrossReplicationCSVStatisticReporting() - This should be done before running the simulation. It uses a CSVExperimentReport to observe a model. This produces a comma separated value file containing all across replication statistical summaries for every counter and response variable in the model. 2) Use any of the writeAcrossReplicationX() methods. These methods will write across replication summary statistics to files, standard output, LaTeX, CSV, etc.
    • Constructor Detail

      • SimulationReporter

        public SimulationReporter​(Simulation sim)
    • Method Detail

      • getSimulation

        protected final Simulation getSimulation()
      • getModel

        protected final Model getModel()
      • getResponseVariables

        protected final java.util.List<ResponseVariable> getResponseVariables()
        A convenience method for sub-classes. Gets the response variables from the model
        Returns:
        the list
      • getCounters

        protected final java.util.List<Counter> getCounters()
        A convenience method for sub-classes. Gets the counters from the model
        Returns:
        the list
      • getAcrossReplicationCSVStatistics

        public java.lang.StringBuilder getAcrossReplicationCSVStatistics()
        Uses a StringBuilder to hold the across replication statistics formatted as a comma separated values with an appropriate header
        Returns:
        the string builder
      • writeAcrossReplicationCSVStatistics

        public final void writeAcrossReplicationCSVStatistics​(java.io.PrintWriter out)
        Writes the across replication statistics to the supplied PrintWriter as comma separated value output
        Parameters:
        out - the PrintWriter
      • writeFullAcrossReplicationStatistics

        public final void writeFullAcrossReplicationStatistics​(java.io.PrintWriter out)
        Writes the full across replication statistics to the supplied PrintWriter as text output. Full means all statistical quantities are printed for every statistic
        Parameters:
        out - the PrintWriter
      • writeAcrossReplicationSummaryStatistics

        public final void writeAcrossReplicationSummaryStatistics​(java.io.PrintWriter out)
        Writes shortened across replication statistics to the supplied PrintWriter as text output Response Name Average Std. Dev.
        Parameters:
        out - the PrintWriter
      • getAcrossReplicationStatistics

        public final java.lang.StringBuilder getAcrossReplicationStatistics()
        Returns a StringBuilder with across replication statistics
        Returns:
        the StringBuilder
      • getAcrossReplicationStatisticsList

        public final java.util.List<StatisticAccessorIfc> getAcrossReplicationStatisticsList()
        Gets the across replication statistics as a list
        Returns:
        a list filled with the across replication statistics
      • fillAcrossReplicationStatistics

        public final void fillAcrossReplicationStatistics​(java.util.List<StatisticAccessorIfc> list)
        Fills the supplied list with the across replication statistics
        Parameters:
        list - the list to fill
      • fillResponseVariableReplicationStatistics

        public final void fillResponseVariableReplicationStatistics​(java.util.List<StatisticAccessorIfc> list)
        Fills the list with across replication statistics from the response variables (ResponseVariable and TimeWeighted).
        Parameters:
        list - the list to fill
      • fillCounterAcrossReplicationStatistics

        public final void fillCounterAcrossReplicationStatistics​(java.util.List<StatisticAccessorIfc> list)
        Fills the list with across replication statistics from the Counters
        Parameters:
        list - the list to fill
      • getAcrossReplicationStatistics

        public final void getAcrossReplicationStatistics​(java.lang.StringBuilder sb)
        Fills the StringBuilder with across replication statistics
        Parameters:
        sb - the StringBuilder to fill
      • printAcrossReplicationCSVStatistics

        public final void printAcrossReplicationCSVStatistics()
        Writes the across replication statistics as comma separated values to System.out
      • writeAcrossReplicationCSVStatistics

        public final java.io.PrintWriter writeAcrossReplicationCSVStatistics​(java.nio.file.Path pathToFile)
        Creates a PrintWriter with the supplied name in directory jslOutput and writes out the across replication statistics
        Parameters:
        pathToFile - the Path to the file
        Returns:
        the PrintWriter
      • writeAcrossReplicationCSVStatistics

        public final java.io.PrintWriter writeAcrossReplicationCSVStatistics​(java.lang.String fName)
        Creates a PrintWriter with the supplied name in directory jslOutput and writes out the across replication statistics
        Parameters:
        fName - the file name
        Returns:
        the PrintWriter
      • writeFullAcrossReplicationStatistics

        public final java.io.PrintWriter writeFullAcrossReplicationStatistics​(java.nio.file.Path pathToFile)
        Creates a PrintWriter with the supplied path and writes the full statistics to the file. Full means all detailed statistical quantities for every statistic.
        Parameters:
        pathToFile - the path to the file
        Returns:
        the PrintWriter
      • writeFullAcrossReplicationStatistics

        public final java.io.PrintWriter writeFullAcrossReplicationStatistics​(java.lang.String fName)
        Creates a PrintWriter with the supplied name in directory jslOutput and writes out the across replication statistics. Full means all statistical quantities are printed for every statistic
        Parameters:
        fName - the file name
        Returns:
        the PrintWriter
      • printFullAcrossReplicationStatistics

        public final void printFullAcrossReplicationStatistics()
        Writes the across replication statistics as text values to System.out
      • printAcrossReplicationSummaryStatistics

        public final void printAcrossReplicationSummaryStatistics()
        Writes the across replication statistics as text values to System.out
      • writeAcrossReplicationSummaryStatistics

        public final java.io.PrintWriter writeAcrossReplicationSummaryStatistics​(java.nio.file.Path pathToFile)
        Creates a PrintWriter with the supplied name in directory within jslOutput and writes out the across replication statistics
        Parameters:
        pathToFile - the path to the file
        Returns:
        the PrintWriter
      • writeAcrossReplicationSummaryStatistics

        public final java.io.PrintWriter writeAcrossReplicationSummaryStatistics​(java.lang.String fName)
        Creates a PrintWriter with the supplied name in directory jslOutput and writes out the across replication statistics
        Parameters:
        fName - the file name
        Returns:
        the PrintWriter
      • turnOnReplicationCSVStatisticReporting

        public final void turnOnReplicationCSVStatisticReporting()
        Attaches a CSVReplicationReport to the model to record within replication statistics to a file
      • turnOnReplicationCSVStatisticReporting

        public final void turnOnReplicationCSVStatisticReporting​(java.lang.String name)
        Attaches a CSVReplicationReport to the model to record within replication statistics to a file
        Parameters:
        name - the report file name
      • turnOffReplicationCSVStatisticReporting

        public final void turnOffReplicationCSVStatisticReporting()
        Detaches a CSVReplicationReport from the model
      • writeAcrossReplicationSummaryStatisticsAsLaTeX

        public final void writeAcrossReplicationSummaryStatisticsAsLaTeX​(java.io.PrintWriter out)
        Writes shortened across replication statistics to the supplied PrintWriter as text output in LaTeX document form Response Name Average Std. Dev.
        Parameters:
        out - the PrintWriter to write to
      • writeAcrossReplicationSummaryStatisticsAsLaTeX

        public final java.io.PrintWriter writeAcrossReplicationSummaryStatisticsAsLaTeX​(java.nio.file.Path pathToFile)
        Creates a PrintWriter using the supplied path and writes out the across replication statistics as a LaTeX file
        Parameters:
        pathToFile - the path to the file
        Returns:
        the PrintWriter
      • writeAcrossReplicationSummaryStatisticsAsLaTeX

        public final java.io.PrintWriter writeAcrossReplicationSummaryStatisticsAsLaTeX​(java.lang.String fName)
        Creates a file with the supplied name in the simulation's output directory with the results as a LaTeX table.
        Parameters:
        fName - the file name
        Returns:
        the PrintWriter
      • writeAcrossReplicationSummaryStatisticsAsLaTeX

        public final java.io.PrintWriter writeAcrossReplicationSummaryStatisticsAsLaTeX()
        Creates a file with name getSimulation().getName() + "_LaTeX_Across_Replication_Summary.tex" in the simulation's output directory with the results as a LaTeX table.
        Returns:
        the PrintWriter
      • getAcrossReplicationStatisticsAsLaTeXTables

        public final java.util.List<java.lang.StringBuilder> getAcrossReplicationStatisticsAsLaTeXTables()
        List of StringBuilder representing LaTeX tables max 60 rows
        Returns:
        the tables as StringBuilders
      • getAcrossReplicationStatisticsAsLaTeXTables

        public final java.util.List<java.lang.StringBuilder> getAcrossReplicationStatisticsAsLaTeXTables​(int maxRows)
        List of StringBuilder representing LaTeX tables
        Parameters:
        maxRows - the maximum number of rows
        Returns:
        the tables as StringBuilders
      • getAcrossReplicationStatisticsAsLaTeXDocument

        public final java.lang.StringBuilder getAcrossReplicationStatisticsAsLaTeXDocument()
        Returns a StringBuilder representation of the across replication statistics as a LaTeX document with max number of rows = 60
        Returns:
        the tables as StringBuilders
      • getAcrossReplicationStatisticsAsLaTeXDocument

        public final java.lang.StringBuilder getAcrossReplicationStatisticsAsLaTeXDocument​(int maxRows)
        Returns a StringBuilder representation of the across replication statistics as a LaTeX document
        Parameters:
        maxRows - maximum number of rows in each table
        Returns:
        the StringBuilder
      • getAcrossReplicationStatisticsAsLaTeXTabular

        public final java.util.List<java.lang.StringBuilder> getAcrossReplicationStatisticsAsLaTeXTabular()
        Gets shortened across replication statistics for response variables as a LaTeX tabular. Each StringBuilder in the list represents a tabular with a maximum number of 60 rows Response Name Average Std. Dev.
        Returns:
        a List of StringBuilders
      • getAcrossReplicationStatisticsAsLaTeXTabular

        public final java.util.List<java.lang.StringBuilder> getAcrossReplicationStatisticsAsLaTeXTabular​(int maxRows)
        Gets shortened across replication statistics for response variables as a LaTeX tabular. Each StringBuilder in the list represents a tabular with a maximum number of rows Response Name Average Std. Dev.
        Parameters:
        maxRows - maximum number of rows in each tabular
        Returns:
        a List of StringBuilders
      • turnOnAcrossReplicationCSVStatisticReporting

        public final void turnOnAcrossReplicationCSVStatisticReporting()
        Attaches a CSVExperimentReport to the model to record across replication statistics to a file
      • turnOnAcrossReplicationCSVStatisticReporting

        public final void turnOnAcrossReplicationCSVStatisticReporting​(java.lang.String name)
        Attaches a CSVExperimentReport to the model to record across replication statistics to a file
        Parameters:
        name - the file name of the report
      • turnOffAcrossReplicationStatisticReporting

        public final void turnOffAcrossReplicationStatisticReporting()
        Detaches a CSVExperimentReport from the model
      • printAcrossReplicationHalfWidthSummaryReport

        public final void printAcrossReplicationHalfWidthSummaryReport()
        Prints a half-width summary report for the across replication statistics to System.out
      • writeAcrossReplicationHalfWidthSummaryReport

        public final void writeAcrossReplicationHalfWidthSummaryReport​(java.io.PrintWriter out)
        Writes a half-width summary report for the across replication statistics
        Parameters:
        out - the writer to write to
      • getAcrossReplicationStatisticReporter

        public final StatisticReporter getAcrossReplicationStatisticReporter()
        Returns:
        a StatisticReporter holding the across replication statistics for reporting