public class DesignSpaceExplorer
extends java.lang.Object
The DesignSpaceExplorer
is the main API of the Design Space Exploration engine.
To parameterize the algorithm one must use the following methods after instantiating:
#setInitialModel(EObject)
or it's overloads to set the starting model.addTransformationRule(BatchTransformationRule)
to define the transformations.addObjective(IObjective)
to define the objective functions. Use the Objectives
helper class for
instantiating built-in, configurable objectives.startExploration(IStrategy)
or it's overloads to start an exploration with the given exploration
strategy. Use the Strategies
helper class for instantiating built-in, configurable exploration strategies.
Designs Space Exploration is the process of finding a sequence (or sequences) of predefined transformation rules ("transitions") that, if applied in order on the starting model, results in a new model state that fulfills the hard (or goal) constraints and is near optimal with respect to the objectives.
An extension to this paradigm is the introduction of global constraints, which guarantees, that no sequence will be
returned, which if executed, results in an intermediate model state that violates the specified global constraints,
including the final state. You can add constraints by invoking addGlobalConstraint(IGlobalConstraint)
.
Modifier and Type | Class and Description |
---|---|
static class |
DesignSpaceExplorer.DseLoggingLevel
Enumeration for different use cases of logging, including:
OFF - no error messages.
WARN - only error and warn messages.
BASIC - logs basic information on how the exploration is going.
VERBOSE_STRATEGY - logs everything the exploration strategy is prepared for.
VERBOSE_FULL - logs every transformation.
|
Constructor and Description |
---|
DesignSpaceExplorer()
Creates a
DesignSpaceExplorer object that is able to execute a design space exploration process. |
Modifier and Type | Method and Description |
---|---|
void |
addDesignSpaceVisulaizer(IDesignSpaceVisualizer visualizer)
Registers a design space visualizer.
|
void |
addGlobalConstraint(IGlobalConstraint constraint)
Adds a global constraint to the exploration process.
|
void |
addMetaModelPackage(org.eclipse.emf.ecore.EPackage metaModelPackage)
Adds a metamodel in the form of
EPackage , which is needed for certain guidance. |
void |
addObjective(IObjective objective)
Adds an objective the the exploration process.
|
void |
addTransformationRule(BatchTransformationRule<?,?> rule)
Adds a
BatchTransformationRule . |
SolutionTrajectory |
getArbitrarySolution()
Returns an arbitrary solution trajectory or null if the exploration failed to find any.
|
GlobalContext |
getGlobalContext()
Returns the
GlobalContext which holds the configurations such as rule, objectives, etc. |
java.util.Set<org.eclipse.emf.ecore.EPackage> |
getMetaModelPackages()
Returns the
EPackage s, which were registered with the
addMetaModelPackage(EPackage) method. |
long |
getNumberOfStates()
Returns the number of distinct states the exploration process has visited so far.
|
long |
getNumberOfTransitions()
Returns the number of distinct transitions the exploration process has discovered (but not necessarily traversed)
so far.
|
java.util.Collection<Solution> |
getSolutions()
Returns all of the found
Solution s, trajectories. |
boolean |
isDone()
Returns true if the
strategy decided to stop, and all the threads finished their work. |
void |
saveModels(org.eclipse.emf.common.notify.Notifier model)
Serializes all the found solutions by transforming the given initial model.
|
void |
saveModels(org.eclipse.emf.common.notify.Notifier model,
ISolutionNameProvider solutionNameProvider)
Serializes all the found solutions by transforming the given initial model.
|
void |
saveModels(org.eclipse.emf.common.notify.Notifier model,
java.lang.String extension)
Serializes all the found solutions by transforming the given initial model.
|
void |
saveModels(org.eclipse.emf.common.notify.Notifier model,
java.lang.String fileNamePrefix,
java.lang.String extension)
Serializes all the found solutions by transforming the given initial model.
|
void |
setConflictResolver(ConflictResolver conflictResolver)
A conflict resolver can filter rule activations the DSE engine will see.
|
void |
setDesignspace(IDesignSpace designspace)
Sets the
IDesignSpace implementation that is to be used during the design space exploration process. |
void |
setInitialModel(org.eclipse.emf.common.notify.Notifier model)
Defines the initial model of the exploration.
|
void |
setInitialModel(org.eclipse.emf.common.notify.Notifier model,
boolean deepCopyModel)
Defines the initial model of the exploration, and whether it is supposed to be used to execute the DSE process or
it should be cloned.
|
void |
setInitialModelUncloned(org.eclipse.emf.common.notify.Notifier model)
Defines the initial model of the exploration.
|
void |
setMaxNumberOfThreads(int maxNumberOfThreads)
Defines the maximum processing threads that the design space exploration can use.
|
void |
setSolutionStore(SolutionStore solutionStore)
Sets the solution store for strategies.
|
void |
setStateCoderFactory(IStateCoderFactory stateCoderFactory)
Sets a
IStateCoderFactory for which will be used for creating IStateCoder s. |
void |
startExploration(IStrategy strategy)
Starts the design space exploration.
|
boolean |
startExploration(IStrategy strategy,
boolean waitForTermination,
long timeout)
Starts the design space exploration.
|
void |
startExplorationAsync(IStrategy strategy)
Starts the design space exploration asynchronously.
|
boolean |
startExplorationAsyncWithTimeout(IStrategy strategy,
long timeout)
Starts the design space exploration asynchronously with a timeout.
|
boolean |
startExplorationWithTimeout(IStrategy strategy,
long timeout)
Starts the design space exploration with a timeout.
|
void |
stopExploration()
Stops the exploration and waits for termination.
|
void |
stopExplorationAsync()
Stops the exploration asynchronously.
|
java.lang.String |
toStringSolutions()
Creates a string containing the state codes of all the found solutions and the found trajectories to these
solutions with fitness values.
|
static void |
turnOnLogging(DesignSpaceExplorer.DseLoggingLevel dseLoggingLevel)
Changes the level of logging.
|
static void |
turnOnLoggingWithBasicConfig(DesignSpaceExplorer.DseLoggingLevel dseLoggingLevel)
Changes the level of logging.
|
void |
waitForTerminaition()
Waits for termination.
|
public DesignSpaceExplorer()
Creates a DesignSpaceExplorer
object that is able to execute a design space exploration process.
By default the state coder used is the generic (not meta-model specific) GraphHash
. You can provide your
custom state coder by implementing the IStateCoderFactory
and IStateCoder
interfaces, and passing
the former to the setStateCoderFactory(IStateCoderFactory)
method.
public void addMetaModelPackage(org.eclipse.emf.ecore.EPackage metaModelPackage)
EPackage
, which is needed for certain guidance.metaModelPackage
- public void setInitialModel(org.eclipse.emf.common.notify.Notifier model, boolean deepCopyModel)
model
- The root object of the EMF model.deepCopyModel
- If it is set to true, the exploration will run on a cloned model.public void setInitialModel(org.eclipse.emf.common.notify.Notifier model)
model
- The root object of the EMF model.public void setInitialModelUncloned(org.eclipse.emf.common.notify.Notifier model)
model
- The root object of the EMF model. It won't be cloned.public void addTransformationRule(BatchTransformationRule<?,?> rule)
BatchTransformationRule
.rule
- The transformationRule.public void addGlobalConstraint(IGlobalConstraint constraint)
IGlobalConstraint
interface and its
implementations for details.constraint
- The global constraint.IGlobalConstraint
public void addObjective(IObjective objective)
IObjective
interface and its
implementations for details.objective
- The objective.IObjective
public final void setStateCoderFactory(IStateCoderFactory stateCoderFactory)
IStateCoderFactory
for which will be used for creating IStateCoder
s. The default
implementation is the SimpleStateCoderFactory
, which works well in most of the cases.stateCoderFactory
- The factory.public void setMaxNumberOfThreads(int maxNumberOfThreads)
Runtime.availableProcessors()
.maxNumberOfThreads
- The number of maximum processing threads available to the design space exploration process.public final void setDesignspace(IDesignSpace designspace)
IDesignSpace
implementation that is to be used during the design space exploration process. By
default, the DesignSpace
implementation is used.designspace
- The IDesignSpace
implementation.public void setSolutionStore(SolutionStore solutionStore)
SolutionStore
for how to configure it.solutionStore
- The parameterized SolutionStore
implementation.public void startExploration(IStrategy strategy)
strategy
- The strategy of the exploration.public void startExplorationAsync(IStrategy strategy)
isDone()
.strategy
- The strategy of the exploration.public boolean startExplorationWithTimeout(IStrategy strategy, long timeout)
strategy
- The strategy of the exploration.timeout
- The number of milliseconds before the exploration is forced to stop.public boolean startExplorationAsyncWithTimeout(IStrategy strategy, long timeout)
isDone()
.strategy
- The strategy of the exploration.timeout
- The number of milliseconds before the exploration is forced to stop.public boolean startExploration(IStrategy strategy, boolean waitForTermination, long timeout)
waitForTermination
is true, then it returns only when the
strategy decides to stop the execution or there was a timeout, otherwise when the exploration process is started
it returns immediately. In this case, process completion can be verified by calling
isDone()
.strategy
- The strategy of the exploration.waitForTermination
- True if the method must wait for the engine to stop, i.e. whether to start synchronously.timeout
- The number of milliseconds before the exploration is forced to stop.public java.util.Collection<Solution> getSolutions()
Solution
s, trajectories. Call it after
DesignSpaceExplorer#startExploration()
. Calling this while the process is running returns the solutions
that have been found so far. The returned Solution
objects may change internal state after they
have been returned, if a shorter trajectory has been found to the referred state.public SolutionTrajectory getArbitrarySolution()
public long getNumberOfStates()
public long getNumberOfTransitions()
public java.util.Set<org.eclipse.emf.ecore.EPackage> getMetaModelPackages()
EPackage
s, which were registered with the
addMetaModelPackage(EPackage)
method.public boolean isDone()
strategy
decided to stop, and all the threads finished their work.public GlobalContext getGlobalContext()
GlobalContext
which holds the configurations such as rule, objectives, etc.public void addDesignSpaceVisulaizer(IDesignSpaceVisualizer visualizer)
IDesignSpaceVisualizer
.visualizer
- IDesignSpaceVisualizer
public java.lang.String toStringSolutions()
public void setConflictResolver(ConflictResolver conflictResolver)
conflictResolver
- public static void turnOnLogging(DesignSpaceExplorer.DseLoggingLevel dseLoggingLevel)
DesignSpaceExplorer.DseLoggingLevel
for details.dseLoggingLevel
- public static void turnOnLoggingWithBasicConfig(DesignSpaceExplorer.DseLoggingLevel dseLoggingLevel)
DesignSpaceExplorer.DseLoggingLevel
for details.
Also configures a basic console appender for log4j.dseLoggingLevel
- public void stopExploration()
public void stopExplorationAsync()
public void waitForTerminaition()
public void saveModels(org.eclipse.emf.common.notify.Notifier model)
solution[id].xmi
.model
- The initial model.public void saveModels(org.eclipse.emf.common.notify.Notifier model, java.lang.String extension)
solution[id].[extension]
.model
- The initial model.extension
- The extension of the omitted file.public void saveModels(org.eclipse.emf.common.notify.Notifier model, java.lang.String fileNamePrefix, java.lang.String extension)
[fileNamePrefix][id].[extension]
.model
- The initial model.fileNamePrefix
- The prefix (optionally including a file path) of the omitted file.extension
- The extension of the omitted file.public void saveModels(org.eclipse.emf.common.notify.Notifier model, ISolutionNameProvider solutionNameProvider)
ISolutionNameProvider
.model
- The initial model.