Class AbstractBenchmarkRunner
java.lang.Object
it.univr.di.cstnu.util.AbstractBenchmarkRunner
- Direct Known Subclasses:
DispatchabilityBenchmarkRunner, MDEBenchmarkRunner
Base class for the benchmark runners that measure the average execution time (and standard deviation) of STNU algorithms
on a given set of instances.
It provides the command-line options common to all runners (input files, output file, number of repetitions, timeout,
save flag, version), the management of the output stream, and the infrastructure to execute an algorithm several times
on fresh instances, collecting the execution-time statistics (repeatMeasure(String, String, Supplier, AlgorithmExecutor)).
- Author:
- posenato
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static interfaceFunctional contract used byrepeatMeasure(String, String, Supplier, AlgorithmExecutor)to execute one repetition of an algorithm.(package private) static final recordRepresents a key composed by(nodes, contingents)used to group the global statistics.(package private) static final classOutcome of the repeated executions of an algorithm on a single network, collected byrepeatMeasure(String, String, Supplier, AlgorithmExecutor). -
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final StringCSV separator(package private) final Class<STNUEdgeInt> Class for representing an edge.(package private) String[]The input file names.Input files asFileobjects.(package private) intParameter for asking how many times to execute each algorithm on each STNU.(package private) PrintStreamOutput stream to outputFile(package private) FileOutput file where to write the determined experimental execution times in CSV format.(package private) boolean(package private) intParameter for asking timeout in sec.(package private) booleanSoftware Version. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) static StringgetNow()(package private) static org.apache.commons.math3.stat.descriptive.SummaryStatisticsgetOrCreateStats(it.unimi.dsi.fastutil.objects.Object2ObjectMap<AbstractBenchmarkRunner.GlobalStatisticsKey, org.apache.commons.math3.stat.descriptive.SummaryStatistics> map, AbstractBenchmarkRunner.GlobalStatisticsKey key) Returns the summary statistics associated withkeyinmap, creating and registering it if absent.(package private) abstract String(package private) final STNUReturns an STNU object filled with the given graph and timeOut set as the parametertimeOut.(package private) final booleanmanageParameters(String[] args) Simple method to manage command line parameters usingargs4jlibrary.(package private) static doublenanoSeconds2Seconds(double value) (package private) final AbstractBenchmarkRunner.RepetitionOutcomerepeatMeasure(String fileName, String algLogName, Supplier<STNU> freshInstance, AbstractBenchmarkRunner.AlgorithmExecutor algorithm) Executesalgorithmup tonDCRepetitiontimes, each time on the fresh instance provided byfreshInstance, collecting the execution time of each successful repetition.(package private) abstract StringChecks the consistency of the algorithm-selection options of the concrete runner.
-
Field Details
-
CSVSep
-
currentEdgeImplClass
Class for representing an edge. -
inputFiles
String[] inputFilesThe input file names. Each file has to contain an STNU graph in GraphML format. -
instances
-
nDCRepetition
int nDCRepetitionParameter for asking how many times to execute each algorithm on each STNU. -
output
PrintStream outputOutput stream to outputFile -
outputFile
File outputFileOutput file where to write the determined experimental execution times in CSV format. -
save
boolean save -
timeOut
int timeOutParameter for asking timeout in sec. -
versionReq
boolean versionReqSoftware Version.
-
-
Constructor Details
-
AbstractBenchmarkRunner
AbstractBenchmarkRunner()
-
-
Method Details
-
getNow
- Returns:
- current time in
dateFormatterformat
-
nanoSeconds2Seconds
static double nanoSeconds2Seconds(double value) - Parameters:
value- value in nanoseconds- Returns:
- the value in seconds
-
getOrCreateStats
static org.apache.commons.math3.stat.descriptive.SummaryStatistics getOrCreateStats(@Nonnull it.unimi.dsi.fastutil.objects.Object2ObjectMap<AbstractBenchmarkRunner.GlobalStatisticsKey, org.apache.commons.math3.stat.descriptive.SummaryStatistics> map, @Nonnull AbstractBenchmarkRunner.GlobalStatisticsKey key) Returns the summary statistics associated withkeyinmap, creating and registering it if absent.- Parameters:
map- one of the global-statistics maps of the runner.key- key of the statistics.- Returns:
- the (possibly new) summary statistics for
key.
-
getVersionAndDate
- Returns:
- the version-and-date string of the concrete runner.
-
validateAlgorithmOptions
Checks the consistency of the algorithm-selection options of the concrete runner.- Returns:
- null if the options are consistent; the error message to show otherwise.
-
makeSTNUInstance
Returns an STNU object filled with the given graph and timeOut set as the parametertimeOut.- Parameters:
g- input graph- Returns:
- an STNU instance
-
manageParameters
Simple method to manage command line parameters usingargs4jlibrary.- Parameters:
args- input arguments- Returns:
- false if a parameter is missing or wrong. True if every parameter is given in the right format.
-
repeatMeasure
final AbstractBenchmarkRunner.RepetitionOutcome repeatMeasure(@Nonnull String fileName, @Nonnull String algLogName, @Nonnull Supplier<STNU> freshInstance, @Nonnull AbstractBenchmarkRunner.AlgorithmExecutor algorithm) Executesalgorithmup tonDCRepetitiontimes, each time on the fresh instance provided byfreshInstance, collecting the execution time of each successful repetition. It stops earlier if a repetition times out or fails.- Parameters:
fileName- name of the network under test (used only for logging).algLogName- name of the algorithm under test (used only for logging).freshInstance- provider of the STNU instance to use in each repetition.algorithm- algorithm to execute and measure.- Returns:
- the outcome of the repetitions.
-