Skip to content
Snippets Groups Projects
Commit df2abbab authored by Alexander Diewald's avatar Alexander Diewald
Browse files

Basic support for coupling constraints


* Add a CouplingConstraint InternalConstraint.
* Add a converter to translate DseML coupling expressions into
  InternalConstraints.

Signed-off-by: default avatarAlexander Diewald <diewald@fortiss.org>
parent d5a6bdb2
No related branches found
No related tags found
No related merge requests found
Showing
with 128 additions and 7 deletions
moea.ecore 27c5fdf7b7a6cd596eae1520fbca5fd87ebdde9b YELLOW
moea.ecore d69c84db80898110003a0ad663d1a1802bed3238 YELLOW
......@@ -370,6 +370,16 @@
<eTypeArguments eClassifier="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EBooleanObject"/>
</eGenericSuperTypes>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="CouplingConstraint">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="documentation" value="{@link InternalConstraint} that defines which sets of {@link IRequestAdapter} may not be deployed together in a single Fault Containment Region."/>
</eAnnotations>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="coupledSet" lowerBound="1"
upperBound="-1" eType="#//adapter/IRequestAdapter"/>
<eGenericSuperTypes eClassifier="#//constraints/InternalConstraint">
<eTypeArguments eClassifier="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EBooleanObject"/>
</eGenericSuperTypes>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="SeparationConstraint">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="documentation" value="{@link InternalConstraint} that defines which sets of {@link IRequestAdapter} may not be deployed together in a single Fault Containment Region."/>
......
......@@ -131,6 +131,10 @@
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute moea.ecore#//constraints/ReplicationConstraint/max"/>
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute moea.ecore#//constraints/ReplicationConstraint/requester"/>
</genClasses>
<genClasses ecoreClass="moea.ecore#//constraints/CouplingConstraint">
<genFeatures notify="false" createChild="false" propertySortChoices="true"
ecoreFeature="ecore:EAttribute moea.ecore#//constraints/CouplingConstraint/coupledSet"/>
</genClasses>
<genClasses ecoreClass="moea.ecore#//constraints/SeparationConstraint">
<genFeatures createChild="false" ecoreFeature="ecore:EReference moea.ecore#//constraints/SeparationConstraint/separatedSets"/>
</genClasses>
......
ExplorationAlg.java eaa245e293ea38ff1e2f4a21d43a3623d68d5a52 RED
ExplorationAlg.java f667fdd3664c65d230a2cbba1b9e260486e60c5b YELLOW
ExplorationAlgActivator.java 7ccd8c61f3cd761be44cd5b23dc925a1f5da8fbe YELLOW
......@@ -42,6 +42,7 @@ import org.fortiss.af3.exploration.alg.module.common.input.TaskGraphInputModule;
import org.fortiss.af3.exploration.alg.module.common.input.TaskSignalInputModule;
import org.fortiss.af3.exploration.alg.module.common.input.TransmissionUnitInputModule;
import org.fortiss.af3.exploration.alg.module.expspectransf.constraint.AllocationPatternConverter;
import org.fortiss.af3.exploration.alg.module.expspectransf.constraint.CouplingPatternConverter;
import org.fortiss.af3.exploration.alg.module.expspectransf.dsmlext.PropertyToFixedValueLiteralConverter;
import org.fortiss.af3.exploration.alg.service.IExpSpecTransformationService;
import org.fortiss.af3.exploration.alg.service.IExplorationEvaluatationService;
......@@ -166,6 +167,7 @@ public final class ExplorationAlg implements IStartup {
tService.registerModule(new PropertyToFixedValueLiteralConverter());
// Transform DSML constraints to a more efficient internal representation.
tService.registerModule(new AllocationPatternConverter());
tService.registerModule(new CouplingPatternConverter());
}
/**
......
AllocationPatternConverter.java 17d237b391ecf61e7990c7f8a5439980c30ce194 RED
CouplingPatternConverter.java 7eb9a8273971b538b8df2276607531e7bb662931 YELLOW
/*-------------------------------------------------------------------------+
| Copyright 2018 fortiss GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.af3.exploration.alg.module.expspectransf.constraint;
import static org.fortiss.af3.exploration.alg.util.DesignSpaceExplorationModelElementFactory.createCouplingConstraint;
import static org.fortiss.af3.exploration.alg.util.DseMLUtils.getCouplingRequesterSet;
import java.util.ArrayList;
import java.util.Collection;
import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IRequestAdapter;
import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.mappers.TaskMapper;
import org.fortiss.af3.exploration.alg.service.module.base.ExpSpecTransformatorBase;
import org.fortiss.af3.exploration.dseml.model.expression.Set;
import org.fortiss.af3.exploration.model.ExplorationConstraint;
import org.fortiss.af3.exploration.moea.model.constraints.CouplingConstraint;
import org.fortiss.af3.exploration.moea.model.constraints.InternalConstraint;
import org.fortiss.af3.task.model.Task;
import org.fortiss.tooling.base.model.element.IModelElement;
import com.google.inject.Injector;
import com.google.inject.Key;
import com.google.inject.TypeLiteral;
/**
* Converts an allocation pattern {@link ExplorationConstraint} to an {@link InternalConstraint}.
*
* @author diewald
*/
public final class CouplingPatternConverter
extends ExpSpecTransformatorBase<ExplorationConstraint<?>, InternalConstraint<?>> {
/** {@inheritDoc} */
@Override
public boolean outputIsReplacement() {
return false;
}
/** {@inheritDoc} */
@Override
public InternalConstraint<?> transform(Injector mainInjector,
ExplorationConstraint<?> constraint) {
TaskMapper taskMapper = mainInjector.getInstance(Key.get(new TypeLiteral<TaskMapper>() { // ...
}));
Set<IModelElement> requesterSet = getCouplingRequesterSet(constraint);
if(requesterSet == null) {
return null;
}
Collection<IRequestAdapter> reqSet = new ArrayList<>();
requesterSet.getEntries().forEach(me -> reqSet.add(taskMapper.getAdapter((Task)me)));
CouplingConstraint couplingConstr = createCouplingConstraint(reqSet);
return couplingConstr;
}
}
ExpSpecTransformationService.java ab77f0a5b2e599f6fe506801088ee19f9a2b2d12 YELLOW
ExpSpecTransformationService.java 16456d0731ff459db3a61986c03880183e780a69 YELLOW
ExplorationEvaluationService.java c24b3221c953b67f950ffc33c155abf78d78b8d7 RED
ExplorationFeatureService.java 2e7a1d99877341fc20e67fe42ac3ba960baeaf8b YELLOW
ExplorationInputService.java a6bbcb5fae180b3f002ea34a433792f7cffd3f43 YELLOW
......
......@@ -112,9 +112,10 @@ public class ExpSpecTransformationService implements IExpSpecTransformationServi
}
} else {
for(Entry<EObject, EObject> tEntry : transformedMap.entrySet()) {
if(tEntry.getValue() instanceof ExplorationTarget) {
EObject value = tEntry.getValue();
if(value instanceof ExplorationTarget) {
expTargets.add((ExplorationTarget<?>)tEntry.getValue());
} else {
} else if(value != null) {
throw new ExplorationException("The module " +
module.getClass().getSimpleName() + " is incorrectly specified. " +
"If the output elements are additional, they must be " +
......
AF3Utils.java 015cd73497d0fe695ba46b1b4fea55bd51ccb9e2 RED
DesignSpaceExplorationModelElementFactory.java e7106372c4a7927954ae38feaa98f6b4c94bacad YELLOW
DseMLUtils.java 2bcea9a81f3db8dd939bd73e9f980e90f330c0b0 YELLOW
DesignSpaceExplorationModelElementFactory.java ef6464be8e68e4ecc2c0f15296b73b2d71b13e24 YELLOW
DseMLUtils.java a8a0a71857fda498e2bce2e538b8cbf3d0d87a4b RED
ExplorationAlgUtils.java b7f3ce93cdaeb1a7d9939172dd1e2ffc21d9d5c5 RED
ExplorationFeatureUtils.java 7a92ff889e45f3b89655fbd9e265343b19b49d25 YELLOW
GraphUtils.java 550784a7fa53eaf370f9cca248cc776843cf1134 RED
......
......@@ -36,6 +36,7 @@ import org.fortiss.af3.exploration.moea.model.allocation.AllocationFactory;
import org.fortiss.af3.exploration.moea.model.allocation.InterferenceLatencyTable;
import org.fortiss.af3.exploration.moea.model.constraints.AssignmentConstraint;
import org.fortiss.af3.exploration.moea.model.constraints.ConstraintsFactory;
import org.fortiss.af3.exploration.moea.model.constraints.CouplingConstraint;
import org.fortiss.af3.exploration.moea.model.constraints.InternalConstraint;
import org.fortiss.af3.exploration.moea.model.constraints.IsolatedCommunicationSet;
import org.fortiss.af3.exploration.moea.model.constraints.PeriodConstraint;
......@@ -152,6 +153,18 @@ public class DesignSpaceExplorationModelElementFactory {
return replConstr;
}
/**
* Creates a {@link CouplingConstraint} {@link InternalConstraint} of the given set of
* {@link IRequestAdapter}s.
*/
public static CouplingConstraint
createCouplingConstraint(Collection<IRequestAdapter> coupledRequesters) {
CouplingConstraint couplingConstr = ConstraintsFactory.eINSTANCE.createCouplingConstraint();
couplingConstr.setName("CouplingConstraint");
couplingConstr.getCoupledSet().addAll(coupledRequesters);
return couplingConstr;
}
/**
* Creates a {@link SeparationConstraint} {@link InternalConstraint} of the given set of
* isolated sets of {@link IRequestAdapter}s.
......
......@@ -19,8 +19,10 @@ import org.fortiss.af3.exploration.dseml.model.booleanp.Exists;
import org.fortiss.af3.exploration.dseml.model.booleanp.ForAll;
import org.fortiss.af3.exploration.dseml.model.booleanp.allocation.ILocationExpression;
import org.fortiss.af3.exploration.dseml.model.expression.IExpression;
import org.fortiss.af3.exploration.dseml.model.expression.Set;
import org.fortiss.af3.exploration.model.ExplorationConstraint;
import org.fortiss.af3.exploration.model.ExplorationTarget;
import org.fortiss.tooling.base.model.element.IModelElement;
/**
* Utility methods for handling DSML {@link IExpression}s of {@link ExplorationTarget}s
......@@ -29,6 +31,23 @@ import org.fortiss.af3.exploration.model.ExplorationTarget;
*/
public class DseMLUtils {
/**
* Extracts the {@link ILocationExpression} of an allocation pattern
* {@link ExplorationConstraint} or {@code null} if the {@link ExplorationConstraint} is not
* such a pattern.
*/
public static Set<IModelElement> getCouplingRequesterSet(ExplorationConstraint<?> constraint) {
IExpression expr = constraint.getExpression();
if(!(expr instanceof Exists)) {
return null;
}
IExpression existsExpr = ((Exists)expr).getExpression();
if(!(existsExpr instanceof ForAll)) {
return null;
}
return ((ForAll)existsExpr).getSet();
}
/**
* Extracts the {@link ILocationExpression} of an allocation pattern
* {@link ExplorationConstraint} or {@code null} if the {@link ExplorationConstraint} is not
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment