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(DSETransformationRule)
to define the transformations.addGlobalConstraint(IGlobalConstraint)
to ensure some patterns on the trajectory's steps.addObjective(IObjective)
to define the objective functions.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 constraints defined by 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 violate the specified global constraints, including the final state. (or in reverse, they all fulfill the negative of the given constraints). You can add constraints by invoking {@link #addGlobalConstraint(IGlobalConstraint)}.
There are several built-in exploration strategies which you can find by using the static methods of Strategies helper class.
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(DSETransformationRule<?,?> rule)
Adds a
DSETransformationRule . |
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. |
java.lang.String |
prettyPrintSolutions()
Deprecated.
use toStringSolutions instead
|
void |
setDesignspace(IDesignSpace designspace)
Sets the
IDesignSpace implementation that is to be used during the design space exploration process. |
void |
setGuidance(Guidance guidance)
Deprecated.
|
void |
setInitialModel(org.eclipse.emf.common.notify.Notifier model)
Defines the starting model of the algorithm.
|
void |
setInitialModel(org.eclipse.emf.common.notify.Notifier model,
boolean deepCopyModel)
Defines the starting model of the algorithm, and whether it is supposed to be used to execute the DSE process or
it should be cloned.
|
void |
setMaxNumberOfThreads(int maxNumberOfThreads)
Defines the maximum processing threads that the design space exploration can use.
|
void |
setPredicatesForOcVectorResolving(java.util.List<Predicate> predicates)
Deprecated.
|
void |
setSerializerFactory(IStateCoderFactory serializerFactory)
Deprecated.
|
void |
setSolutionStore(ISolutionStore solutionStore)
Deprecated.
This method is only used by the strategies implementing the deprecated
LocalSearchStrategyBase abstract class. Use
setSolutionStore(SolutionStore) instead. |
void |
setSolutionStore(SolutionStore solutionStore)
Sets the solution store for strategies using the new strategy API.
|
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.
|
java.lang.String |
toStringSolutions() |
public DesignSpaceExplorer()
Creates a DesignSpaceExplorer
object that is able to execute a design space exploration process.
By default the design space implementation is the POJO based ConcurrentDesignSpace
. You can provide your
own custom design space implementation by implementing the IDesignSpace
interface and passing it to the
setDesignspace(IDesignSpace)
method.
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 algorithm will run in cloned model.public void setInitialModel(org.eclipse.emf.common.notify.Notifier model)
model
- The root object of the EMF model. It will be cloned on default.public void addTransformationRule(DSETransformationRule<?,?> rule)
DSETransformationRule
.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
@Deprecated public final void setSerializerFactory(IStateCoderFactory serializerFactory)
setStateCoderFactory(IStateCoderFactory)
IStateCoderFactory
for which will be used for creating IStateCoder
s.serializerFactory
- The factory.public final void setStateCoderFactory(IStateCoderFactory stateCoderFactory)
IStateCoderFactory
for which will be used for creating IStateCoder
s.stateCoderFactory
- The factory.@Deprecated public void setGuidance(Guidance guidance)
@Deprecated public void setPredicatesForOcVectorResolving(java.util.List<Predicate> predicates)
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 ConcurrentDesignSpace
implementation is used.designspace
- The IDesignSpace
implementation.@Deprecated public void setSolutionStore(ISolutionStore solutionStore)
LocalSearchStrategyBase
abstract class. Use
setSolutionStore(SolutionStore)
instead.ISolutionStore
interface and its implementations for details.solutionStore
- The ISolutionStore
implementation.public void setSolutionStore(SolutionStore solutionStore)
SolutionStore
for details.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()
@Deprecated public java.lang.String prettyPrintSolutions()