From 91584fb3d8bf243ea11ddd4f582690d829c10c0e Mon Sep 17 00:00:00 2001 From: Alexander Diewald <diewald@fortiss.org> Date: Fri, 3 Mar 2017 13:59:17 +0000 Subject: [PATCH] - Move evaluator-specific input validations into the constructors of the evaluators. - Extend the validateInput method in multiple evaluators. - Documentation cleanup. - Cleanup w.r.t. the Exception signature in the factories. --- .../alg/dse/TaskMappingFactory.java | 41 ++++++------ .../ArchitectureExplorationProblemModule.java | 5 +- .../opt4j/problem/EvaluatorWrapper.java | 16 +---- .../ExplorationTargetEvaluatorBase.java | 16 ++++- ...entMultiAllocationConstraintEvaluator.java | 36 +++++++++-- ...ntMultiDislocationConstraintEvaluator.java | 36 +++++++++-- .../constraint/ConstraintEvaluatorBase.java | 8 ++- .../DeadlineConstraintEvaluator.java | 56 ++++++++--------- .../constraint/PeriodConstraintEvaluator.java | 39 ++++++++++-- ...fetyIntegrityLevelConstraintEvaluator.java | 6 +- .../objective/EnergyObjectiveEvaluator.java | 27 ++++++-- .../FailSilentReliabilityEvaluator.java | 9 +-- ...ltDetectionVotingReliabilityEvaluator.java | 5 +- .../objective/ReliabilityEvaluatorBase.java | 38 ++++++++++-- .../sysmodel/FailSilentExecModelFactory.java | 62 ++++--------------- .../FaultDetectionVotingExecModelFactory.java | 58 ++++------------- .../arch/IDeployableComponentAdapter.java | 4 +- .../dse/sysmodel/arch/IResourceAdapter.java | 5 +- .../af3/AF3DeployableComponentAdapter.java | 4 +- .../sysmodel/arch/af3/AF3ResourceAdapter.java | 9 ++- .../service/IExplorationTargetEvaluator.java | 6 +- .../ExplorationEvaluationService.java | 10 ++- .../alg/util/ExplorationAlgUtils.java | 14 +++++ 23 files changed, 288 insertions(+), 222 deletions(-) diff --git a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/TaskMappingFactory.java b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/TaskMappingFactory.java index 20058130..4567e006 100644 --- a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/TaskMappingFactory.java +++ b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/TaskMappingFactory.java @@ -17,7 +17,6 @@ $Id: TaskMappingFactory.java 3730 2016-10-19 15:43:43Z diewald $ +--------------------------------------------------------------------------*/ package org.fortiss.af3.exploration.alg.dse; -import org.conqat.lib.commons.reflect.TypeConversionException; import org.fortiss.af3.exploration.alg.dse.backend.opt4j.create.taskmapping.AbstractTaskMappingCreator; import org.fortiss.af3.exploration.alg.dse.backend.opt4j.create.taskmapping.TaskMappingCreator; import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskgraph.InstantiatedTaskGraphEncoding; @@ -319,14 +318,12 @@ public abstract class TaskMappingFactory<S extends InstantiatedTaskMappingEntry, /** * Decides, which create method has to be called for a specific goal. * - * @throws TypeConversionException - * @throws InstantiationException + * @throws Exception */ @SuppressWarnings("unchecked") public <RT, ET extends ExplorationTarget<RT>> EvaluatorWrapper<?, RT, ET> createEvaluatorWrapper(ExplorationTarget<?> goal, int priority, - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) - throws InstantiationException, TypeConversionException { + SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) throws Exception { ExplorationEvaluationService<?> evalService = ExplorationEvaluationService.getInstance(); EvaluatorWrapper<?, RT, ET> evaluatorWrapper = (EvaluatorWrapper<?, RT, ET>)evalService.createEvalWrapperFor(systemModelAdapter, @@ -382,13 +379,13 @@ public abstract class TaskMappingFactory<S extends InstantiatedTaskMappingEntry, * defines the order of evaluation. * @param systemModelAdapter * the system model deduced from the logical and technical architecture - * @throws TypeConversionException + * @throws Exception + * if the input model validation fails. */ protected <RT, ET extends ExplorationTarget<RT>> EvaluatorWrapper<?, Double, FailureMinObjective> createFailureMinObjectiveWrapper( ExplorationTarget<?> optGoal, int priority, - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) - throws TypeConversionException { + SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) throws Exception { throw new UnsupportedOperationException(GOAL_NOT_IMPL_MSG); } @@ -402,13 +399,13 @@ public abstract class TaskMappingFactory<S extends InstantiatedTaskMappingEntry, * defines the order of evaluation. * @param systemModelAdapter * the system model deduced from the logical and technical architecture - * @throws TypeConversionException + * @throws Exception + * if the input model validation fails. */ protected <RT, ET extends ExplorationTarget<RT>> EvaluatorWrapper<?, Double, DeadlineConstraint> createDeadlineConstraintWrapper( ExplorationTarget<?> optGoal, int priority, - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) - throws TypeConversionException { + SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) throws Exception { throw new UnsupportedOperationException(GOAL_NOT_IMPL_MSG); } @@ -422,12 +419,12 @@ public abstract class TaskMappingFactory<S extends InstantiatedTaskMappingEntry, * defines the order of evaluation. * @param systemModelAdapter * the system model deduced from the logical and technical architecture - * @throws TypeConversionException + * @throws Exception + * if the input model validation fails. */ protected <RT, ET extends ExplorationTarget<RT>> EvaluatorWrapper<?, Double, PeriodConstraint> createPeriodConstraintWrapper(ExplorationTarget<?> optGoal, int priority, - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) - throws TypeConversionException { + SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) throws Exception { throw new UnsupportedOperationException(GOAL_NOT_IMPL_MSG); } @@ -441,13 +438,14 @@ public abstract class TaskMappingFactory<S extends InstantiatedTaskMappingEntry, * defines the order of evaluation. * @param systemModelAdapter * the system model deduced from the logical and technical architecture - * @throws TypeConversionException + * @throws Exception + * if the input model validation fails. */ protected <RT, ET extends ExplorationTarget<RT>> EvaluatorWrapper<?, Boolean, ComponentMultiAllocationConstraint> createComponentMultiAllocationConstraintWrapper(ExplorationTarget<?> optGoal, int priority, SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) - throws TypeConversionException { + throws Exception { throw new UnsupportedOperationException(GOAL_NOT_IMPL_MSG); } @@ -461,13 +459,14 @@ public abstract class TaskMappingFactory<S extends InstantiatedTaskMappingEntry, * defines the order of evaluation. * @param systemModelAdapter * the system model deduced from the logical and technical architecture - * @throws TypeConversionException + * @throws Exception + * if the input model validation fails. */ protected <RT, ET extends ExplorationTarget<RT>> EvaluatorWrapper<?, Boolean, ComponentMultiDislocationConstraint> createComponentMultiDislocationConstraintWrapper(ExplorationTarget<?> optGoal, int priority, SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) - throws TypeConversionException { + throws Exception { throw new UnsupportedOperationException(GOAL_NOT_IMPL_MSG); } @@ -481,13 +480,13 @@ public abstract class TaskMappingFactory<S extends InstantiatedTaskMappingEntry, * defines the order of evaluation. * @param systemModelAdapter * the system model deduced from the logical and technical architecture - * @throws TypeConversionException + * @throws Exception + * if the input model validation fails. */ protected <RT, ET extends ExplorationTarget<RT>> EvaluatorWrapper<?, SIL, SafetyIntegrityLevelConstraint> createSafetyIntegrityLevelConstraintWrapper(ExplorationTarget<?> optGoal, int priority, - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) - throws TypeConversionException { + SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) throws Exception { throw new UnsupportedOperationException(GOAL_NOT_IMPL_MSG); } } diff --git a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/problem/ArchitectureExplorationProblemModule.java b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/problem/ArchitectureExplorationProblemModule.java index 69e95bd5..bd5ff566 100644 --- a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/problem/ArchitectureExplorationProblemModule.java +++ b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/problem/ArchitectureExplorationProblemModule.java @@ -17,6 +17,8 @@ $Id: ArchitectureExplorationProblemModule.java 3451 2016-09-02 13:36:29Z diewald +--------------------------------------------------------------------------*/ package org.fortiss.af3.exploration.alg.dse.backend.opt4j.problem; +import static org.fortiss.af3.exploration.alg.util.ExplorationAlgUtils.rethrow; + import java.util.Set; import org.fortiss.af3.exploration.alg.dse.DSEFactory; @@ -80,8 +82,7 @@ public class ArchitectureExplorationProblemModule try { addGoalEvaluators(archEvaluator); } catch(Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); + throw rethrow(e); } } } diff --git a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/problem/EvaluatorWrapper.java b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/problem/EvaluatorWrapper.java index b762540a..dfe0edba 100644 --- a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/problem/EvaluatorWrapper.java +++ b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/problem/EvaluatorWrapper.java @@ -17,7 +17,6 @@ $Id: EvaluatorWrapper.java 3730 2016-10-19 15:43:43Z diewald $ +--------------------------------------------------------------------------*/ package org.fortiss.af3.exploration.alg.dse.backend.opt4j.problem; -import org.conqat.lib.commons.reflect.TypeConversionException; import org.eclipse.emf.ecore.EObject; import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.ComposablePhenotype; import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.FlatPhenotypeMap; @@ -64,13 +63,9 @@ public class EvaluatorWrapper<P, RT, T extends ExplorationTarget<RT>> implements /** Phenotypes, i.e. (sub-)solutions, to which this operator may be applied to. */ private Class<P> targetPhenotypeType; - /** - * Constructor that creates an evaluator wrapper for a given {@link ExplorationTarget} - * - * @throws TypeConversionException - */ + /** Constructor that creates an evaluator wrapper for a given {@link ExplorationTarget}. */ public EvaluatorWrapper(T goal, IExplorationTargetEvaluator<P, RT, T> evaluator, int priority, - Class<? extends P> primaryInputType) throws TypeConversionException { + Class<? extends P> primaryInputType) { // Construct EA objectives and register it in objective map. Do not give an // "optimization direction" (min/max) in case of constraints. They default to minimization. @@ -88,13 +83,6 @@ public class EvaluatorWrapper<P, RT, T extends ExplorationTarget<RT>> implements new Objective(objectiveName, direction == OptimizationDirectionEnum.MIN ? Sign.MIN : Sign.MAX); - // TODO: modify EvaluatorWrapper to indicate the exception below (allow handling of the - // "validation exception in the UI" - if(!evaluator.validateGoalSpecification()) { - throw new RuntimeException("Error. The optimization goal " + goal.getName() + - " failed the validation. Please re-check this goal."); - } - this.goal = goal; this.evaluator = evaluator; this.targetPriority = priority; diff --git a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/evaluator/ExplorationTargetEvaluatorBase.java b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/evaluator/ExplorationTargetEvaluatorBase.java index caa92795..214f0be3 100644 --- a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/evaluator/ExplorationTargetEvaluatorBase.java +++ b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/evaluator/ExplorationTargetEvaluatorBase.java @@ -51,11 +51,23 @@ public abstract class ExplorationTargetEvaluatorBase<P, RT, T extends Exploratio /** Exploration goal evaluated by this evaluator */ protected T optTarget; - /** Creates an evaluator for a given exploration goal */ + /** Prototype constructor. */ + protected ExplorationTargetEvaluatorBase() { + } + + /** + * Creates an evaluator for a given exploration goal + * + * @throws Exception + * if the input validation fails (has to be implemented by the concrete + * {@link ExplorationTarget} evaluators. + */ protected ExplorationTargetEvaluatorBase( - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, T optTarget) { + SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, T optTarget) throws Exception { this.systemModelAdapter = systemModelAdapter; this.optTarget = optTarget; + + validateInputs(); } /** diff --git a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/evaluator/constraint/ComponentMultiAllocationConstraintEvaluator.java b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/evaluator/constraint/ComponentMultiAllocationConstraintEvaluator.java index 82bdfece..17ee3331 100644 --- a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/evaluator/constraint/ComponentMultiAllocationConstraintEvaluator.java +++ b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/evaluator/constraint/ComponentMultiAllocationConstraintEvaluator.java @@ -17,6 +17,9 @@ $Id: ComponentMultiAllocationConstraintEvaluator.java 3730 2016-10-19 15:43:43Z +--------------------------------------------------------------------------*/ package org.fortiss.af3.exploration.alg.dse.evaluator.constraint; +import static org.fortiss.tooling.common.util.LambdaUtils.mapInOut; + +import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -53,7 +56,7 @@ public class ComponentMultiAllocationConstraintEvaluator<S extends InstantiatedT /** Constructor. */ public ComponentMultiAllocationConstraintEvaluator( SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - ComponentMultiAllocationConstraint optGoal) { + ComponentMultiAllocationConstraint optGoal) throws Exception { super(systemModelAdapter, optGoal); } @@ -65,12 +68,33 @@ public class ComponentMultiAllocationConstraintEvaluator<S extends InstantiatedT return new DoubleValue(0.0); } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + * + * @throws Exception + * if the component or execution unit reference is missing, if the component is not + * part of the deployable component set, or if the referenced execution unit is not + * in the set of deployment targets. + */ @Override - public boolean validateGoalSpecification() { - if(optTarget.getComponent() == null || optTarget.getExecutionUnits().isEmpty()) { - return false; + public boolean validateInputs() throws Exception { + if(optTarget.getComponent() == null || + systemModelAdapter.getDeployableComponentOf(optTarget.getComponent()) == null) { + throw new Exception("The referenced component of the dislocation constraint " + + optTarget.getName() + "(id: " + optTarget.getId() + + ") is not correctly specified." + + " Either it is missing, or not part of the set of deployable components."); } + + if(optTarget.getExecutionUnits().isEmpty() || + !mapInOut(systemModelAdapter.getDeploymentTargets(), t -> t.getObject(), + ArrayList::new).containsAll(optTarget.getExecutionUnits())) { + throw new Exception("The referenced execution unit of the dislocation constraint " + + optTarget.getName() + "(id: " + optTarget.getId() + + ") is not correctly specified." + + " Either it is missing, or not part of the set of deployment targets."); + } + return true; } @@ -99,7 +123,7 @@ public class ComponentMultiAllocationConstraintEvaluator<S extends InstantiatedT @Override public IExplorationTargetEvaluator<T, Boolean, ComponentMultiAllocationConstraint> createEvaluator(SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - ComponentMultiAllocationConstraint explorationTarget) { + ComponentMultiAllocationConstraint explorationTarget) throws Exception { return new ComponentMultiAllocationConstraintEvaluator<>(systemModelAdapter, explorationTarget); } diff --git a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/evaluator/constraint/ComponentMultiDislocationConstraintEvaluator.java b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/evaluator/constraint/ComponentMultiDislocationConstraintEvaluator.java index ae8c8412..56697156 100644 --- a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/evaluator/constraint/ComponentMultiDislocationConstraintEvaluator.java +++ b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/evaluator/constraint/ComponentMultiDislocationConstraintEvaluator.java @@ -17,6 +17,9 @@ $Id: ComponentMultiDislocationConstraintEvaluator.java 3730 2016-10-19 15:43:43Z +--------------------------------------------------------------------------*/ package org.fortiss.af3.exploration.alg.dse.evaluator.constraint; +import static org.fortiss.tooling.common.util.LambdaUtils.mapInOut; + +import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -52,7 +55,7 @@ public class ComponentMultiDislocationConstraintEvaluator<S extends Instantiated /** Constructor. */ public ComponentMultiDislocationConstraintEvaluator( SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - ComponentMultiDislocationConstraint optGoal) { + ComponentMultiDislocationConstraint optGoal) throws Exception { super(systemModelAdapter, optGoal); } @@ -64,12 +67,33 @@ public class ComponentMultiDislocationConstraintEvaluator<S extends Instantiated return new DoubleValue(0.0); } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + * + * @throws Exception + * if the component or execution unit reference is missing, if the component is not + * part of the deployable component set, or if the referenced execution unit is not + * in the set of deployment targets. + */ @Override - public boolean validateGoalSpecification() { - if(optTarget.getComponent() == null || optTarget.getExecutionUnits().isEmpty()) { - return false; + public boolean validateInputs() throws Exception { + if(optTarget.getComponent() == null || + systemModelAdapter.getDeployableComponentOf(optTarget.getComponent()) == null) { + throw new Exception("The referenced component of the dislocation constraint " + + optTarget.getName() + "(id: " + optTarget.getId() + + ") is not correctly specified." + + " Either it is missing, or not part of the set of deployable components."); } + + if(optTarget.getExecutionUnits().isEmpty() || + !mapInOut(systemModelAdapter.getDeploymentTargets(), t -> t.getObject(), + ArrayList::new).containsAll(optTarget.getExecutionUnits())) { + throw new Exception("The referenced execution unit of the dislocation constraint " + + optTarget.getName() + "(id: " + optTarget.getId() + + ") is not correctly specified." + + " Either it is missing, or not part of the set of deployment targets."); + } + return true; } @@ -98,7 +122,7 @@ public class ComponentMultiDislocationConstraintEvaluator<S extends Instantiated @Override public IExplorationTargetEvaluator<T, Boolean, ComponentMultiDislocationConstraint> createEvaluator(SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - ComponentMultiDislocationConstraint explorationTarget) { + ComponentMultiDislocationConstraint explorationTarget) throws Exception { return new ComponentMultiDislocationConstraintEvaluator<>(systemModelAdapter, explorationTarget); } diff --git a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/evaluator/constraint/ConstraintEvaluatorBase.java b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/evaluator/constraint/ConstraintEvaluatorBase.java index 2e0779d9..1ebd8517 100644 --- a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/evaluator/constraint/ConstraintEvaluatorBase.java +++ b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/evaluator/constraint/ConstraintEvaluatorBase.java @@ -48,9 +48,13 @@ public abstract class ConstraintEvaluatorBase<P extends Phenotype, RT, T extends */ private int iterationCount; - /** Creates an evaluator for a given exploration goal */ + /** Prototype constructor. */ + protected ConstraintEvaluatorBase() { + } + + /** Creates an evaluator for a given exploration goal. */ protected ConstraintEvaluatorBase(SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - T goal) { + T goal) throws Exception { super(systemModelAdapter, goal); // Init with -1 due to automatic increment during readout via its getter function. diff --git a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/evaluator/constraint/DeadlineConstraintEvaluator.java b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/evaluator/constraint/DeadlineConstraintEvaluator.java index 42394b8b..bab0cb32 100644 --- a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/evaluator/constraint/DeadlineConstraintEvaluator.java +++ b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/evaluator/constraint/DeadlineConstraintEvaluator.java @@ -71,7 +71,7 @@ public class DeadlineConstraintEvaluator<S extends InstantiatedTaskMappingEntry, /** Objective to track evaluation of this {@link ExplorationTarget}. */ public DeadlineConstraintEvaluator(SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - DeadlineConstraint optGoal) { + DeadlineConstraint optGoal) throws Exception { super(systemModelAdapter, optGoal); sourceDeployableComponent = new ArrayList<>(); targetDeployableComponent = new ArrayList<>(); @@ -80,6 +80,30 @@ public class DeadlineConstraintEvaluator<S extends InstantiatedTaskMappingEntry, .getStartComponent())); targetDeployableComponent.add(systemModelAdapter.getDeployableComponentOf(optTarget .getEndComponent())); + + deadline = optTarget.getDeadline(); + + // TODO: AD: The cast to the AF3 systemmodeladapter breaks the abstration the goals. It + // would be rather required to define the source and sink components as + // IDeployableComponents in the ecore model. The transformation from AF3 components to the + // IDeployableCompontes should be done when the data from the GUI is written to the model. + IDeployableComponentAdapter<?> origStartComponent = + ((AF3SystemModelAdapter)systemModelAdapter).getDeployableComponentAdapter(optTarget + .getStartComponent()); + if(origStartComponent.isInstantiation()) { + sourceDeployableComponent.add(origStartComponent); + } else { + sourceDeployableComponent.addAll(origStartComponent.getReplacementComponents()); + } + + IDeployableComponentAdapter<?> origTargetComponent = + ((AF3SystemModelAdapter)systemModelAdapter).getDeployableComponentAdapter(optTarget + .getEndComponent()); + if(origStartComponent.isInstantiation()) { + targetDeployableComponent.add(origTargetComponent); + } else { + targetDeployableComponent.addAll(origTargetComponent.getReplacementComponents()); + } } /** @@ -142,7 +166,7 @@ public class DeadlineConstraintEvaluator<S extends InstantiatedTaskMappingEntry, /** {@inheritDoc} */ @Override - public boolean validateGoalSpecification() { + public boolean validateInputs() { // TODO: AD: is this check really required here? Shouldn't this be done by the // inputvalidator? if(optTarget.getStartComponent() == null || optTarget.getEndComponent() == null || @@ -150,32 +174,6 @@ public class DeadlineConstraintEvaluator<S extends InstantiatedTaskMappingEntry, return false; } - deadline = optTarget.getDeadline(); - - // Validate whether a task graph can be found for the source and the sink of the deadline - // constraint, such that we can safely assume the specified tasks are scheduleable. - // TODO: AD: The cast to the AF3 systemmodeladapter breaks the abstration the goals. It - // would be rather required to define the source and sink components as - // IDeployableComponents in the ecore model. The transformation from AF3 components to the - // IDeployableCompontes should be done when the data from the GUI is written to the model. - IDeployableComponentAdapter<?> origStartComponent = - ((AF3SystemModelAdapter)systemModelAdapter).getDeployableComponentAdapter(optTarget - .getStartComponent()); - if(origStartComponent.isInstantiation()) { - sourceDeployableComponent.add(origStartComponent); - } else { - sourceDeployableComponent.addAll(origStartComponent.getReplacementComponents()); - } - - IDeployableComponentAdapter<?> origTargetComponent = - ((AF3SystemModelAdapter)systemModelAdapter).getDeployableComponentAdapter(optTarget - .getEndComponent()); - if(origStartComponent.isInstantiation()) { - targetDeployableComponent.add(origTargetComponent); - } else { - targetDeployableComponent.addAll(origTargetComponent.getReplacementComponents()); - } - return true; } @@ -211,7 +209,7 @@ public class DeadlineConstraintEvaluator<S extends InstantiatedTaskMappingEntry, @Override public IExplorationTargetEvaluator<StrictTTSchedule<S, T>, Double, DeadlineConstraint> createEvaluator(SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - DeadlineConstraint explorationTarget) { + DeadlineConstraint explorationTarget) throws Exception { return new DeadlineConstraintEvaluator<S, T>(systemModelAdapter, explorationTarget); } } diff --git a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/evaluator/constraint/PeriodConstraintEvaluator.java b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/evaluator/constraint/PeriodConstraintEvaluator.java index 4024b85a..01137ea3 100644 --- a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/evaluator/constraint/PeriodConstraintEvaluator.java +++ b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/evaluator/constraint/PeriodConstraintEvaluator.java @@ -31,6 +31,7 @@ import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegen import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.Phenotype; import org.fortiss.af3.exploration.alg.dse.backend.opt4j.solution.StrictTTSchedule; import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IDeployableComponentAdapter; +import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IExecutionUnitAdapter; import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.taskgraph.TaskGraph; import org.fortiss.af3.exploration.alg.service.IExplorationTargetEvaluator; @@ -52,11 +53,10 @@ import com.google.common.collect.ClassToInstanceMap; public class PeriodConstraintEvaluator<S extends InstantiatedTaskMappingEntry, T extends InstantiatedTaskMappingEncoding<S>> extends ConstraintEvaluatorBase<StrictTTSchedule<S, T>, Double, PeriodConstraint> { - /** Objective to track evaluation of this {@link ExplorationTarget} */ + /** Objective to track evaluation of this {@link ExplorationTarget}. */ public PeriodConstraintEvaluator(SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - PeriodConstraint optGoal) { + PeriodConstraint optGoal) throws Exception { super(systemModelAdapter, optGoal); - } /** @@ -97,9 +97,36 @@ public class PeriodConstraintEvaluator<S extends InstantiatedTaskMappingEntry, T return new DoubleValue(retval > 0 ? pow(retval * getIterationCountAndIncrement(), 2) : 0); } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + * + * @throws Exception + * if the period of one component is missing, or one combination of a component and + * execution unit has no WCET specified. + */ @Override - public boolean validateGoalSpecification() { + public boolean validateInputs() throws Exception { + // Each deployable component has a period. + for(IDeployableComponentAdapter<?> component : systemModelAdapter.getDeployableComponents()) { + if(component.getTimingRequirementPeriod() == null) { + throw new Exception("The component " + component.getName() + + " has no period specified. Each component that shall be considered" + + " by the DSE must be associated with a period: either defined for" + + " the component itself or indirectly by its ports."); + } + } + + // Check WCETs of each component/execution unit combination. + for(IDeployableComponentAdapter<?> component : systemModelAdapter.getDeployableComponents()) { + for(IExecutionUnitAdapter<?> execUnit : systemModelAdapter.getDeploymentTargets()) { + if(component.getWcet(execUnit) == null) { + throw new Exception("The combination of the component " + component.getName() + + " and the executuion unit " + execUnit.getName() + + " does not have a WCET specified. This parameter is required for the DSE."); + } + } + } + return true; } @@ -135,7 +162,7 @@ public class PeriodConstraintEvaluator<S extends InstantiatedTaskMappingEntry, T @Override public IExplorationTargetEvaluator<StrictTTSchedule<S, T>, Double, PeriodConstraint> createEvaluator(SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - PeriodConstraint explorationTarget) { + PeriodConstraint explorationTarget) throws Exception { return new PeriodConstraintEvaluator<>(systemModelAdapter, explorationTarget); } } diff --git a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/evaluator/constraint/SafetyIntegrityLevelConstraintEvaluator.java b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/evaluator/constraint/SafetyIntegrityLevelConstraintEvaluator.java index 64867f72..76f76056 100644 --- a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/evaluator/constraint/SafetyIntegrityLevelConstraintEvaluator.java +++ b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/evaluator/constraint/SafetyIntegrityLevelConstraintEvaluator.java @@ -63,7 +63,7 @@ public class SafetyIntegrityLevelConstraintEvaluator<S extends InstantiatedTaskM /** Constructor. */ public SafetyIntegrityLevelConstraintEvaluator( SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - SafetyIntegrityLevelConstraint optGoal) { + SafetyIntegrityLevelConstraint optGoal) throws Exception { super(systemModelAdapter, optGoal); } @@ -97,7 +97,7 @@ public class SafetyIntegrityLevelConstraintEvaluator<S extends InstantiatedTaskM /** {@inheritDoc} */ @Override - public boolean validateGoalSpecification() { + public boolean validateInputs() { // Currently, there is no known error case needing validation return true; } @@ -212,7 +212,7 @@ public class SafetyIntegrityLevelConstraintEvaluator<S extends InstantiatedTaskM @Override public IExplorationTargetEvaluator<T, SIL, SafetyIntegrityLevelConstraint> createEvaluator( SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - SafetyIntegrityLevelConstraint explorationTarget) { + SafetyIntegrityLevelConstraint explorationTarget) throws Exception { return new SafetyIntegrityLevelConstraintEvaluator<S, T>(systemModelAdapter, explorationTarget); } diff --git a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/evaluator/objective/EnergyObjectiveEvaluator.java b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/evaluator/objective/EnergyObjectiveEvaluator.java index c6f3e92b..6b795aea 100644 --- a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/evaluator/objective/EnergyObjectiveEvaluator.java +++ b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/evaluator/objective/EnergyObjectiveEvaluator.java @@ -55,12 +55,11 @@ public class EnergyObjectiveEvaluator<S extends TaskMappingEntry, T extends Task /** Creates a template energy objective evaluator */ public EnergyObjectiveEvaluator() { - super(null, null); } /** Creates an energy objective evaluator */ public EnergyObjectiveEvaluator(SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - EnergyMinObjective goal) { + EnergyMinObjective goal) throws Exception { super(systemModelAdapter, goal); } @@ -123,9 +122,27 @@ public class EnergyObjectiveEvaluator<S extends TaskMappingEntry, T extends Task return deployedEnergyDemand; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + * + * @throws Exception + */ @Override - public boolean validateGoalSpecification() { + public boolean validateInputs() throws Exception { + // TODO: If constraints exist for the allocation, only consider component / execution unit + // allocations that are valid acc. to these constraints. + for(IDeployableComponentAdapter<?> component : systemModelAdapter.getDeployableComponents()) { + for(IExecutionUnitAdapter<?> execUnit : systemModelAdapter.getDeploymentTargets()) { + if(component.getEnergyConsumption(execUnit) == null) { + throw new Exception( + "The energy consumption of the allocation of the component " + + component.getName() + " to the execution unit " + + execUnit.getName() + " has not been defined. " + + "It is required for the energy minimization objective."); + } + } + } + return true; } @@ -147,7 +164,7 @@ public class EnergyObjectiveEvaluator<S extends TaskMappingEntry, T extends Task @Override public IExplorationTargetEvaluator<StrictTTSchedule<S, T>, Double, EnergyMinObjective> createEvaluator(SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - EnergyMinObjective explorationTarget) { + EnergyMinObjective explorationTarget) throws Exception { return new EnergyObjectiveEvaluator<>(systemModelAdapter, explorationTarget); } } diff --git a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/evaluator/objective/FailSilentReliabilityEvaluator.java b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/evaluator/objective/FailSilentReliabilityEvaluator.java index 2926e8ee..48bc9578 100644 --- a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/evaluator/objective/FailSilentReliabilityEvaluator.java +++ b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/evaluator/objective/FailSilentReliabilityEvaluator.java @@ -44,7 +44,7 @@ public class FailSilentReliabilityEvaluator extends /** Creates a fail-silent reliability analysis evaluator for a given exploration goal. */ public FailSilentReliabilityEvaluator(SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - FailureMinObjective goal) { + FailureMinObjective goal) throws Exception { super(systemModelAdapter, goal); } @@ -91,13 +91,6 @@ public class FailSilentReliabilityEvaluator extends return (one.subtract(overallSuccRate)).doubleValue(); } - /** {@inheritDoc} */ - @Override - public boolean validateGoalSpecification() { - // TODO Auto-generated method stub - return true; - } - /** {@inheritDoc} */ @Override public Collection<Class<?>> getRequiredInputTypes() { diff --git a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/evaluator/objective/FaultDetectionVotingReliabilityEvaluator.java b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/evaluator/objective/FaultDetectionVotingReliabilityEvaluator.java index b5903574..1c47ea48 100644 --- a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/evaluator/objective/FaultDetectionVotingReliabilityEvaluator.java +++ b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/evaluator/objective/FaultDetectionVotingReliabilityEvaluator.java @@ -123,7 +123,8 @@ public class FaultDetectionVotingReliabilityEvaluator * goal. */ public FaultDetectionVotingReliabilityEvaluator( - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, FailureMinObjective target) { + SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, FailureMinObjective target) + throws Exception { super(systemModelAdapter, target); } @@ -373,7 +374,7 @@ public class FaultDetectionVotingReliabilityEvaluator /** {@inheritDoc} */ @Override - public boolean validateGoalSpecification() { + public boolean validateInputs() { // TODO Auto-generated method stub return true; } diff --git a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/evaluator/objective/ReliabilityEvaluatorBase.java b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/evaluator/objective/ReliabilityEvaluatorBase.java index a8d3f520..f8d5dd1c 100644 --- a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/evaluator/objective/ReliabilityEvaluatorBase.java +++ b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/evaluator/objective/ReliabilityEvaluatorBase.java @@ -39,6 +39,7 @@ import org.fortiss.af3.exploration.alg.dse.backend.opt4j.solution.StrictTTSchedu import org.fortiss.af3.exploration.alg.dse.evaluator.ExplorationTargetEvaluatorBase; import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IDeployableComponentAdapter; import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IExecutionUnitAdapter; +import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IResourceAdapter; import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.taskgraph.DefaultTaskGraph; import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.taskgraph.TaskGraph; @@ -78,13 +79,25 @@ public abstract class ReliabilityEvaluatorBase<S extends InstantiatedTaskMapping */ IDeployableComponentAdapter<?> targetComponent; - /** Constructor. */ + /** + * Constructor. + * + * @throws Exception + * if the {@link IDeployableComponentAdapter} specifying the component to minimize + * the failure rate for is missing. + */ public ReliabilityEvaluatorBase(SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - FailureMinObjective target) { + FailureMinObjective target) throws Exception { super(systemModelAdapter, target); targetComponent = systemModelAdapter.getDeployableComponentOf(optTarget.getTargetComponent()); + if(targetComponent == null) { + throw new Exception("The Component for which to minimize the failure rate is not" + + " correctly specified. It is either not defined, or it is not part of the" + + " set of deployable Components. The error is caused by " + optTarget.getName() + + "(id: " + optTarget.getId() + ")."); + } // TODO: Check for different implementation of this single initialization for different // reliability goals. In particular, it must be checked if the current implementation with a @@ -263,10 +276,25 @@ public abstract class ReliabilityEvaluatorBase<S extends InstantiatedTaskMapping protected abstract double evaluateInternal(StrictTTSchedule<S, T> schedule, T itmEnc, DefaultTaskGraph taskGraph, FailureType failureProbabilityType); - /** {@inheritDoc} */ + /** + * {@inheritDoc} + * + * @throws Exception + * if the failure rate of physical resources are missing. + */ @Override - public boolean validateGoalSpecification() { - // TODO: readd sinkComponent check, currently ignored for porting + public boolean validateInputs() throws Exception { + // TODO: Proper modularity requires to get rid of the types phys. platform element and + // Executionunit. + for(IResourceAdapter<?> resource : systemModelAdapter.getAvailableResources()) { + if((!resource.isVirtual() || resource instanceof IExecutionUnitAdapter) && + resource.getFailureRate() == null) { + throw new Exception("The failure rate of the platform resource " + + resource.getName() + " or its referenced physical entity is not defined." + + " It is required for the Reliability analysis."); + } + } + return true; } diff --git a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/FailSilentExecModelFactory.java b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/FailSilentExecModelFactory.java index d9923204..4c5a1aba 100644 --- a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/FailSilentExecModelFactory.java +++ b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/FailSilentExecModelFactory.java @@ -17,7 +17,6 @@ $Id: FailSilentExecModelFactory.java 3730 2016-10-19 15:43:43Z diewald $ +--------------------------------------------------------------------------*/ package org.fortiss.af3.exploration.alg.dse.sysmodel; -import org.conqat.lib.commons.reflect.TypeConversionException; import org.fortiss.af3.exploration.alg.dse.TaskMappingFactory; import org.fortiss.af3.exploration.alg.dse.backend.opt4j.create.taskmapping.FailSilentTaskMappingCreator; import org.fortiss.af3.exploration.alg.dse.backend.opt4j.create.taskmapping.TaskMappingCreator; @@ -100,15 +99,6 @@ public class FailSilentExecModelFactory extends return new FailSilentTaskMappingCreator(dse, systemModelAdapter, execDepGraph); } - // /** Creates a TaskMappingCreator that matches the given execution model. */ - // @Override - // public TaskMappingCreator<FailSilentTaskMappingEntry, FailSilentTaskMappingEncoding> - // createTaskMappingCreator(DseSpecification dse, - // SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - // AbstractTaskMappingEncoding abstractEnc) { - // return new FailSilentTaskMappingCreator(dse, systemModelAdapter, abstractEnc); - // } - /* * Construct execution model specific operators */ @@ -209,17 +199,12 @@ public class FailSilentExecModelFactory extends * Construct Evaluators for Optimization Goals */ - /** - * {@inheritDoc} - * - * @throws TypeConversionException - */ + /** {@inheritDoc} */ @Override @SuppressWarnings("unchecked") public <RT, ET extends ExplorationTarget<RT>> EvaluatorWrapper<?, Double, FailureMinObjective> createFailureMinObjectiveWrapper(ExplorationTarget<?> goal, int priority, - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) - throws TypeConversionException { + SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) throws Exception { return new EvaluatorWrapper<StrictTTSchedule<FailSilentTaskMappingEntry, FailSilentTaskMappingEncoding>, Double, FailureMinObjective>( (FailureMinObjective)goal, new FailSilentReliabilityEvaluator(systemModelAdapter, (FailureMinObjective)goal), @@ -227,17 +212,12 @@ public class FailSilentExecModelFactory extends (Class<? extends StrictTTSchedule<FailSilentTaskMappingEntry, FailSilentTaskMappingEncoding>>)StrictTTSchedule.class); } - /** - * {@inheritDoc} - * - * @throws TypeConversionException - */ + /** {@inheritDoc} */ @SuppressWarnings("unchecked") @Override public <RT, ET extends ExplorationTarget<RT>> EvaluatorWrapper<?, Double, DeadlineConstraint> createDeadlineConstraintWrapper(ExplorationTarget<?> goal, int priority, - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) - throws TypeConversionException { + SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) throws Exception { return new EvaluatorWrapper<StrictTTSchedule<FailSilentTaskMappingEntry, FailSilentTaskMappingEncoding>, Double, DeadlineConstraint>( (DeadlineConstraint)goal, new DeadlineConstraintEvaluator<FailSilentTaskMappingEntry, FailSilentTaskMappingEncoding>( @@ -246,17 +226,12 @@ public class FailSilentExecModelFactory extends (Class<? extends StrictTTSchedule<FailSilentTaskMappingEntry, FailSilentTaskMappingEncoding>>)StrictTTSchedule.class); } - /** - * {@inheritDoc} - * - * @throws TypeConversionException - */ + /** {@inheritDoc} */ @SuppressWarnings("unchecked") @Override public <RT, ET extends ExplorationTarget<RT>> EvaluatorWrapper<?, Double, PeriodConstraint> createPeriodConstraintWrapper(ExplorationTarget<?> goal, int priority, - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) - throws TypeConversionException { + SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) throws Exception { return new EvaluatorWrapper<StrictTTSchedule<FailSilentTaskMappingEntry, FailSilentTaskMappingEncoding>, Double, PeriodConstraint>( (PeriodConstraint)goal, new PeriodConstraintEvaluator<FailSilentTaskMappingEntry, FailSilentTaskMappingEncoding>( @@ -265,18 +240,14 @@ public class FailSilentExecModelFactory extends (Class<? extends StrictTTSchedule<FailSilentTaskMappingEntry, FailSilentTaskMappingEncoding>>)StrictTTSchedule.class); } - /** - * {@inheritDoc} - * - * @throws TypeConversionException - */ + /** {@inheritDoc} */ // TODO: adjust when the constraint is defined for mappings. @Override public <RT, ET extends ExplorationTarget<RT>> EvaluatorWrapper<?, Boolean, ComponentMultiAllocationConstraint> createComponentMultiAllocationConstraintWrapper(ExplorationTarget<?> goal, int priority, SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) - throws TypeConversionException { + throws Exception { return new EvaluatorWrapper<FailSilentTaskMappingEncoding, Boolean, ComponentMultiAllocationConstraint>( (ComponentMultiAllocationConstraint)goal, new ComponentMultiAllocationConstraintEvaluator<FailSilentTaskMappingEntry, FailSilentTaskMappingEncoding>( @@ -284,18 +255,14 @@ public class FailSilentExecModelFactory extends FailSilentTaskMappingEncoding.class); } - /** - * {@inheritDoc} - * - * @throws TypeConversionException - */ + /** {@inheritDoc} */ // TODO: adjust when the constraint is defined for mappings. @Override public <RT, ET extends ExplorationTarget<RT>> EvaluatorWrapper<?, Boolean, ComponentMultiDislocationConstraint> createComponentMultiDislocationConstraintWrapper(ExplorationTarget<?> goal, int priority, SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) - throws TypeConversionException { + throws Exception { return new EvaluatorWrapper<FailSilentTaskMappingEncoding, Boolean, ComponentMultiDislocationConstraint>( (ComponentMultiDislocationConstraint)goal, new ComponentMultiDislocationConstraintEvaluator<FailSilentTaskMappingEntry, FailSilentTaskMappingEncoding>( @@ -303,17 +270,12 @@ public class FailSilentExecModelFactory extends FailSilentTaskMappingEncoding.class); } - /** - * {@inheritDoc} - * - * @throws TypeConversionException - */ + /** {@inheritDoc} */ @Override public <RT, ET extends ExplorationTarget<RT>> EvaluatorWrapper<?, SIL, SafetyIntegrityLevelConstraint> createSafetyIntegrityLevelConstraintWrapper(ExplorationTarget<?> goal, int priority, - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) - throws TypeConversionException { + SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) throws Exception { return new EvaluatorWrapper<FailSilentTaskMappingEncoding, SIL, SafetyIntegrityLevelConstraint>( (SafetyIntegrityLevelConstraint)goal, new SafetyIntegrityLevelConstraintEvaluator<FailSilentTaskMappingEntry, FailSilentTaskMappingEncoding>( diff --git a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/FaultDetectionVotingExecModelFactory.java b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/FaultDetectionVotingExecModelFactory.java index d524ac2c..d574ff34 100644 --- a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/FaultDetectionVotingExecModelFactory.java +++ b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/FaultDetectionVotingExecModelFactory.java @@ -17,7 +17,6 @@ $Id: FaultDetectionVotingExecModelFactory.java 3730 2016-10-19 15:43:43Z diewald +--------------------------------------------------------------------------*/ package org.fortiss.af3.exploration.alg.dse.sysmodel; -import org.conqat.lib.commons.reflect.TypeConversionException; import org.fortiss.af3.exploration.alg.dse.TaskMappingFactory; import org.fortiss.af3.exploration.alg.dse.backend.opt4j.create.taskmapping.FaultDetectionVotingTaskMappingCreator; import org.fortiss.af3.exploration.alg.dse.backend.opt4j.create.taskmapping.TaskMappingCreator; @@ -103,17 +102,6 @@ public class FaultDetectionVotingExecModelFactory return new FaultDetectionVotingTaskMappingCreator(dse, systemModelAdapter, execDepGraph); } - // /** Creates a TaskMappingCreator that matches the given execution model. */ - // @Override - // public - // TaskMappingCreator<FaultDetectionVotingTaskMappingEntry, - // FaultDetectionVotingTaskMappingEncoding> - // createTaskMappingCreator(DseSpecification dse, - // SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - // AbstractTaskMappingEncoding abstractEnc) { - // return new FaultDetectionVotingTaskMappingCreator(dse, systemModelAdapter, abstractEnc); - // } - /* * Construct execution model specific operators */ @@ -220,8 +208,7 @@ public class FaultDetectionVotingExecModelFactory @Override public <RT, ET extends ExplorationTarget<RT>> EvaluatorWrapper<?, Double, FailureMinObjective> createFailureMinObjectiveWrapper(ExplorationTarget<?> goal, int priority, - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) - throws TypeConversionException { + SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) throws Exception { return new EvaluatorWrapper<StrictTTSchedule<FaultDetectionVotingTaskMappingEntry, FaultDetectionVotingTaskMappingEncoding>, Double, FailureMinObjective>( (FailureMinObjective)goal, new FaultDetectionVotingReliabilityEvaluator(systemModelAdapter, @@ -230,17 +217,12 @@ public class FaultDetectionVotingExecModelFactory (Class<? extends StrictTTSchedule<FaultDetectionVotingTaskMappingEntry, FaultDetectionVotingTaskMappingEncoding>>)StrictTTSchedule.class); } - /** - * {@inheritDoc} - * - * @throws TypeConversionException - */ + /** {@inheritDoc} */ @SuppressWarnings("unchecked") @Override public <RT, ET extends ExplorationTarget<RT>> EvaluatorWrapper<?, Double, DeadlineConstraint> createDeadlineConstraintWrapper(ExplorationTarget<?> goal, int priority, - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) - throws TypeConversionException { + SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) throws Exception { return new EvaluatorWrapper<StrictTTSchedule<FaultDetectionVotingTaskMappingEntry, FaultDetectionVotingTaskMappingEncoding>, Double, DeadlineConstraint>( (DeadlineConstraint)goal, new DeadlineConstraintEvaluator<FaultDetectionVotingTaskMappingEntry, FaultDetectionVotingTaskMappingEncoding>( @@ -249,17 +231,12 @@ public class FaultDetectionVotingExecModelFactory (Class<? extends StrictTTSchedule<FaultDetectionVotingTaskMappingEntry, FaultDetectionVotingTaskMappingEncoding>>)StrictTTSchedule.class); } - /** - * {@inheritDoc} - * - * @throws TypeConversionException - */ + /** {@inheritDoc} */ @SuppressWarnings("unchecked") @Override public <RT, ET extends ExplorationTarget<RT>> EvaluatorWrapper<?, Double, PeriodConstraint> createPeriodConstraintWrapper(ExplorationTarget<?> goal, int priority, - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) - throws TypeConversionException { + SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) throws Exception { return new EvaluatorWrapper<StrictTTSchedule<FaultDetectionVotingTaskMappingEntry, FaultDetectionVotingTaskMappingEncoding>, Double, PeriodConstraint>( (PeriodConstraint)goal, new PeriodConstraintEvaluator<FaultDetectionVotingTaskMappingEntry, FaultDetectionVotingTaskMappingEncoding>( @@ -268,18 +245,14 @@ public class FaultDetectionVotingExecModelFactory (Class<? extends StrictTTSchedule<FaultDetectionVotingTaskMappingEntry, FaultDetectionVotingTaskMappingEncoding>>)StrictTTSchedule.class); } - /** - * {@inheritDoc} - * - * @throws TypeConversionException - */ + /** {@inheritDoc} */ // TODO: adjust when the constraint is defined for mappings. @Override public <RT, ET extends ExplorationTarget<RT>> EvaluatorWrapper<?, Boolean, ComponentMultiAllocationConstraint> createComponentMultiAllocationConstraintWrapper(ExplorationTarget<?> goal, int priority, SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) - throws TypeConversionException { + throws Exception { return new EvaluatorWrapper<FaultDetectionVotingTaskMappingEncoding, Boolean, ComponentMultiAllocationConstraint>( (ComponentMultiAllocationConstraint)goal, new ComponentMultiAllocationConstraintEvaluator<FaultDetectionVotingTaskMappingEntry, FaultDetectionVotingTaskMappingEncoding>( @@ -287,18 +260,14 @@ public class FaultDetectionVotingExecModelFactory FaultDetectionVotingTaskMappingEncoding.class); } - /** - * {@inheritDoc} - * - * @throws TypeConversionException - */ + /** {@inheritDoc} */ // TODO: adjust when the constraint is defined for mappings. @Override public <RT, ET extends ExplorationTarget<RT>> EvaluatorWrapper<?, Boolean, ComponentMultiDislocationConstraint> createComponentMultiDislocationConstraintWrapper(ExplorationTarget<?> goal, int priority, SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) - throws TypeConversionException { + throws Exception { return new EvaluatorWrapper<FaultDetectionVotingTaskMappingEncoding, Boolean, ComponentMultiDislocationConstraint>( (ComponentMultiDislocationConstraint)goal, new ComponentMultiDislocationConstraintEvaluator<FaultDetectionVotingTaskMappingEntry, FaultDetectionVotingTaskMappingEncoding>( @@ -306,17 +275,12 @@ public class FaultDetectionVotingExecModelFactory FaultDetectionVotingTaskMappingEncoding.class); } - /** - * {@inheritDoc} - * - * @throws TypeConversionException - */ + /** {@inheritDoc} */ @Override public <RT, ET extends ExplorationTarget<RT>> EvaluatorWrapper<?, SIL, SafetyIntegrityLevelConstraint> createSafetyIntegrityLevelConstraintWrapper(ExplorationTarget<?> goal, int priority, - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) - throws TypeConversionException { + SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) throws Exception { return new EvaluatorWrapper<FaultDetectionVotingTaskMappingEncoding, SIL, SafetyIntegrityLevelConstraint>( (SafetyIntegrityLevelConstraint)goal, new SafetyIntegrityLevelConstraintEvaluator<FaultDetectionVotingTaskMappingEntry, FaultDetectionVotingTaskMappingEncoding>( diff --git a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/IDeployableComponentAdapter.java b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/IDeployableComponentAdapter.java index 073bdc99..eb1e6a3a 100644 --- a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/IDeployableComponentAdapter.java +++ b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/IDeployableComponentAdapter.java @@ -37,13 +37,13 @@ public interface IDeployableComponentAdapter<T> extends IRequestAdapter<T>, Clon * Returns the WCET if this {@link IDeployableComponentAdapter} would be executed on the given * {@link IExecutionUnitAdapter}. */ - public double getWcet(IExecutionUnitAdapter<?> executionUnit); + public Double getWcet(IExecutionUnitAdapter<?> executionUnit); /** * Returns the consumed energy if this {@link IDeployableComponentAdapter} would be executed on * the given {@link IExecutionUnitAdapter}. */ - public double getEnergyConsumption(IExecutionUnitAdapter<?> executionUnit); + public Double getEnergyConsumption(IExecutionUnitAdapter<?> executionUnit); /** Returns the minimum required safety integrity level of the deployable component. */ public Enumerator getRequiredSafetyIntegrityLevel(); diff --git a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/IResourceAdapter.java b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/IResourceAdapter.java index b9bd98b7..7ba393db 100644 --- a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/IResourceAdapter.java +++ b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/IResourceAdapter.java @@ -27,6 +27,9 @@ package org.fortiss.af3.exploration.alg.dse.sysmodel.arch; * @ConQAT.Rating YELLOW Hash: DC64328CEBAFBE1391D36F20D349779B */ public interface IResourceAdapter<T> extends IModelElementAdapter<T> { + /** Predicate if the resource is a virtual or a HW resource. */ + boolean isVirtual(); + /** Returns the resource's failure rate (in FIT) */ - public double getFailureRate(); + Double getFailureRate(); } diff --git a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/af3/AF3DeployableComponentAdapter.java b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/af3/AF3DeployableComponentAdapter.java index 4155f790..6d76c630 100644 --- a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/af3/AF3DeployableComponentAdapter.java +++ b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/af3/AF3DeployableComponentAdapter.java @@ -143,13 +143,13 @@ public class AF3DeployableComponentAdapter extends AF3RequestAdapter<Component> /** {@inheritDoc} */ @Override - public double getWcet(IExecutionUnitAdapter<?> executionUnit) { + public Double getWcet(IExecutionUnitAdapter<?> executionUnit) { return wcetMap.get(executionUnit); } /** {@inheritDoc} */ @Override - public double getEnergyConsumption(IExecutionUnitAdapter<?> executionUnit) { + public Double getEnergyConsumption(IExecutionUnitAdapter<?> executionUnit) { return energyMap.get(executionUnit); } diff --git a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/af3/AF3ResourceAdapter.java b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/af3/AF3ResourceAdapter.java index ad9283df..f09331b5 100644 --- a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/af3/AF3ResourceAdapter.java +++ b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/af3/AF3ResourceAdapter.java @@ -20,6 +20,7 @@ package org.fortiss.af3.exploration.alg.dse.sysmodel.arch.af3; import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IExecutionUnitAdapter; import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IResourceAdapter; import org.fortiss.af3.platform.model.ExecutionUnit; +import org.fortiss.af3.platform.model.IVirtualizationPlatformArchitectureElement; import org.fortiss.tooling.base.model.element.IModelElement; /** @@ -48,7 +49,13 @@ public class AF3ResourceAdapter<T extends IModelElement> extends AF3ModelElement /** {@inheritDoc} */ @Override - public double getFailureRate() { + public Double getFailureRate() { return failureRate; } + + /** {@inheritDoc} */ + @Override + public boolean isVirtual() { + return getObject() instanceof IVirtualizationPlatformArchitectureElement; + } } diff --git a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/service/IExplorationTargetEvaluator.java b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/service/IExplorationTargetEvaluator.java index dd13ceee..f60bf203 100644 --- a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/service/IExplorationTargetEvaluator.java +++ b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/service/IExplorationTargetEvaluator.java @@ -52,7 +52,7 @@ public interface IExplorationTargetEvaluator<P, RT, S extends ExplorationTarget< ClassToInstanceMap<EObject> transformedModels); /** Validate if objective has been correctly specified. */ - public boolean validateGoalSpecification(); + public boolean validateInputs() throws Exception; /** * Returns the set of input types (classes) which are required for the enclosed @@ -76,8 +76,10 @@ public interface IExplorationTargetEvaluator<P, RT, S extends ExplorationTarget< * @return A new instance of {@code this} {@link IExplorationTargetEvaluator}. * @throws InstantiationException * If the instantiation of a new {@link IExplorationTargetEvaluator} fails. + * @throws Exception + * if the input validation fails. */ IExplorationTargetEvaluator<P, RT, S> createEvaluator( SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, S explorationTarget) - throws InstantiationException; + throws InstantiationException, Exception; } diff --git a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/service/internal/ExplorationEvaluationService.java b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/service/internal/ExplorationEvaluationService.java index d187d8d9..80d4fcd0 100644 --- a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/service/internal/ExplorationEvaluationService.java +++ b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/service/internal/ExplorationEvaluationService.java @@ -24,7 +24,6 @@ import java.util.Collection; import java.util.HashSet; import java.util.Set; -import org.conqat.lib.commons.reflect.TypeConversionException; import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.evaluate.ComposableEvaluator; import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.ComposablePhenotype; import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.Phenotype; @@ -210,15 +209,14 @@ public class ExplorationEvaluationService<T extends IExplorationTargetEvaluator< * @param explorationTarget * {@link ExplorationTarget} to create an {@link EvaluatorWrapper} for. * @return The instantiated {@link EvaluatorWrapper}. - * @throws TypeConversionException - * If some model element cannot be translated to the internal representation of the - * DSE. + * @throws Exception + * if some required input is missing. * @throws InstantiationException - * If the instantiation of the {@link EvaluatorWrapper} fails. + * if the construction of the evaluator fails due to some unknown reason. */ public <P, RT, ET extends ExplorationTarget<RT>> EvaluatorWrapper<P, RT, ET> createEvalWrapperFor(SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - ET explorationTarget) throws TypeConversionException, InstantiationException { + ET explorationTarget) throws InstantiationException, Exception { @SuppressWarnings("unchecked") Collection<IExplorationTargetEvaluator<P, RT, ET>> evaluatorHandlers = (Collection<IExplorationTargetEvaluator<P, RT, ET>>)getInstance() .getRegisteredHandlers(explorationTarget.getClass()); diff --git a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/util/ExplorationAlgUtils.java b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/util/ExplorationAlgUtils.java index 959d40f9..32309836 100644 --- a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/util/ExplorationAlgUtils.java +++ b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/util/ExplorationAlgUtils.java @@ -1049,4 +1049,18 @@ public class ExplorationAlgUtils { } return status; } + + /** + * Takes a checked Exception and allows its usage in a RuntimeException based environment. + * + * @param exception + * Exception to wrap. + * @return not used, only rethrows the Exception. + * @throws T + * the original Exception. + */ + @SuppressWarnings("unchecked") + public static <T extends Exception> RuntimeException rethrow(Exception exception) throws T { + throw (T)exception; // rely on vacuous cast + } } -- GitLab