Package org.moeaframework
Class Analyzer
java.lang.Object
org.moeaframework.Analyzer
- All Implemented Interfaces:
Displayable
Performs basic end-of-run analysis. This includes evaluating the selected performance indicators, summarizing the
indicator values with descriptive statistics (min, median, max, inter-quartile range, etc.), and determining if
the results of each algorithm are statistically similar.
For example, the following demonstrates its typical use. First construct and configure the analyzer:
Analyzer analyzer = new Analyzer() .withProblem("DTLZ2_2") .includeGenerationalDistance() .includeInvertedGenerationalDistance() .includeAdditiveEpsilonIndicator() .includeContribution() .showAggregate() .showStatisticalSignificance();The problem must always be specified. Next, add the data to be analyzed:
Executor executor = new Executor().withProblem("DTLZ2_2"); analyzer.add("NSGAII", executor.withAlgorithm("NSGAII").run()); analyzer.add("eMOEA", executor.withAlgorithm("eMOEA").run());Lastly, print the results of the analysis:
analyzer.display();
-
Nested Class Summary
Modifier and TypeClassDescriptionclass
Stores the results produced by this analyzer.class
Collection of end-of-run results (i.e., the approximation set) produced by an algorithm across multiple seeds. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionadd
(String name, NondominatedPopulation approximationSet) Adds a new sample with the specified name.addAll
(String name, Collection<NondominatedPopulation> approximationSets) Adds the collection of new samples with the specified name.clear()
Clears all data stored in this analyzer.void
display
(PrintStream ps) Displays the contents of this object to the given output stream.Generates the analysis of all data recorded in this analyzer.Returns the reference set used by this analyzer.Enables the evaluation of the additive ε-indicator metric.Enables the evaluation of all metrics.Enables the evaluation of the contribution metric.Enables the evaluation of the generational distance metric.Enables the evaluation of the generational distance plus metric.Enables the evaluation of the hypervolume metric.Enables the evaluation of the inverted generational distance metric.Enables the evaluation of the inverted generational distance plus metric.Enables the evaluation of the maximum Pareto front error metric.Enables the evaluation of the R1 indicator.Enables the evaluation of the R2 indicator.Enables the evaluation of the R3 indicator.Enables the evaluation of the spacing metric.Loads the samples stored in a result file usingResultFileReader
.Loads data into this analyzer, which was previously saved usingsaveData(File, String, String)
with matching arguments.Prints the analysis of all data recorded in this analyzer to standard output.Prints the analysis of all data recorded in this analyzer.saveAnalysis
(File file) Saves the analysis of all data recorded in this analyzer to the specified file.Saves the samples to a result file usingResultFileWriter
.Saves all data stored in this analyzer, which can subsequently be read usingloadData(File, String, String)
with matching arguments.saveReferenceSet
(File file) Saves the reference set to the specified file.Enables the output of the metric value of the aggregate approximation set, produced by merging all individual seeds.showAll()
Enables the output of all analysis results.Enables the output of individual metric values for each seed.showStatistic
(org.apache.commons.math3.stat.descriptive.UnivariateStatistic statistic) Specifies theUnivariateStatistic
s calculated during the analysis.Enables the output of statistical significance tests.usingProblemFactory
(ProblemFactory problemFactory) withEpsilon
(double... epsilon) withEpsilons
(Epsilons epsilons) withIdealPoint
(double... idealPoint) Sets the ideal point used for computing the hypervolume metric.withProblem
(String problemName) withProblem
(Problem problemInstance) withProblemClass
(Class<?> problemClass, Object... problemArguments) withProblemClass
(String problemClassName, Object... problemArguments) withReferencePoint
(double... referencePoint) Sets the reference point used for computing the hypervolume metric.withReferenceSet
(File referenceSetFile) withReferenceSet
(NondominatedPopulation referenceSet) withSameProblemAs
(org.moeaframework.ProblemBuilder builder) withSignifianceLevel
(double significanceLevel) Sets the level of significance used when testing the statistical significance of observed differences in the medians.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.moeaframework.util.format.Displayable
display
-
Constructor Details
-
Analyzer
public Analyzer()Constructs a new analyzer initialized with default settings.
-
-
Method Details
-
withSameProblemAs
-
usingProblemFactory
-
withProblem
-
withProblem
-
withProblemClass
-
withProblemClass
public Analyzer withProblemClass(String problemClassName, Object... problemArguments) throws ClassNotFoundException - Throws:
ClassNotFoundException
-
withEpsilon
-
withEpsilons
-
withReferenceSet
-
withReferenceSet
-
includeHypervolume
Enables the evaluation of the hypervolume metric.- Returns:
- a reference to this analyzer
-
includeGenerationalDistance
Enables the evaluation of the generational distance metric.- Returns:
- a reference to this analyzer
-
includeGenerationalDistancePlus
Enables the evaluation of the generational distance plus metric.- Returns:
- a reference to this analyzer
-
includeInvertedGenerationalDistance
Enables the evaluation of the inverted generational distance metric.- Returns:
- a reference to this analyzer
-
includeInvertedGenerationalDistancePlus
Enables the evaluation of the inverted generational distance plus metric.- Returns:
- a reference to this analyzer
-
includeAdditiveEpsilonIndicator
Enables the evaluation of the additive ε-indicator metric.- Returns:
- a reference to this analyzer
-
includeMaximumParetoFrontError
Enables the evaluation of the maximum Pareto front error metric.- Returns:
- a reference to this analyzer
-
includeSpacing
Enables the evaluation of the spacing metric.- Returns:
- a reference to this analyzer
-
includeContribution
Enables the evaluation of the contribution metric.- Returns:
- a reference to this analyzer
-
includeR1
Enables the evaluation of the R1 indicator.- Returns:
- a reference to this analyzer
-
includeR2
Enables the evaluation of the R2 indicator.- Returns:
- a reference to this analyzer
-
includeR3
Enables the evaluation of the R3 indicator.- Returns:
- a reference to this analyzer
-
includeAllMetrics
Enables the evaluation of all metrics.- Returns:
- a reference to this analyzer
-
showAll
Enables the output of all analysis results.- Returns:
- a reference to this analyzer
-
showIndividualValues
Enables the output of individual metric values for each seed.- Returns:
- a reference to this analyzer
-
showAggregate
Enables the output of the metric value of the aggregate approximation set, produced by merging all individual seeds.- Returns:
- a reference to this analyzer
-
showStatisticalSignificance
Enables the output of statistical significance tests. If enabled, it is necessary to record multiple seeds for each entry.- Returns:
- a reference to this analyzer
-
showStatistic
public Analyzer showStatistic(org.apache.commons.math3.stat.descriptive.UnivariateStatistic statistic) Specifies theUnivariateStatistic
s calculated during the analysis. If none are specified by the user, then the default statistics are displayed.- Parameters:
statistic
- the statistic to calculate- Returns:
- a reference to this analyzer
-
withSignifianceLevel
Sets the level of significance used when testing the statistical significance of observed differences in the medians. Commonly used levels of significance are0.05
and0.01
.- Parameters:
significanceLevel
- the level of significance- Returns:
- a reference to this analyzer
-
withIdealPoint
Sets the ideal point used for computing the hypervolume metric.- Parameters:
idealPoint
- the ideal point- Returns:
- a reference to this analyzer
-
withReferencePoint
Sets the reference point used for computing the hypervolume metric.- Parameters:
referencePoint
- the reference point- Returns:
- a reference to this analyzer
-
addAll
Adds the collection of new samples with the specified name.- Parameters:
name
- the name of these samplesapproximationSets
- the approximation sets- Returns:
- a reference to this analyzer
-
add
Adds a new sample with the specified name. If multiple samples are added using the same name, each sample is treated as an individual seed. Analyses can be performed on both the individual seeds and aggregates of the seeds.- Parameters:
name
- the name of this sampleapproximationSet
- the approximation set- Returns:
- a reference to this analyzer
-
saveData
Saves all data stored in this analyzer, which can subsequently be read usingloadData(File, String, String)
with matching arguments.- Parameters:
directory
- the directory in which the data is storedprefix
- the prefix for filenamessuffix
- the suffix (extension) for filenames- Returns:
- a reference to this analyzer
- Throws:
IOException
- if an I/O error occurred
-
loadData
Loads data into this analyzer, which was previously saved usingsaveData(File, String, String)
with matching arguments.- Parameters:
directory
- the directory in which the data is storedprefix
- the prefix for filenamessuffix
- the suffix (extension) for filenames- Returns:
- a reference to this analyzer
- Throws:
IOException
- if an I/O error occurred
-
loadAs
Loads the samples stored in a result file usingResultFileReader
.- Parameters:
name
- the name of the samplesresultFile
- the result file to load- Returns:
- a reference to this analyzer
- Throws:
IOException
- if an I/O error occurred
-
saveAs
Saves the samples to a result file usingResultFileWriter
. Ifname
isnull
, the reference set is saved. Otherwise, the approximation sets for the named entries are saved.- Parameters:
name
- the name of the samplesresultFile
- the result file to which the data is saved- Returns:
- a reference to this analyzer
- Throws:
IOException
- if an I/O error occurred
-
saveAnalysis
Saves the analysis of all data recorded in this analyzer to the specified file.- Parameters:
file
- the file to which the analysis is saved- Returns:
- a reference to this analyzer
- Throws:
IOException
- if an I/O error occurred
-
printAnalysis
Prints the analysis of all data recorded in this analyzer to standard output.- Returns:
- a reference to this analyzer
-
saveReferenceSet
Saves the reference set to the specified file.- Parameters:
file
- the file to which the reference set is saved- Returns:
- a reference to this analyzer
- Throws:
IOException
- if an I/O error occurred- See Also:
-
getReferenceSet
Returns the reference set used by this analyzer. The reference set is generated as follows:- If
withReferenceSet(File)
has been set, the contents of the reference set file are returned; - If the problem factory provides a reference set via the
ProblemFactory.getReferenceSet(String)
method, this reference set is returned; - Otherwise, the reference set is aggregated from all individual approximation sets.
- Returns:
- the reference set used by this analyzer
- Throws:
IllegalArgumentException
- if the reference set could not be loaded
- If
-
getAnalysis
Generates the analysis of all data recorded in this analyzer.- Returns:
- an object storing the results of the analysis
-
printAnalysis
Prints the analysis of all data recorded in this analyzer.- Parameters:
ps
- the stream to which the analysis is written- Returns:
- a reference to this analyzer
-
display
Description copied from interface:Displayable
Displays the contents of this object to the given output stream. This method does not close the underlying stream; the caller is responsible for disposing it.- Specified by:
display
in interfaceDisplayable
- Parameters:
ps
- the output stream
-
clear
Clears all data stored in this analyzer.- Returns:
- a reference to this analyzer
-