Provides reporting services on model output data and time values

Namespace:  iseesystems.iseeNET
Assembly:  iseesystems.iseeNET.Simulation (in iseesystems.iseeNET.Simulation.dll) Version: 1.0.3315.21357

Syntax

C#
public abstract class ProvidesReporting : List<double>
Visual Basic (Declaration)
Public MustInherit Class ProvidesReporting _
	Inherits List(Of Double)
Visual C++
public ref class ProvidesReporting abstract : public List<double>

Examples

CopyC#
public void transformOutputData()
{
    sim.ResetAllRuns();
    if (sim.TimeSpecs.DT != .25) changeDT(.25);

    sim.Run(); /* Run one step */

    double reportInterval = .25;

    /* First just get the raw values */
    OutputValues anotherFlowValues = sim.GetOutput("another_flow").ValuesForRun[1];
    OutputValues flowValues = sim.GetOutput("depositing").ValuesForRun[1];
    OutputValues stockValues = sim.GetOutput("Bank_Balance").ValuesForRun[1];
    OutputValues converterValues = sim.GetOutput("converter").ValuesForRun[1];

    double[] flowValuesReported;
    double[] anotherFlowValuesReported;
    double[] stockValuesReported;
    double[] converterValuesReported;

    /* 
     * --------------------------------------------
     * Case 1: Beginning balances, inst flow values 
     * --------------------------------------------
     */
    Simulation.ReportingOptions reportFlags = Simulation.ReportingOptions.BEGINNING_BALANCES | Simulation.ReportingOptions.C_TO_F;

    flowValuesReported = flowValues.Report(reportInterval, reportFlags);
    anotherFlowValuesReported = anotherFlowValues.Report(reportInterval, reportFlags);
    stockValuesReported = stockValues.Report(reportInterval, reportFlags);
    converterValuesReported = converterValues.Report(reportInterval, reportFlags);

    /* --- depositing --- */
    Assert.That(flowValuesReported[0] == 10);
    Assert.That(flowValuesReported[1] == 10);
    Assert.That(flowValuesReported[2] == 10);
    Assert.That(flowValuesReported[3] == 10);
    Assert.That(Double.IsNaN(flowValuesReported[4]));

    /* --- another flow --- */
    Assert.That(anotherFlowValuesReported[0] == 1);
    Assert.That(anotherFlowValuesReported[1] == 1);
    Assert.That(anotherFlowValuesReported[2] == 1);
    Assert.That(anotherFlowValuesReported[3] == 1);
    Assert.That(Double.IsNaN(anotherFlowValuesReported[4]));

    /* --- Bank Balance --- */
    Assert.That(stockValuesReported[0] == 0);
    Assert.That(stockValuesReported[1] == 2.5);
    Assert.That(stockValuesReported[2] == 5);
    Assert.That(stockValuesReported[3] == 7.5);
    Assert.That(stockValuesReported[4] == 10);

    /* --- conveter --- */
    Assert.That(converterValuesReported[0] == 10);
    Assert.That(converterValuesReported[1] == 10);
    Assert.That(converterValuesReported[2] == 10);
    Assert.That(converterValuesReported[3] == 10);
    Assert.That(Double.IsNaN(converterValuesReported[4]));

    /* 
     * --------------------------------------------
     * Case 2: Ending balances, inst flow values 
     * --------------------------------------------
     */
    reportFlags = Simulation.ReportingOptions.ENDING_BALANCES | Simulation.ReportingOptions.C_TO_F;

    flowValuesReported = flowValues.Report(reportInterval, reportFlags);
    anotherFlowValuesReported = anotherFlowValues.Report(reportInterval, reportFlags);
    stockValuesReported = stockValues.Report(reportInterval, reportFlags);
    converterValuesReported = converterValues.Report(reportInterval, reportFlags);

    /* --- depositing --- */
    Assert.That(Double.IsNaN(flowValuesReported[0]));
    Assert.That(flowValuesReported[1] == 10);
    Assert.That(flowValuesReported[2] == 10);
    Assert.That(flowValuesReported[3] == 10);
    Assert.That(flowValuesReported[4] == 10);

    /* --- another flow --- */
    Assert.That(Double.IsNaN(anotherFlowValuesReported[0]));
    Assert.That(anotherFlowValuesReported[1] == 1);
    Assert.That(anotherFlowValuesReported[2] == 1);
    Assert.That(anotherFlowValuesReported[3] == 1);
    Assert.That(anotherFlowValuesReported[4] == 1);

    /* --- Bank Balance --- */
    Assert.That(stockValuesReported[0] == 0);
    Assert.That(stockValuesReported[1] == 2.5);
    Assert.That(stockValuesReported[2] == 5);
    Assert.That(stockValuesReported[3] == 7.5);
    Assert.That(stockValuesReported[4] == 10);

    /* --- conveter --- */
    Assert.That(Double.IsNaN(converterValuesReported[0]));
    Assert.That(converterValuesReported[1] == 10);
    Assert.That(converterValuesReported[2] == 10);
    Assert.That(converterValuesReported[3] == 10);
    Assert.That(converterValuesReported[4] == 10);

    /* 
     * ------------------------------------------------
     * Case 3: Beginning balances, summed flow values 
     * ------------------------------------------------
     */
    reportFlags = Simulation.ReportingOptions.BEGINNING_BALANCES | Simulation.ReportingOptions.C_TO_F | Simulation.ReportingOptions.SUMMED_FLOWS;

    flowValuesReported = flowValues.Report(reportInterval, reportFlags);
    anotherFlowValuesReported = anotherFlowValues.Report(reportInterval, reportFlags);
    stockValuesReported = stockValues.Report(reportInterval, reportFlags);
    converterValuesReported = converterValues.Report(reportInterval, reportFlags);

    /* --- depositing --- */
    Assert.That(flowValuesReported[0] == 2.5);
    Assert.That(flowValuesReported[1] == 2.5);
    Assert.That(flowValuesReported[2] == 2.5);
    Assert.That(flowValuesReported[3] == 2.5);
    Assert.That(Double.IsNaN(flowValuesReported[4]));

    /* --- another flow --- */
    Assert.That(anotherFlowValuesReported[0] == .25);
    Assert.That(anotherFlowValuesReported[1] == .25);
    Assert.That(anotherFlowValuesReported[2] == .25);
    Assert.That(anotherFlowValuesReported[3] == .25);
    Assert.That(Double.IsNaN(anotherFlowValuesReported[4]));

    /* --- Bank Balance --- */
    Assert.That(stockValuesReported[0] == 0);
    Assert.That(stockValuesReported[1] == 2.5);
    Assert.That(stockValuesReported[2] == 5);
    Assert.That(stockValuesReported[3] == 7.5);
    Assert.That(stockValuesReported[4] == 10);

    /* --- conveter --- */
    Assert.That(converterValuesReported[0] == 2.5);
    Assert.That(converterValuesReported[1] == 2.5);
    Assert.That(converterValuesReported[2] == 2.5);
    Assert.That(converterValuesReported[3] == 2.5);
    Assert.That(Double.IsNaN(converterValuesReported[4]));

    /* 
    * ------------------------------------------------
    * Case 4: Ending balances, summed flow values 
    * ------------------------------------------------
    */
    reportFlags = Simulation.ReportingOptions.ENDING_BALANCES | Simulation.ReportingOptions.C_TO_F | Simulation.ReportingOptions.SUMMED_FLOWS;

    flowValuesReported = flowValues.Report(reportInterval, reportFlags);
    anotherFlowValuesReported = anotherFlowValues.Report(reportInterval, reportFlags);
    stockValuesReported = stockValues.Report(reportInterval, reportFlags);
    converterValuesReported = converterValues.Report(reportInterval, reportFlags);

    /* --- depositing --- */
    Assert.That(Double.IsNaN(flowValuesReported[0]));
    Assert.That(flowValuesReported[1] == 2.5);
    Assert.That(flowValuesReported[2] == 2.5);
    Assert.That(flowValuesReported[3] == 2.5);
    Assert.That(flowValuesReported[4] == 2.5);

    /* --- another flow --- */
    Assert.That(Double.IsNaN(anotherFlowValuesReported[0]));
    Assert.That(anotherFlowValuesReported[1] == .25);
    Assert.That(anotherFlowValuesReported[2] == .25);
    Assert.That(anotherFlowValuesReported[3] == .25);
    Assert.That(anotherFlowValuesReported[4] == .25);

    /* --- Bank Balance --- */
    Assert.That(stockValuesReported[0] == 0);
    Assert.That(stockValuesReported[1] == 2.5);
    Assert.That(stockValuesReported[2] == 5);
    Assert.That(stockValuesReported[3] == 7.5);
    Assert.That(stockValuesReported[4] == 10);

    /* --- conveter --- */
    Assert.That(Double.IsNaN(converterValuesReported[0]));
    Assert.That(converterValuesReported[1] == 2.5);
    Assert.That(converterValuesReported[2] == 2.5);
    Assert.That(converterValuesReported[3] == 2.5);
    Assert.That(converterValuesReported[4] == 2.5);
}

