Class Instrumenter
The instrumenter walks the object graph of an algorithm to determine its composition. Upon finding objects that can
be instrumented, it attaches the corresponding collector. The returned InstrumentedAlgorithm
orchestrates
the collection of runtime information as the algorithm is executed.
Note: this will not scan the contents of Solution
or Problem
.
- See Also:
-
Constructor Summary
ConstructorDescriptionConstructs a new instrumenter instance, initially with no collectors. -
Method Summary
Modifier and TypeMethodDescriptionaddExcludedPackage
(String packageName) Adds an excluded package that will not be walked by this instrumenter.Includes the specified collector when instrumenting algorithms.Includes the adaptive multimethod variation collector when instrumenting algorithms.Includes the adaptive time continuation collector when instrumenting algorithms.Includes the additive ε-indicator collector when instrumenting algorithms.Includes all collectors when instrumenting algorithms.Includes all indicator collectors when instrumenting algorithms.Includes the contribution collector when instrumenting algorithms.Includes the elapsed time collector when instrumenting algorithms.Includes the ε-progress collector when instrumenting algorithms.Includes the generational distance collector when instrumenting algorithms.Includes the generational distance plus collector when instrumenting algorithms.Includes the hypervolume collector when instrumenting algorithms.Includes the inverted generational distance collector when instrumenting algorithms.Includes the inverted generational distance plus collector when instrumenting algorithms.Includes the maximum Pareto front error collector when instrumenting algorithms.Includes the population size collector when instrumenting algorithms.Includes the R1 collector when instrumenting algorithms.Includes the R2 collector when instrumenting algorithms.Includes the R3 collector when instrumenting algorithms.Includes the spacing collector when instrumenting algorithms.Returns the reference set that was configured with this instrumenter.protected void
instrument
(Algorithm algorithm, InstrumentedExtension extension, List<Collector> collectors, Set<Object> visited, Stack<Object> parents, Object object, Class<?> type) Recursively walks the object graph to 1) determine the nesting of objects to help determine which objects are to be instrumented; and 2) attach theCollector
s to any matching objects.<T extends Algorithm>
InstrumentedAlgorithm<T>instrument
(T algorithm) Instruments the specified algorithm, returning anInstrumentedAlgorithm
to be used to execute the algorithm and store the data produced by any attached instruments.removeExcludedPackage
(String packageName) Removes an excluded package from this instrumenter.withEpsilon
(double... epsilon) Sets the ε values used by this instrumenter.withEpsilons
(Epsilons epsilons) Sets the ε values used by this instrumenter.withFrequency
(Frequency frequency) Sets the frequency that data is collected.withReferenceSet
(File referenceSetFile) Loads a reference set from file.withReferenceSet
(String resource) Loads a reference set from a resource available in the file system or bundled in a JAR.withReferenceSet
(NondominatedPopulation referenceSet) Configures a reference set to use for this problem.
-
Constructor Details
-
Instrumenter
public Instrumenter()Constructs a new instrumenter instance, initially with no collectors.
-
-
Method Details
-
getReferenceSet
Returns the reference set that was configured with this instrumenter.- Returns:
- the reference set
-
addExcludedPackage
Adds an excluded package that will not be walked by this instrumenter.- Parameters:
packageName
- the package name- Returns:
- a reference to this instrumenter
-
removeExcludedPackage
Removes an excluded package from this instrumenter.- Parameters:
packageName
- the package name- Returns:
- a reference to this instrumenter
-
withFrequency
Sets the frequency that data is collected.- Parameters:
frequency
- the frequency- Returns:
- a reference to this instrumenter
-
attach
Includes the specified collector when instrumenting algorithms.- Parameters:
collector
- the collector to include when instrumenting algorithms- Returns:
- a reference to this instrumenter
-
attachHypervolumeCollector
Includes the hypervolume collector when instrumenting algorithms.- Returns:
- a reference to this instrumenter
-
attachGenerationalDistanceCollector
Includes the generational distance collector when instrumenting algorithms.- Returns:
- a reference to this instrumenter
-
attachGenerationalDistancePlusCollector
Includes the generational distance plus collector when instrumenting algorithms.- Returns:
- a reference to this instrumenter
-
attachInvertedGenerationalDistanceCollector
Includes the inverted generational distance collector when instrumenting algorithms.- Returns:
- a reference to this instrumenter
-
attachInvertedGenerationalDistancePlusCollector
Includes the inverted generational distance plus collector when instrumenting algorithms.- Returns:
- a reference to this instrumenter
-
attachSpacingCollector
Includes the spacing collector when instrumenting algorithms.- Returns:
- a reference to this instrumenter
-
attachAdditiveEpsilonIndicatorCollector
Includes the additive ε-indicator collector when instrumenting algorithms.- Returns:
- a reference to this instrumenter
-
attachContributionCollector
Includes the contribution collector when instrumenting algorithms.- Returns:
- a reference to this instrumenter
-
attachMaximumParetoFrontErrorCollector
Includes the maximum Pareto front error collector when instrumenting algorithms.- Returns:
- a reference to this instrumenter
-
attachR1Collector
Includes the R1 collector when instrumenting algorithms.- Returns:
- a reference to this instrumenter
-
attachR2Collector
Includes the R2 collector when instrumenting algorithms.- Returns:
- a reference to this instrumenter
-
attachR3Collector
Includes the R3 collector when instrumenting algorithms.- Returns:
- a reference to this instrumenter
-
attachAllMetricCollectors
Includes all indicator collectors when instrumenting algorithms.- Returns:
- a reference to this instrumenter
-
attachEpsilonProgressCollector
Includes the ε-progress collector when instrumenting algorithms.- Returns:
- a reference to this instrumenter
-
attachAdaptiveMultimethodVariationCollector
Includes the adaptive multimethod variation collector when instrumenting algorithms.- Returns:
- a reference to this instrumenter
-
attachAdaptiveTimeContinuationCollector
Includes the adaptive time continuation collector when instrumenting algorithms.- Returns:
- a reference to this instrumenter
-
attachElapsedTimeCollector
Includes the elapsed time collector when instrumenting algorithms.- Returns:
- a reference to this instrumenter
-
attachPopulationSizeCollector
Includes the population size collector when instrumenting algorithms.- Returns:
- a reference to this instrumenter
-
attachAll
Includes all collectors when instrumenting algorithms.- Returns:
- a reference to this instrumenter
-
withReferenceSet
Loads a reference set from file. Only required when computing performance indicators.- Parameters:
referenceSetFile
- the reference set file- Returns:
- a reference to this instrumenter
- Throws:
IOException
- if an I/O error occurred
-
withReferenceSet
Loads a reference set from a resource available in the file system or bundled in a JAR. Only required when computing performance indicators.- Parameters:
resource
- the reference set resource name- Returns:
- a reference to this instrumenter
- Throws:
IOException
- if an I/O error occurred
-
withReferenceSet
Configures a reference set to use for this problem. Only required when computing performance indicators.- Parameters:
referenceSet
- the reference set- Returns:
- a reference to this instrumenter
-
withEpsilon
Sets the ε values used by this instrumenter.- Parameters:
epsilon
- the ε values- Returns:
- a reference to this builder
-
withEpsilons
Sets the ε values used by this instrumenter.- Parameters:
epsilons
- the ε values- Returns:
- a reference to this builder
-
instrument
protected void instrument(Algorithm algorithm, InstrumentedExtension extension, List<Collector> collectors, Set<Object> visited, Stack<Object> parents, Object object, Class<?> type) Recursively walks the object graph to 1) determine the nesting of objects to help determine which objects are to be instrumented; and 2) attach theCollector
s to any matching objects.In order to avoid cycles in the object graph, objects are only traversed the first time they are encountered. If an object appears multiple times in the object graph, the
instrument
method will only be invoked once.When generating the nesting of objects, anonymous classes are given the placeholder type
"(Anonymous)"
, without quotes. While the contents of arrays andCollection
s are listed in the nesting, the array/collection object itself is not listed. For example, the nesting will showCompoundVariation >> PM
instead ofCompoundVariation >> ArrayList >> Object[] >> PM
.This method is reentrant.
- Parameters:
algorithm
- the algorithmextension
- the extension responsible for collecting the datacollectors
- the collectors to be attachedvisited
- the set of visited objects, which may include the current object when traversing its superclassesparents
- the objects in which the current object is containedobject
- the current object undergoing reflectiontype
- the superclass whose members are being reflected; ornull
if the base type is to be used
-
instrument
Instruments the specified algorithm, returning anInstrumentedAlgorithm
to be used to execute the algorithm and store the data produced by any attached instruments.- Type Parameters:
T
- the type of the algorithm- Parameters:
algorithm
- the algorithm to instrument- Returns:
- the instrumented algorithm
- Throws:
IllegalArgumentException
- if no reference set is available or could not be loaded
-