Commit 255658c4 authored by Alexander Diewald's avatar Alexander Diewald

DSE-EMM: Remove the subTargets field

* Sub-Targets of IExplorationTargets are not used.
* An equivalent and additional (but hidden) field existed for
  sub-constrains of SMTObjectives. They are considered only in the
  transformation code of DSE backends. Such implict constraints are
  only intended to bound user-defined objectives.
* Resolve several warnings in UI code.

Issue-Ref: 3365
Issue-Url: https://af3-developer.fortiss.org/issues/3365Signed-off-by: Alexander Diewald's avatarAlexander Diewald <diewald@fortiss.org>
parent b8d08abe
......@@ -4,7 +4,7 @@ BasicScheduleConstraint.java 8b054b5ad961295b97936e26240eb33a10a1ee9a YELLOW
ConstraintDefinitionUtils.java 8a709a9cd10edd36d1ac3ed0ded0c938aa010f12 GREEN
ConstraintTransformationAdapter.java 8806164d71491c7d1af665990dd154f2275cad8c GREEN
DSMLTransformationService.java 2c19395bffa10cdaf2e7f38fdb592254289e659c GREEN
DSMLtoSMTTransformator.java 81ef8c9fc1598a7d28907fe9b165b4667bdeafb1 YELLOW
DSMLtoSMTTransformator.java 32431ae9bcbca84d1c7cb9726f77af67019da250 YELLOW
DefaultExpressionTransformator.java 9f572be21d1d96bc3d7604695678e57035a1b82e GREEN
DeploScheduleRun.java 2b07bd6b40cf4ce2eabc12198f6db3b9655bed25 GREEN
DeploymentRun.java 4b2d0a6d64bb5a6efabc2ee9bf933cc523843ac8 GREEN
......@@ -15,5 +15,5 @@ NonQuantifiedExpressionTransformator.java 9ee437aeaf518d94b81e34a275cd01b87cfca1
QuantifiedExpressionTransformator.java 01e7162b24d16adb23f646cf02340879e8a18205 GREEN
SMTTransformationUtils.java 376da0f5dafb350b49004c7d75fb8858b53d3b7d GREEN
ScheduleRun.java 43d869a9adfbebe34c34f1ebb0bc8e0600f45b9d GREEN
SolverRun.java d0707217f6f63ee19e09848d3706fd3714978cfc YELLOW
SolverRun.java be9794b2be0fd203a31435548abe9d9945bc2160 YELLOW
TimingConstraintDefinition.java 92281277d99bb52b72c1cb898bba944b3b9a24f7 YELLOW
......@@ -167,23 +167,15 @@ public class DSMLtoSMTTransformator {
if(explorationTgt instanceof IExplorationConstraint) {
IExplorationConstraint<?> smtConstraint =
(IExplorationConstraint<?>)explorationTgt;
if(smtConstraint.getContainedTargets().isEmpty()) {
Expr smtExpr = extractSMTExpr(smtConstraint);
addExpression(smtExpr, explorationTgt);
} else {
for(IExplorationTarget<?> t : smtConstraint.getContainedTargets()) {
IExplorationConstraint<?> subCon = (IExplorationConstraint<?>)t;
Expr smtExpr = extractSMTExpr(subCon);
addExpression(smtExpr, subCon);
}
}
Expr smtExpr = extractSMTExpr(smtConstraint);
addExpression(smtExpr, explorationTgt);
} else if(explorationTgt instanceof IExplorationObjective) {
IExplorationObjective<?> smtObjective =
(IExplorationObjective<?>)explorationTgt;
for(IExplorationTarget<?> t : smtObjective.getContainedTargets()) {
IExplorationConstraint<?> subCon = (IExplorationConstraint<?>)t;
Expr smtExpr = extractSMTExpr(subCon);
addExpression(smtExpr, subCon);
for(IExplorationConstraint<?> constraint : smtObjective
.getImplicitConstraints()) {
Expr smtExpr = extractSMTExpr(constraint);
addExpression(smtExpr, constraint);
}
IExpression expression = smtObjective.getExpression();
......
......@@ -584,15 +584,17 @@ public abstract class SolverRun {
" returned value from the solver is not an integer value.");
}
} else {
error(getDefault(), "Could not transform " + z3EvalResult +
" to the exptected type " + expectedType.getSimpleName() + ".");
continue;
String errStr = "Could not transform " + z3EvalResult +
" to the exptected type " + expectedType.getSimpleName() + ".";
error(getDefault(), errStr);
throw new Z3Exception(errStr);
}
singleSolution.put(castedObjective, result);
}
} catch(Z3Exception e) {
error(getDefault(), e.getMessage());
throw new Z3Exception(e.getMessage());
}
}
}
......@@ -9,4 +9,4 @@ HelpView.java 5cd89049b0373cacd8fc7e431870260bd81b93c1 GREEN
HierarchicElementContentProvider.java 8a393f0b867ce5616292910a5287b0e39c6d48b7 GREEN
PatternFXControllerBase.java 76c63bb40e6de376b18e0589066a83132a3d7507 YELLOW
SuperSetContentProvider.java 7e44e42675740b08582dfbc3e4b67ec9bdd73b93 GREEN
SynthesisViewBase.java e432cee729d0df5a82b2157383e702fe46130490 YELLOW
SynthesisViewBase.java 908f9ae2bb8cd570ac32861375f46343024f814c YELLOW
......@@ -38,6 +38,7 @@ import static org.fortiss.tooling.kernel.ui.util.MessageUtilsExtended.showInfoIn
import static org.fortiss.tooling.kernel.ui.util.SelectionUtils.checkAndPickFirst;
import static org.fortiss.tooling.kernel.utils.EcoreUtils.copy;
import static org.fortiss.tooling.kernel.utils.EcoreUtils.getChildrenWithType;
import static org.fortiss.tooling.kernel.utils.EcoreUtils.pickInstanceOf;
import static org.fortiss.tooling.kernel.utils.KernelModelElementUtils.runAsCommand;
import static org.fortiss.tooling.kernel.utils.LoggingUtils.error;
import static org.fortiss.tooling.kernel.utils.LoggingUtils.showInfo;
......@@ -59,7 +60,6 @@ import java.util.Map.Entry;
import java.util.NoSuchElementException;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
import javax.management.modelmbean.InvalidTargetObjectTypeException;
......@@ -113,9 +113,9 @@ import org.eclipse.swt.widgets.Tree;
import org.eclipse.ui.forms.widgets.ExpandableComposite;
import org.eclipse.ui.forms.widgets.Section;
import org.fortiss.af3.exploration.dseml.model.expression.SuperSet;
import org.fortiss.af3.exploration.model.ExplorationSpecification;
import org.fortiss.af3.exploration.model.IExplorationConstraint;
import org.fortiss.af3.exploration.model.IExplorationObjective;
import org.fortiss.af3.exploration.model.ExplorationSpecification;
import org.fortiss.af3.exploration.model.IExplorationTarget;
import org.fortiss.af3.exploration.model.SuperSetMap;
import org.fortiss.af3.exploration.model.project.DSE;
......@@ -302,9 +302,11 @@ public abstract class SynthesisViewBase extends DSEPerspectiveViewBase {
return;
int numberOfObjectives = 0;
for(RuleSet rs : subsets) {
List<IExplorationTarget<?>> collect = rs.getExplorationTargets().stream()
.filter(e -> e instanceof IExplorationObjective<?>).collect(Collectors.toList());
numberOfObjectives += collect.size();
@SuppressWarnings("unchecked") Collection<IExplorationObjective<?>> objectives =
pickInstanceOf(
(Class<IExplorationObjective<?>>)(Class<?>)IExplorationObjective.class,
rs.getExplorationTargets());
numberOfObjectives += objectives.size();
}
int userTimeout = 0;
try {
......
DSEProcessNavigator.java a45e03d6080c637edb8b44070816a828838e47e9 GREEN
ExplorationNavigatorElementContentProvider.java a1e72619f39c8fe51432bd254d820cc39b7e4e85 YELLOW
ExplorationNavigatorElementContentProvider.java 36626523f1e3eb45fc75c2104cac59505ad9daf0 YELLOW
ExplorationNavigatorFXController.java 7f7c5fee19f5fe14c925dcfd97ef541a1ef354d1 YELLOW
ExplorationNavigatorFXViewPart.java 8604b65d141c21690f90bc942a6bb29e35911295 GREEN
ReferencedExplorationConstraint.java 0d65560502283b37f96712bd13c9719daa99788b YELLOW
......
......@@ -62,9 +62,10 @@ public class ExplorationNavigatorElementContentProvider
children.addAll(((ProcessStep)current).getSuccessors());
} else if(current instanceof RuleSet) {
for(IExplorationTarget<?> t : ((RuleSet)current).getExplorationTargets()) {
if(t instanceof IExplorationConstraint<?>) {
if(t instanceof IExplorationConstraint &&
!((IExplorationConstraint<?>)t).isImplicit()) {
children.add(new ReferencedExplorationConstraint((IExplorationConstraint<?>)t));
} else if(t instanceof IExplorationObjective<?>) {
} else if(t instanceof IExplorationObjective) {
children.add(new ReferencedExplorationObjective((IExplorationObjective<?>)t));
}
}
......
ConstraintSetWizard.java 100191da87caeca434e7c14153dac55e3eed0d64 GREEN
ConstraintSetWizardContentProvider.java 28a82adfa4ef19526a40472bb738b0460ee8403f YELLOW
ConstraintSetWizardContentProvider.java 45403bfa47e50e3e66be44b07f7e5c7609f3b7f2 YELLOW
ConstraintSetWizardPageBackend.java cc1441638a908230669a20fdae9dfca43d5a77e3 YELLOW
ConstraintWizardLabelProvider.java 6d7be0290755e4bd8b8f166b152173b3f083d122 YELLOW
ConstraintWizardLabelProvider.java 5b074c6bdbb65ade589bab3893ba62245f4c3247 YELLOW
ModifySubSetWizard.java 907c68a61764091d245fe9585f4c73c7a3dc199b YELLOW
ModifyWizardPage.java 20e88f93d330bde33313c14fd7889a5c0cabde6c YELLOW
ObjectiveSetWizardContentProvider.java f1afd7059a2abaea8d66edcd44881c37159b652b YELLOW
ObjectiveSetWizardContentProvider.java 9d4abd497505b0e55b33cf18b01a13810dcf8e13 YELLOW
ObjectivesSetWizardPageBackend.java d92ba18ad957df22a08e42bb5844f80f95a47801 GREEN
......@@ -19,7 +19,6 @@ import static org.fortiss.tooling.common.util.LambdaUtils.filterType;
import org.conqat.ide.commons.ui.jface.TreeContentProviderBase;
import org.fortiss.af3.exploration.model.IExplorationConstraint;
import org.fortiss.af3.exploration.model.IExplorationTarget;
import org.fortiss.af3.exploration.model.project.ProcessStep;
/**
......@@ -33,8 +32,8 @@ public class ConstraintSetWizardContentProvider extends TreeContentProviderBase
@Override
public Object[] getElements(Object inputElement) {
if(inputElement instanceof ProcessStep) {
return filterType(((ProcessStep)inputElement).getTargets(), IExplorationConstraint.class)
.toArray();
return filterType(((ProcessStep)inputElement).getTargets(),
IExplorationConstraint.class).toArray();
}
return null;
}
......@@ -42,9 +41,6 @@ public class ConstraintSetWizardContentProvider extends TreeContentProviderBase
/** {@inheritDoc} */
@Override
public Object[] getChildren(Object parentElement) {
if(parentElement instanceof IExplorationTarget) {
return ((IExplorationTarget<?>)parentElement).getContainedTargets().toArray();
}
return null;
}
}
......@@ -19,7 +19,6 @@ import static org.eclipse.wb.swt.SWTResourceManager.getColor;
import java.util.List;
import org.eclipse.emf.common.util.EList;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Image;
......@@ -88,14 +87,6 @@ public class ConstraintWizardLabelProvider extends ModelElementLabelProvider {
} else if(element instanceof IExplorationConstraint<?>) {
if(latestFailedConstraints.contains(element)) {
return RED;
} else if(!((IExplorationTarget<?>)element).getContainedTargets().isEmpty()) {
// search in composite constraints for failed constraints and mark parent red if
// some child failed
EList<?> containedTargets = ((IExplorationTarget<?>)element).getContainedTargets();
for(Object ct : containedTargets) {
if(latestFailedConstraints.contains(ct))
return RED;
}
}
}
......
......@@ -19,7 +19,6 @@ import static org.fortiss.tooling.common.util.LambdaUtils.filterType;
import org.conqat.ide.commons.ui.jface.TreeContentProviderBase;
import org.fortiss.af3.exploration.model.IExplorationObjective;
import org.fortiss.af3.exploration.model.IExplorationTarget;
import org.fortiss.af3.exploration.model.project.ProcessStep;
/**
......@@ -42,9 +41,6 @@ public class ObjectiveSetWizardContentProvider extends TreeContentProviderBase {
/** {@inheritDoc} */
@Override
public Object[] getChildren(Object parentElement) {
if(parentElement instanceof IExplorationTarget) {
return ((IExplorationTarget<?>)parentElement).getContainedTargets().toArray();
}
return null;
}
}
ConstraintsFXViewPart.java 89893c80b8af0582ce1f2a786a9dce180a7bd099 GREEN
ConstraintsFXViewPart.java 89893c80b8af0582ce1f2a786a9dce180a7bd099 RED
AllocationPatternFXController.java 7c3ba677a9b14857d20140d48d321cd4b41d0fda YELLOW
CouplingPatternFXController.java b8270aaddefdde9d845bb2c6624bb850384b4aad YELLOW
MemoryPatternFXController.java a15b2a0bb69681e4ae675dcc23fc9aaf44558728 YELLOW
SafetyPatternFXController.java 440af5d6bdd5ce26b4d77461f8b34271fadfc637 YELLOW
AllocationPatternFXController.java 7c3ba677a9b14857d20140d48d321cd4b41d0fda RED
CouplingPatternFXController.java b8270aaddefdde9d845bb2c6624bb850384b4aad RED
MemoryPatternFXController.java a15b2a0bb69681e4ae675dcc23fc9aaf44558728 RED
SafetyPatternFXController.java 440af5d6bdd5ce26b4d77461f8b34271fadfc637 RED
ObjectivesFXViewPart.java 9f7957b5e627efcebdffecc4fd75eab9e438e482 GREEN
ObjectivesFXViewPart.java 9f7957b5e627efcebdffecc4fd75eab9e438e482 RED
BusBandwidthOptimizationPatternFXController.java dc024a9c06cd730f839f06cfcbb72def27d0b99c RED
HardwareOptimizationPatternFXController.java f2893d1a205d8126af11ff98e055e32223e50aa6 YELLOW
BusBandwidthOptimizationPatternFXController.java 7710397aff99c4d495341f951d7475bdcdf7b925 RED
HardwareOptimizationPatternFXController.java 0ffe02e30b1892e2da7072db051bbaa8db1add69 RED
......@@ -33,7 +33,8 @@ import java.util.List;
import org.eclipse.emf.ecore.EObject;
import org.fortiss.af3.exploration.dseml.model.expression.IExpression;
import org.fortiss.af3.exploration.dseml.model.expression.SuperSet;
import org.fortiss.af3.exploration.model.ExplorationObjective;
import org.fortiss.af3.exploration.model.IExplorationConstraint;
import org.fortiss.af3.exploration.model.IExplorationObjective;
import org.fortiss.af3.exploration.model.IExplorationTarget;
import org.fortiss.af3.exploration.model.project.DSE;
import org.fortiss.af3.exploration.ui.perspective.generic.PatternFXControllerBase;
......@@ -92,29 +93,26 @@ public class BusBandwidthOptimizationPatternFXController extends PatternFXContro
if(selectedBus == null) {
return null;
}
List<IExplorationTarget<Boolean>> constraints = new ArrayList<>();
Collection<IExplorationConstraint<?>> constraints = new ArrayList<>();
IExpression routeWeightExpression = createRouteWeightConstraintPatternExpression(dse);
constraints.add(createExplorationConstraint(Boolean.class, createResourceDimension(),
routeWeightExpression, "BandwidthWeight", false));
routeWeightExpression, "BandwidthWeight", true));
for(TransmissionUnit bus : dse.getCurrentStep().getSuperSetMap().get(TransmissionUnit.class)
.getEntries()) {
for(Route route : dse.getCurrentStep().getSuperSetMap().get(Route.class).getEntries()) {
IExpression routeUsesBusExpression =
createRouteUsesBusConstraintPatternExpression(dse, bus, route);
constraints.add(createExplorationConstraint(Boolean.class,
createResourceDimension(), routeUsesBusExpression, "RouteUsesBus", false));
createResourceDimension(), routeUsesBusExpression, "RouteUsesBus", true));
}
}
IExpression expr = createBusWeightOptimizationPatternExpression(dse, selectedBus,
minButton.isSelected());
ExplorationObjective<?> objective = createExplorationObjective(Double.class,
IExplorationObjective<Double> objective = createExplorationObjective(Double.class,
createUserDefinedDimension(getCategory()), expr, getExplorationTargetName());
constraints
.forEach(c -> ((List<IExplorationTarget>)(List<?>)objective.getContainedTargets())
.add((IExplorationTarget<?>)c));
// objective.getContainedTargets().addAll(constraints);
// TODO(AD): How to return constraints?
objective.getImplicitConstraints().addAll(constraints);
return objective;
}
......@@ -125,9 +123,10 @@ public class BusBandwidthOptimizationPatternFXController extends PatternFXContro
private TransmissionUnit getSelectedTransmissionUnit() {
List<TransmissionUnit> list = view.getSelectionModel().getSelectedItems().stream()
.map(item -> (TransmissionUnit)item.getValue()).collect(toList());
if(!list.isEmpty())
if(!list.isEmpty()) {
// the selection mode is such that at most one element is selected
return list.get(0);
}
return null;
}
......
......@@ -41,8 +41,8 @@ import org.fortiss.af3.task.model.Task;
import org.fortiss.tooling.base.annotation.AnnotationEntry;
import org.fortiss.tooling.base.annotation.IAnnotationValueService;
import org.fortiss.tooling.base.model.element.IAnnotatedSpecification;
import org.fortiss.tooling.common.ui.javafx.control.treetableview.DynamicTreeTableUIProviderBase;
import org.fortiss.tooling.common.ui.javafx.control.treetableview.DynamicTreeTableViewer;
import org.fortiss.tooling.common.ui.javafx.control.treetableview.DynamicTreeUIProviderBase;
import org.fortiss.tooling.common.ui.javafx.control.treetableview.DynamicTreeViewer;
import org.fortiss.tooling.kernel.model.INamedElement;
import javafx.fxml.FXML;
......@@ -51,6 +51,7 @@ import javafx.scene.control.RadioButton;
import javafx.scene.control.SelectionMode;
import javafx.scene.control.ToggleGroup;
import javafx.scene.control.TreeTableView;
import javafx.scene.control.TreeView;
/**
* {@link PatternFXControllerBase} that allows the user to define objectives for optimization of the
......@@ -64,19 +65,19 @@ public class HardwareOptimizationPatternFXController extends PatternFXController
* {@link TreeTableView} displaying the list of execution units.
*/
@FXML
private TreeTableView<EObject> ecuView;
private TreeView<EObject> ecuView;
/**
* {@link TreeTableView} displaying the list of properties.
*/
@FXML
private TreeTableView<EObject> propertyView;
private TreeView<EObject> propertyView;
/**
* {@link TreeTableView} displaying the list of tasks.
*/
@FXML
private TreeTableView<EObject> taskView;
private TreeView<EObject> taskView;
/**
* {@link RadioButton} to select the minimize option.
......@@ -211,36 +212,29 @@ public class HardwareOptimizationPatternFXController extends PatternFXController
/** Constructor. */
public HardwareOptimizationViewer() {
SuperSet<ExecutionUnit> ecus = IDSEPerspectiveManager.INSTANCE.getCurrentlySelectedDSE()
.getCurrentStep().getSuperSetMap().get(ExecutionUnit.class);
DynamicTreeTableUIProviderBase uiProvider = new DynamicTreeTableUIProviderBase() {
/** {@inheritDoc} */
@Override
public String getLabel(Object element, int column) {
String string;
if(element instanceof IAnnotatedSpecification) {
string = getPropertyName((IAnnotatedSpecification)element);
} else {
string = ((INamedElement)element).getName();
}
return string;
}
};
DSE dse = IDSEPerspectiveManager.INSTANCE.getCurrentlySelectedDSE();
SuperSet<ExecutionUnit> ecus =
dse.getCurrentStep().getSuperSetMap().get(ExecutionUnit.class);
SuperSet<Task> tasks = dse.getCurrentStep().getSuperSetMap().get(Task.class);
@SuppressWarnings("unchecked") DynamicTreeUIProviderBase<EObject> uiProvider =
(DynamicTreeUIProviderBase<EObject>)(DynamicTreeUIProviderBase<?>)new DynamicTreeUIProviderBase<INamedElement>() {
/** {@inheritDoc} */
@Override
public String getLabel(INamedElement element) {
return (element instanceof IAnnotatedSpecification)
? getPropertyName((IAnnotatedSpecification)element)
: element.getName();
}
};
// add a viewer for {ExecutionUnit}s
DynamicTreeTableViewer<EObject> ecuViewer = new DynamicTreeTableViewer<EObject>(ecuView,
ecus, false, 0, new SuperSetContentProvider<ExecutionUnit>(), uiProvider);
ecuViewer.addColumn("Execution Unit", 250, true);
new DynamicTreeViewer<EObject>(ecuView, ecus, false, 0,
new SuperSetContentProvider<ExecutionUnit>(), uiProvider);
// add a viewer for properties
DynamicTreeTableViewer<EObject> propertyViewer =
new DynamicTreeTableViewer<EObject>(propertyView, ecus.getEntries().get(0),
false, 0, new AnnotationContentProvider(), uiProvider);
propertyViewer.addColumn("Property", 250, true);
new DynamicTreeViewer<>(propertyView, ecus.getEntries().get(0), false, 0,
new AnnotationContentProvider(), uiProvider);
// add a viewer for {Task}s
SuperSet<Task> tasks = IDSEPerspectiveManager.INSTANCE.getCurrentlySelectedDSE()
.getCurrentStep().getSuperSetMap().get(Task.class);
DynamicTreeTableViewer<EObject> taskViewer = new DynamicTreeTableViewer<EObject>(
taskView, tasks, false, 0, new SuperSetContentProvider<Task>(), uiProvider);
taskViewer.addColumn("Task", 250, true);
new DynamicTreeViewer<>(taskView, tasks, false, 0, new SuperSetContentProvider<Task>(),
uiProvider);
// add the radio buttons for switching from minimize to maximize
final ToggleGroup minmaxGroup = new ToggleGroup();
......
dseml.ecore 9a07a7ea81eff402eeb35bde7b2cebe2482792bb GREEN
exploration.ecore 184cf1544f9ec544b8446f367530cf319d8d1f10 YELLOW
exploration.ecore 15c0d5921146a84fe8b1381d3463d44d7df560e4 YELLOW
......@@ -55,12 +55,6 @@
<details key="documentation" value="Contains the {@link IExpression} that defines an {@link ExplorationTarget}."/>
</eAnnotations>
</eStructuralFeatures>
<eStructuralFeatures xsi:type="ecore:EReference" name="containedTargets" upperBound="-1"
containment="true">
<eGenericType eClassifier="#//IExplorationTarget">
<eTypeArguments eTypeParameter="#//IExplorationTarget/T"/>
</eGenericType>
</eStructuralFeatures>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="resultTypeInternal">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="suppressedGetVisibility" value="true"/>
......@@ -80,6 +74,12 @@
<details key="documentation" value="{@link ExplorationTarget} that defines objectives of a DSE."/>
</eAnnotations>
<eTypeParameters name="T"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="implicitConstraints" upperBound="-1"
containment="true">
<eGenericType eClassifier="#//IExplorationConstraint">
<eTypeArguments/>
</eGenericType>
</eStructuralFeatures>
<eGenericSuperTypes eClassifier="#//IExplorationTarget">
<eTypeArguments eTypeParameter="#//IExplorationObjective/T"/>
</eGenericSuperTypes>
......
......@@ -17,7 +17,6 @@
<genClasses image="false" ecoreClass="exploration.ecore#//IExplorationTarget">
<genTypeParameters ecoreTypeParameter="exploration.ecore#//IExplorationTarget/T"/>
<genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference exploration.ecore#//IExplorationTarget/expression"/>
<genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference exploration.ecore#//IExplorationTarget/containedTargets"/>
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute exploration.ecore#//IExplorationTarget/resultTypeInternal"/>
<genFeatures createChild="false" ecoreFeature="ecore:EReference exploration.ecore#//IExplorationTarget/problemDimension"/>
<genOperations ecoreOperation="exploration.ecore#//IExplorationTarget/getResultType"
......@@ -29,6 +28,7 @@
</genClasses>
<genClasses image="false" ecoreClass="exploration.ecore#//IExplorationObjective">
<genTypeParameters ecoreTypeParameter="exploration.ecore#//IExplorationObjective/T"/>
<genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference exploration.ecore#//IExplorationObjective/implicitConstraints"/>
</genClasses>
<genClasses image="false" ecoreClass="exploration.ecore#//IExplorationConstraint">
<genTypeParameters ecoreTypeParameter="exploration.ecore#//IExplorationConstraint/T"/>
......
ExplorationExpressionDeploymentValidator.java c0db6164e1623fee1d41ff3b38dfa8ac87e739f9 GREEN
ExplorationExpressionDeploymentValidator.java 1a76ba7bb01d9c9f53be9f9ad01381cd9f88ffe9 YELLOW
ExplorationExpressionEvaluator.java 4f0cd81aae80b59dcf62c41ef0248b85e2374fb2 GREEN
ExpressionVisitorBase.java d3b60238c6685e05f9c75980d1869bd1f0af4132 GREEN
Function.java 9f4dc40006029d2ae58b62936893c2cd0de7e172 GREEN
......
......@@ -15,6 +15,8 @@
+--------------------------------------------------------------------------*/
package org.fortiss.af3.exploration.lang;
import static org.fortiss.tooling.common.util.LambdaUtils.filterByType;
import java.util.LinkedList;
import java.util.Queue;
......@@ -29,8 +31,8 @@ import org.fortiss.af3.exploration.dseml.model.function.IsTask;
import org.fortiss.af3.exploration.dseml.model.function.Maximize;
import org.fortiss.af3.exploration.dseml.model.function.Minimize;
import org.fortiss.af3.exploration.dseml.model.function.StronglyCausal;
import org.fortiss.af3.exploration.model.IExplorationConstraint;
import org.fortiss.af3.exploration.model.ExplorationSpecification;
import org.fortiss.af3.exploration.model.IExplorationConstraint;
import org.fortiss.af3.exploration.model.IExplorationTarget;
import org.fortiss.af3.exploration.model.project.RuleSet;
import org.fortiss.af3.platform.model.ExecutionUnit;
......@@ -78,30 +80,21 @@ public class ExplorationExpressionDeploymentValidator extends ExplorationExpress
public Boolean validate() throws Exception {
boolean validationResult = true;
Queue<IExplorationTarget<?>> constraintSet =
new LinkedList<>(ruleSet.getExplorationTargets());
Queue<IExplorationConstraint<?>> constraintSet = new LinkedList<>(
filterByType(ruleSet.getExplorationTargets(), IExplorationConstraint.class));
while(!constraintSet.isEmpty()) {
IExplorationTarget<?> constraint = constraintSet.poll();
if(!constraint.getContainedTargets().isEmpty()) {
constraintSet.addAll(constraint.getContainedTargets());
} else if(constraint instanceof IExplorationConstraint) {
if(((IExplorationConstraint<?>)constraint).getExpression() == null) {
throw new Exception("The constraint " + constraint.getName() + " neither" +
" contains an expression nor does it contain other constraints." +
"Please validate the given ExplorationSpecification.");
}
// Exit early behavior: Return whenever the first invalid constraint was found.
validationResult = ((IExplorationConstraint<?>)constraint).getExpression()
.accept(this, Boolean.class);
if(!validationResult) {
return false;
}
} else {
throw new Exception(
"At least one Constraint is not a ConstraintExpression in terms" +
" of the Exploration DSL v2. Cannot perfom the Validation" +
" for other ExplorationConstraint types. Sorry, aborting.");
if(((IExplorationConstraint<?>)constraint).getExpression() == null) {
throw new Exception("The constraint " + constraint.getName() + " neither" +
" contains an expression nor does it contain other constraints." +
"Please validate the given ExplorationSpecification.");
}
// Exit early behavior: Return whenever the first invalid constraint was found.
validationResult = ((IExplorationConstraint<?>)constraint).getExpression().accept(this,
Boolean.class);
if(!validationResult) {
return false;
}
}
......
......@@ -4,6 +4,6 @@ DSMLModelElementFactory.java 8081a2d7e2a1ee311b830305854bb60bb7572d91 GREEN
DSMLUtils.java c07eeef09787cea9db98533d346e3e384a232593 GREEN
ExplorationModelElementFactory.java 2c1c16a25b94002738be9a0576879b360e75a8db YELLOW
ExplorationReflectionUtils.java 62731e1cef32fe93f2c2017f93f5ba1f054d5197 GREEN
ExplorationUtils.java c25fb91b735472c9bb1149571aa28926e2f71906 YELLOW
ExplorationUtils.java a953fe66dc4bda61f854b4fe4836fd3e8d0049ee YELLOW
ModelSnapshotExtractUtils.java 4f023e1247701c0e8f329575caddbbcac0066200 GREEN
PatternFactoryUtils.java f260307c09e9d26303a46ca2a69ce6c76eae926f GREEN
......@@ -261,7 +261,8 @@ public class ExplorationUtils {
}
/**
* Extracts the {@link IExplorationTarget} references from the given {@link RuleSet}s and returns
* Extracts the {@link IExplorationTarget} references from the given {@link RuleSet}s and
* returns
* them as a list.
*
* @param ruleSets
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment