|
MOEA Framework 2.5 API Specification |
|||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||
java.lang.Objectorg.moeaframework.Instrumenter
public class Instrumenter
Instruments algorithms with Collectors which record information about
the runtime behavior of algorithms. First, the instrumenter walks the object
graph of an algorithm to determine its composition. Upon finding objects
which can be instrumented, it attaches the corresponding collector. Next,
the instrumenter returns an InstrumentedAlgorithm, which orchestrates
the collection of runtime information as the algorithm is executed. Lastly,
the InstrumentedAlgorithm stores the runtime information, which can
subsequently be accessed and analyzed.
Instrumenter instrumenter = new Instrumenter()
.withProblem(problemName)
.attachAll();
Executor executor = new Executor()
.withProblem(problemName)
.withAlgorithm(algorithmName)
.withMaxEvaluations(numberOfEvaluations)
.withInstrumenter(instrumenter)
.run();
Accumulator accumulator = instrumenter.getLastAccumulator();
| Constructor Summary | |
|---|---|
Instrumenter()
Constructs a new instrumenter instance, initially with no collectors. |
|
| Method Summary | |
|---|---|
Instrumenter |
addAllowedPackage(String packageName)
Allows this instrumenter to visit classes in the given package. |
Instrumenter |
attach(Collector collector)
Includes the specified collector when instrumenting algorithms. |
Instrumenter |
attachAdaptiveMultimethodVariationCollector()
Includes the adaptive multimethod variation collector when instrumenting algorithms. |
Instrumenter |
attachAdaptiveTimeContinuationCollector()
Includes the adaptive time continuation collector when instrumenting algorithms. |
Instrumenter |
attachAdditiveEpsilonIndicatorCollector()
Includes the additive ε-indicator collector when instrumenting algorithms. |
Instrumenter |
attachAll()
Includes all collectors when instrumenting algorithms. |
Instrumenter |
attachAllMetricCollectors()
Includes all indicator collectors when instrumenting algorithms. |
Instrumenter |
attachApproximationSetCollector()
Includes the approximation set collector when instrumenting algorithms. |
Instrumenter |
attachContributionCollector()
Includes the contribution collector when instrumenting algorithms. |
Instrumenter |
attachElapsedTimeCollector()
Includes the elapsed time collector when instrumenting algorithms. |
Instrumenter |
attachEpsilonProgressCollector()
Includes the ε-progress collector when instrumenting algorithms. |
Instrumenter |
attachGenerationalDistanceCollector()
Includes the generational distance collector when instrumenting algorithms. |
Instrumenter |
attachHypervolumeCollector()
Includes the hypervolume collector when instrumenting algorithms. |
Instrumenter |
attachInvertedGenerationalDistanceCollector()
Includes the inverted generational distance collector when instrumenting algorithms. |
Instrumenter |
attachPopulationSizeCollector()
Includes the population size collector when instrumenting algorithms. |
Instrumenter |
attachR1Collector()
Includes the R1 collector when instrumenting algorithms. |
Instrumenter |
attachR2Collector()
Includes the R2 collector when instrumenting algorithms. |
Instrumenter |
attachR3Collector()
Includes the R3 collector when instrumenting algorithms. |
Instrumenter |
attachSpacingCollector()
Includes the spacing collector when instrumenting algorithms. |
List<String> |
getAllowedPackages()
Returns all packages this instrumenter is allowed to visit. |
Accumulator |
getLastAccumulator()
Returns the accumulator from the last instrumented algorithm. |
NondominatedPopulation |
getReferenceSet()
Returns the reference set used by this builder. |
InstrumentedAlgorithm |
instrument(Algorithm algorithm)
Instruments the specified algorithm, returning an InstrumentedAlgorithm to be used to execute the algorithm and
store the data produced by any attached instruments. |
protected void |
instrument(InstrumentedAlgorithm algorithm,
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 the collectors to any matching objects. |
Instrumenter |
removeAllowedPackage(String packageName)
Removes one of the packages this instrumenter is allowed to visit. |
Instrumenter |
usingProblemFactory(ProblemFactory problemFactory)
Sets the problem factory used by this builder. |
Instrumenter |
withEpsilon(double... epsilon)
Sets the ε values used by this builder, specifying the archive returned by newArchive(). |
Instrumenter |
withFrequency(int frequency)
Sets the frequency, in evaluations, that data is collected. |
Instrumenter |
withProblem(String problemName)
Sets the problem used by this builder. |
Instrumenter |
withProblemClass(Class<?> problemClass,
Object... problemArguments)
Sets the problem used by this builder. |
Instrumenter |
withProblemClass(String problemClassName,
Object... problemArguments)
Sets the problem used by this builder. |
Instrumenter |
withReferenceSet(File referenceSetFile)
Sets the file containing the reference set to be used by this builder. |
Instrumenter |
withSameProblemAs(org.moeaframework.ProblemBuilder builder)
Configures this builder to use the same problem, reference set, ε values and ProblemFactory as the specified instance. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Instrumenter()
| Method Detail |
|---|
public Accumulator getLastAccumulator()
public Instrumenter addAllowedPackage(String packageName)
NullPointerException or a
SecurityException. Therefore, the instrumenter can only visit
classes explicitly allowed by the user. By default,
org.moeaframework is allowed.
packageName - a package name or the package name prefix
public Instrumenter removeAllowedPackage(String packageName)
addAllowedPackage(String).
packageName - the package name or package name prefix to remove
public List<String> getAllowedPackages()
public Instrumenter withFrequency(int frequency)
frequency - the frequency
public Instrumenter attach(Collector collector)
collector - the collector to include when instrumenting algorithms
public Instrumenter attachHypervolumeCollector()
public Instrumenter attachGenerationalDistanceCollector()
public Instrumenter attachInvertedGenerationalDistanceCollector()
public Instrumenter attachSpacingCollector()
public Instrumenter attachAdditiveEpsilonIndicatorCollector()
public Instrumenter attachContributionCollector()
public Instrumenter attachR1Collector()
public Instrumenter attachR2Collector()
public Instrumenter attachR3Collector()
public Instrumenter attachAllMetricCollectors()
public Instrumenter attachEpsilonProgressCollector()
public Instrumenter attachAdaptiveMultimethodVariationCollector()
public Instrumenter attachAdaptiveTimeContinuationCollector()
public Instrumenter attachElapsedTimeCollector()
public Instrumenter attachApproximationSetCollector()
public Instrumenter attachPopulationSizeCollector()
public Instrumenter attachAll()
public Instrumenter withSameProblemAs(org.moeaframework.ProblemBuilder builder)
ProblemFactory as the specified instance.
builder - the instance whose problem, reference set, ε
values and ProblemFactory are to be copied
public Instrumenter usingProblemFactory(ProblemFactory problemFactory)
problemFactory - the problem factory
public Instrumenter withProblem(String problemName)
problemName - the problem name
public Instrumenter withProblemClass(Class<?> problemClass,
Object... problemArguments)
Class.newInstance() method. Ensure the problem
class satisfies all the conditions of newInstance(), otherwise
exceptions may be thrown when attempting to create an instance of the
problem.
problemClass - the problem classproblemArguments - the arguments passed to the problem constructor
public Instrumenter withProblemClass(String problemClassName,
Object... problemArguments)
throws ClassNotFoundException
Class.newInstance() method. Ensure the problem
class satisfies all the conditions of newInstance(), otherwise
exceptions may be thrown when attempting to create an instance of the
problem.
problemClassName - the problem class nameproblemArguments - the arguments passed to the problem constructor
ClassNotFoundException - if the specified problem class name could
not be foundpublic Instrumenter withReferenceSet(File referenceSetFile)
referenceSetFile - the reference set file
public Instrumenter withEpsilon(double... epsilon)
newArchive().
epsilon - the ε values
public NondominatedPopulation getReferenceSet()
withReferenceSet(File) has been set, the contents of
the reference set file are returned;
ProblemFactory.getReferenceSet(String) method, this
reference set is returned;
protected void instrument(InstrumentedAlgorithm algorithm,
List<Collector> collectors,
Set<Object> visited,
Stack<Object> parents,
Object object,
Class<?> type)
collectors 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 and Collections are listed in the nesting,
the array/collection object itself is not listed. For example,
the nesting will show CompoundVariation >> PM instead of
CompoundVariation >> ArrayList >> Object[] >> PM.
This method is reentrant.
algorithm - the instrumented algorithmcollectors - 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; or
null if the base type is to be usedpublic InstrumentedAlgorithm instrument(Algorithm algorithm)
InstrumentedAlgorithm to be used to execute the algorithm and
store the data produced by any attached instruments.
algorithm - the algorithm to instrument
IllegalArgumentException - if no reference set is available or
could not be loaded
|
MOEA Framework 2.5 API Specification |
|||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||