public void formatModelData()
{
    sim.ResetAllRuns();
    if (sim.TimeSpecs.DT != .25) changeDT(.25);

    sim.Run(); /* Run one step */

    double reportInterval = .25;

    /* First just get the raw values */
    OutputValues anotherFlowValues = sim.GetOutput("another_flow").ValuesForRun[1];
    OutputValues flowValues = sim.GetOutput("depositing").ValuesForRun[1];
    OutputValues stockValues = sim.GetOutput("Bank_Balance").ValuesForRun[1];
    OutputValues converterValues = sim.GetOutput("converter").ValuesForRun[1];

    string[] flowValuesFormatted;
    string[] anotherFlowValuesFormatted;
    string[] stockValuesFormatted;
    string[] converterValuesFormatted;

    /* 
     * --------------------------------------------
     * Test for blank formatting where NaNs are present
     * --------------------------------------------
     */

    FormatOptions options = new FormatOptions();
    options.BalanceReporting = FormatOptions.BalanceOptions.BEGINNING_BALANCES;
    options.Precision = FormatOptions.PrecisionOptions.TWO;
    options.ReportDecimals = true;
    options.Scaling = FormatOptions.ScalingOptions.NONE;
    options.Units = FormatOptions.UnitOptions.UNSPECIFIED;

    Simulation.ReportingOptions reportFlags = Simulation.ReportingOptions.BEGINNING_BALANCES | Simulation.ReportingOptions.C_TO_F;

    flowValuesFormatted = flowValues.ReportAndFormat(1, reportInterval, reportFlags, options);
    anotherFlowValuesFormatted = anotherFlowValues.ReportAndFormat(1, reportInterval, reportFlags, options);
    stockValuesFormatted = stockValues.ReportAndFormat(1, reportInterval, reportFlags, options);
    converterValuesFormatted = converterValues.ReportAndFormat(1, reportInterval, reportFlags, options);

    /* --- depositing --- */
    Assert.That(flowValuesFormatted[0] == "10.00");
    Assert.That(flowValuesFormatted[1] == "10.00");
    Assert.That(flowValuesFormatted[2] == "10.00");
    Assert.That(flowValuesFormatted[3] == "10.00");
    Assert.That(flowValuesFormatted[4] == "");

    /* --- another flow --- */
    Assert.That(anotherFlowValuesFormatted[0] == "1.00");
    Assert.That(anotherFlowValuesFormatted[1] == "1.00");
    Assert.That(anotherFlowValuesFormatted[2] == "1.00");
    Assert.That(anotherFlowValuesFormatted[3] == "1.00");
    Assert.That(anotherFlowValuesFormatted[4] == "");

    /* --- Bank Balance --- */
    Assert.That(stockValuesFormatted[0] == "0.00");
    Assert.That(stockValuesFormatted[1] == "2.50");
    Assert.That(stockValuesFormatted[2] == "5.00");
    Assert.That(stockValuesFormatted[3] == "7.50");
    Assert.That(stockValuesFormatted[4] == "10.00");

    /* --- conveter --- */
    Assert.That(converterValuesFormatted[0] == "10.00");
    Assert.That(converterValuesFormatted[1] == "10.00");
    Assert.That(converterValuesFormatted[2] == "10.00");
    Assert.That(converterValuesFormatted[3] == "10.00");
    Assert.That(converterValuesFormatted[4] == "");


    /*
     * ----------------------------------------
     *  Test for currency
     * ----------------------------------------
     */

    options.Units = FormatOptions.UnitOptions.CURRENCY;
    reportFlags = Simulation.ReportingOptions.BEGINNING_BALANCES | Simulation.ReportingOptions.C_TO_F;

    flowValuesFormatted = flowValues.ReportAndFormat(1, reportInterval, reportFlags, options);
    anotherFlowValuesFormatted = anotherFlowValues.ReportAndFormat(1, reportInterval, reportFlags, options);
    stockValuesFormatted = stockValues.ReportAndFormat(1, reportInterval, reportFlags, options);
    converterValuesFormatted = converterValues.ReportAndFormat(1, reportInterval, reportFlags, options);

    /* --- depositing --- */
    Assert.That(flowValuesFormatted[0] == "$10.00");
    Assert.That(flowValuesFormatted[1] == "$10.00");
    Assert.That(flowValuesFormatted[2] == "$10.00");
    Assert.That(flowValuesFormatted[3] == "$10.00");
    Assert.That(flowValuesFormatted[4] == "");

    /* --- another flow --- */
    Assert.That(anotherFlowValuesFormatted[0] == "$1.00");
    Assert.That(anotherFlowValuesFormatted[1] == "$1.00");
    Assert.That(anotherFlowValuesFormatted[2] == "$1.00");
    Assert.That(anotherFlowValuesFormatted[3] == "$1.00");
    Assert.That(anotherFlowValuesFormatted[4] == "");

    /* --- Bank Balance --- */
    Assert.That(stockValuesFormatted[0] == "$0.00");
    Assert.That(stockValuesFormatted[1] == "$2.50");
    Assert.That(stockValuesFormatted[2] == "$5.00");
    Assert.That(stockValuesFormatted[3] == "$7.50");
    Assert.That(stockValuesFormatted[4] == "$10.00");

    /* --- conveter --- */
    Assert.That(converterValuesFormatted[0] == "$10.00");
    Assert.That(converterValuesFormatted[1] == "$10.00");
    Assert.That(converterValuesFormatted[2] == "$10.00");
    Assert.That(converterValuesFormatted[3] == "$10.00");
    Assert.That(converterValuesFormatted[4] == "");

    /*
     * ----------------------------------------
     *  Test for %
     * ----------------------------------------
     */

    options.Units = FormatOptions.UnitOptions.PCT;
    reportFlags = Simulation.ReportingOptions.BEGINNING_BALANCES | Simulation.ReportingOptions.C_TO_F;

    flowValuesFormatted = flowValues.ReportAndFormat(1, reportInterval, reportFlags, options);
    anotherFlowValuesFormatted = anotherFlowValues.ReportAndFormat(1, reportInterval, reportFlags, options);
    stockValuesFormatted = stockValues.ReportAndFormat(1, reportInterval, reportFlags, options);
    converterValuesFormatted = converterValues.ReportAndFormat(1, reportInterval, reportFlags, options);

    /* --- depositing --- */
    Assert.That(flowValuesFormatted[0] == "10%");
    Assert.That(flowValuesFormatted[1] == "10%");
    Assert.That(flowValuesFormatted[2] == "10%");
    Assert.That(flowValuesFormatted[3] == "10%");
    Assert.That(flowValuesFormatted[4] == "");

    /* --- another flow --- */
    Assert.That(anotherFlowValuesFormatted[0] == "1%");
    Assert.That(anotherFlowValuesFormatted[1] == "1%");
    Assert.That(anotherFlowValuesFormatted[2] == "1%");
    Assert.That(anotherFlowValuesFormatted[3] == "1%");
    Assert.That(anotherFlowValuesFormatted[4] == "");

    /* --- Bank Balance --- */
    Assert.That(stockValuesFormatted[0] == "0%");
    Assert.That(stockValuesFormatted[1] == "3%");
    Assert.That(stockValuesFormatted[2] == "5%");
    Assert.That(stockValuesFormatted[3] == "8%");
    Assert.That(stockValuesFormatted[4] == "10%");

    /* --- conveter --- */
    Assert.That(converterValuesFormatted[0] == "10%");
    Assert.That(converterValuesFormatted[1] == "10%");
    Assert.That(converterValuesFormatted[2] == "10%");
    Assert.That(converterValuesFormatted[3] == "10%");
    Assert.That(converterValuesFormatted[4] == "");


    /* Will a value that is impossible in the model survive formatting? */
    string[] divideByZeroFormatted = sim.GetOutput("divide_by_zero").ValuesForRun[1].ReportAndFormat(1, reportInterval, reportFlags, options);
    string[] logZeroFormatted = sim.GetOutput("log_zero").ValuesForRun[1].ReportAndFormat(1, reportInterval, reportFlags, options);
    string[] sqrtNegOneFormatted = sim.GetOutput("square_of_neg_one").ValuesForRun[1].ReportAndFormat(1, reportInterval, reportFlags, options);

    Assert.That(divideByZeroFormatted[0] == "?");
    Assert.That(divideByZeroFormatted[1] == "?");
    Assert.That(divideByZeroFormatted[2] == "?");
    Assert.That(divideByZeroFormatted[3] == "?");
    Assert.That(divideByZeroFormatted[4] == "");

    Assert.That(logZeroFormatted[0] == "?");
    Assert.That(logZeroFormatted[1] == "?");
    Assert.That(logZeroFormatted[2] == "?");
    Assert.That(logZeroFormatted[3] == "?");
    Assert.That(logZeroFormatted[4] == "");

    Assert.That(sqrtNegOneFormatted[0] == "?");
    Assert.That(sqrtNegOneFormatted[1] == "?");
    Assert.That(sqrtNegOneFormatted[2] == "?");
    Assert.That(sqrtNegOneFormatted[3] == "?");
    Assert.That(sqrtNegOneFormatted[4] == "");

    /* Test scaling */
    options.Scaling = FormatOptions.ScalingOptions.BILLIONS;
    options.Precision = FormatOptions.PrecisionOptions.TWO;
    options.Units = FormatOptions.UnitOptions.DELIMIT_THOUSANDS;

    string[] scalingFormatted = sim.GetOutput("Scale_Me").ValuesForRun[1].ReportAndFormat(1, reportInterval, reportFlags, options);
    Assert.That(scalingFormatted[0] == "0.00");
    Assert.That(scalingFormatted[1] == "0.00");
    Assert.That(scalingFormatted[2] == "0.63");
    Assert.That(scalingFormatted[3] == "158.13");
    Assert.That(scalingFormatted[4] == "39,691.26");
}

Inheritance Hierarchy

System..::.Object
  System.Collections.Generic..::.List<(Of <(Double>)>)
    iseesystems.iseeNET..::.ProvidesReporting
      iseesystems.iseeNET..::.OutputValues
      iseesystems.iseeNET..::.TimeValues

See Also