Package org.djutils.traceverifier
Class TraceVerifier
- java.lang.Object
-
- org.djutils.traceverifier.TraceVerifier
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
public class TraceVerifier extends Object implements Closeable
Create or verify identity of a trace of states of a system.
E.g., A simulation that is run with the same initial conditions (including random seed) should behave in a 100% predictable manner. If it does not, there is some source of randomness that probably should be eliminated. This package can help locate where the various runs of the simulation start to deviate from one another.
The simulation must be instrumented with calls to thesample
method. The sample method either records these samples in a file, or compares these samples with the values that were stored in the file in a previous run. When a difference occurs, the sample method throws an exception.
Copyright (c) 2020-2021 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See for project information https://djutils.org. The DJUTILS project is distributed under a three-clause BSD-style license, which can be found at https://djutils.org/docs/license.html.- Author:
- Alexander Verbraeck, Peter Knoppers
-
-
Constructor Summary
Constructors Constructor Description TraceVerifier(String fileName)
Create a new TraceVerifier.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
void
sample(String description, String state)
Add or compare one sample.String
toString()
-
-
-
Constructor Detail
-
TraceVerifier
public TraceVerifier(String fileName) throws IOException
Create a new TraceVerifier.- Parameters:
fileName
- String; name of the file for the trace- Throws:
IOException
- when reading or writing fails
-
-
Method Detail
-
sample
public void sample(String description, String state) throws IOException
Add or compare one sample.- Parameters:
description
- String; some kind of description of the sample (usually some kind of time stamp).state
- String; summary of the state of the process that is sampled.- Throws:
IOException
- when reading or writing failsTraceVerifierException
- on detection of a sample discrepancy
-
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
-