Permalink
Browse files

[#130]: Mapping restrictions should allow task references

  • Loading branch information...
RobertHilbrich committed Jul 17, 2018
1 parent c6f8e58 commit a74edde8f919567acbb798f3b2a361be62e5e69a
Showing with 935 additions and 280 deletions.
  1. +1 −1 ch.hilbri.assist.dse.dsl.tests/META-INF/MANIFEST.MF
  2. +1 −1 ch.hilbri.assist.dse.dsl.ui/META-INF/MANIFEST.MF
  3. +3 −12 ch.hilbri.assist.dse.dsl.ui/src/ch/hilbri/assist/dse/dsl/ui/labeling/DSEDslLabelProvider.xtend
  4. +2 −2 ch.hilbri.assist.dse.dsl/META-INF/MANIFEST.MF
  5. +10 −8 ch.hilbri.assist.dse.dsl/src/ch/hilbri/assist/dse/dsl/DSEDsl.xtext
  6. +3 −3 ...ng.benchmarking/src/ch/hilbri/assist/mapping/benchmarking/generator/MappingExampleGenerator.xtend
  7. +1 −1 ch.hilbri.assist.mapping.dsl.tests/META-INF/MANIFEST.MF
  8. +1 −1 ch.hilbri.assist.mapping.dsl.ui/META-INF/MANIFEST.MF
  9. +3 −12 ....assist.mapping.dsl.ui/src/ch/hilbri/assist/mapping/dsl/ui/labeling/MappingDSLLabelProvider.xtend
  10. +2 −2 ch.hilbri.assist.mapping.dsl/META-INF/MANIFEST.MF
  11. +8 −4 ch.hilbri.assist.mapping.dsl/src/ch/hilbri/assist/mapping/dsl/MappingDSL.xtext
  12. +1 −1 ch.hilbri.assist.mapping/plugin.xml
  13. +1 −3 ch.hilbri.assist.mapping/src/ch/hilbri/assist/mapping/solver/constraints/ColocalityConstraint.xtend
  14. +3 −3 ch.hilbri.assist.mapping/src/ch/hilbri/assist/mapping/solver/constraints/DislocalityConstraint.xtend
  15. +11 −14 ...lbri.assist.mapping/src/ch/hilbri/assist/mapping/solver/constraints/DissimilarityConstraint.xtend
  16. BIN ch.hilbri.assist.model.edit/icons/full/obj16/AbstractSoftwareElement.gif
  17. +7 −0 ch.hilbri.assist.model.edit/plugin.properties
  18. +120 −0 ...ri.assist.model.edit/src/ch/hilbri/assist/model/provider/AbstractSoftwareElementItemProvider.java
  19. +1 −27 ch.hilbri.assist.model.edit/src/ch/hilbri/assist/model/provider/ApplicationItemProvider.java
  20. +1 −3 ch.hilbri.assist.model.edit/src/ch/hilbri/assist/model/provider/ColocalityRelationItemProvider.java
  21. +1 −3 ch.hilbri.assist.model.edit/src/ch/hilbri/assist/model/provider/DislocalityRelationItemProvider.java
  22. +1 −3 ...lbri.assist.model.edit/src/ch/hilbri/assist/model/provider/DissimilarityRelationItemProvider.java
  23. +60 −14 ch.hilbri.assist.model.edit/src/ch/hilbri/assist/model/provider/MappingRelationItemProvider.java
  24. +24 −0 ch.hilbri.assist.model.edit/src/ch/hilbri/assist/model/provider/ModelItemProviderAdapterFactory.java
  25. +1 −27 ch.hilbri.assist.model.edit/src/ch/hilbri/assist/model/provider/TaskItemProvider.java
  26. +33 −3 ch.hilbri.assist.model/model/ASSIST-Model.xcore
  27. +18 −0 ch.hilbri.assist.model/src-gen/ch/hilbri/assist/model/AbstractSoftwareElement.java
  28. +1 −3 ch.hilbri.assist.model/src-gen/ch/hilbri/assist/model/Application.java
  29. +41 −11 ch.hilbri.assist.model/src-gen/ch/hilbri/assist/model/MappingRelation.java
  30. +9 −0 ch.hilbri.assist.model/src-gen/ch/hilbri/assist/model/ModelFactory.java
  31. +283 −91 ch.hilbri.assist.model/src-gen/ch/hilbri/assist/model/ModelPackage.java
  32. +1 −3 ch.hilbri.assist.model/src-gen/ch/hilbri/assist/model/Task.java
  33. +39 −0 ch.hilbri.assist.model/src-gen/ch/hilbri/assist/model/impl/AbstractSoftwareElementImpl.java
  34. +1 −2 ch.hilbri.assist.model/src-gen/ch/hilbri/assist/model/impl/ApplicationImpl.java
  35. +93 −17 ch.hilbri.assist.model/src-gen/ch/hilbri/assist/model/impl/MappingRelationImpl.java
  36. +37 −0 ch.hilbri.assist.model/src-gen/ch/hilbri/assist/model/impl/ModelFactoryImpl.java
  37. +68 −3 ch.hilbri.assist.model/src-gen/ch/hilbri/assist/model/impl/ModelPackageImpl.java
  38. +1 −2 ch.hilbri.assist.model/src-gen/ch/hilbri/assist/model/impl/TaskImpl.java
  39. +19 −0 ch.hilbri.assist.model/src-gen/ch/hilbri/assist/model/util/ModelAdapterFactory.java
  40. +24 −0 ch.hilbri.assist.model/src-gen/ch/hilbri/assist/model/util/ModelSwitch.java
@@ -9,7 +9,7 @@ Require-Bundle: ch.hilbri.assist.dse.dsl,
org.junit;bundle-version="4.12.0",
org.eclipse.xtext.testing,
org.eclipse.xtext.xbase.testing,
org.eclipse.xtext.xbase.lib
org.eclipse.xtext.xbase.lib;bundle-version="2.14.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Export-Package: ch.hilbri.assist.dse.dsl.tests;x-internal=true
Import-Package: org.hamcrest.core,
@@ -17,7 +17,7 @@ Require-Bundle: ch.hilbri.assist.model,
org.eclipse.compare,
org.eclipse.xtext.builder,
org.eclipse.xtend.lib;resolution:=optional,
org.eclipse.xtext.xbase.lib
org.eclipse.xtext.xbase.lib;bundle-version="2.14.0"
Import-Package: org.apache.log4j
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Export-Package: ch.hilbri.assist.dse.dsl.ui.quickfix,
@@ -102,10 +102,7 @@ class DSEDslLabelProvider extends DefaultEObjectLabelProvider {
val output = new StringBuilder()
output.append("[")
for (app : r.applications) {
output.append(app.name)
if(r.applications.last != app) output.append(", ")
}
output.append(r.softwareElementNames)
output.append("]")
output.append(" dislocal up to ")
output.append(r.hardwareLevel)
@@ -122,10 +119,7 @@ class DSEDslLabelProvider extends DefaultEObjectLabelProvider {
val output = new StringBuilder()
output.append("[")
for (app : r.applications) {
output.append(app.name)
if (r.applications.last != app) output.append(", ")
}
output.append(r.softwareElementNames)
output.append("]")
output.append(" dissimilar ")
@@ -139,10 +133,7 @@ class DSEDslLabelProvider extends DefaultEObjectLabelProvider {
val output = new StringBuilder()
output.append("[")
for (app : r.applications) {
output.append(app.name)
if(r.applications.last != app) output.append(", ")
}
output.append(r.softwareElementNames)
output.append("]")
output.append(" on same ")
output.append(r.hardwareLevel)
@@ -10,10 +10,10 @@ Require-Bundle: ch.hilbri.assist.model,
org.eclipse.xtext,
org.eclipse.xtext.xbase,
org.eclipse.equinox.common;bundle-version="3.5.0",
org.eclipse.xtext.xbase.lib,
org.eclipse.xtext.xbase.lib;bundle-version="2.14.0",
org.antlr.runtime,
org.eclipse.xtext.util,
org.eclipse.xtend.lib,
org.eclipse.xtend.lib;bundle-version="2.14.0",
ch.hilbri.assist.mapping.dsl
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Export-Package: ch.hilbri.assist.dse.dsl.parser.antlr.internal,
@@ -139,16 +139,18 @@ RestrictionAlternative:
'}'
;
DislocalityRelation returns DislocalityRelation:
applications+=[Application] (',' applications+=[Application])* 'dislocal' 'up' 'to' hardwareLevel=HardwareArchitectureLevelType ';';
ColocalityRelation returns ColocalityRelation:
applications+=[Application|QualifiedName] (',' (applications+=[Application]))* 'on' 'same' hardwareLevel=HardwareArchitectureLevelType ';';
DislocalityRelation:
abstractSoftwareElements+=[AbstractSoftwareElement] (',' abstractSoftwareElements+=[AbstractSoftwareElement])*
'dislocal' 'up' 'to' hardwareLevel=HardwareArchitectureLevelType ';';
ColocalityRelation:
abstractSoftwareElements+=[AbstractSoftwareElement] (',' abstractSoftwareElements+=[AbstractSoftwareElement])*
'on' 'same' hardwareLevel=HardwareArchitectureLevelType ';';
DissimilarityRelation:
applications+=[Application|QualifiedName] (',' (applications+=[Application]))*
'dissimilar' 'based' 'on'
dissimilarityClause=DissimilarityClause ';';
abstractSoftwareElements+=[AbstractSoftwareElement] (',' abstractSoftwareElements+=[AbstractSoftwareElement])*
'dissimilar' 'based' 'on'
dissimilarityClause=DissimilarityClause ';';
DissimilarityClause:
DissimilarityEntry |
@@ -166,16 +166,16 @@ class MappingExampleGenerator {
var boolean applicationAdded = false
while (!applicationAdded) {
val selectedApplication = assistModel.applications.get(rng.nextInt(0, assistModel.applications.size))
if (!dislocality.applications.contains(selectedApplication))
applicationAdded = dislocality.applications.add(selectedApplication)
if (!dislocality.abstractSoftwareElements.contains(selectedApplication))
applicationAdded = dislocality.abstractSoftwareElements.add(selectedApplication)
}
}
}
/* Enforce all applications to have their tasks on the same board */
for (app : assistModel.applications) {
val colocality = factory.createColocalityRelation
colocality.applications.add(app)
colocality.abstractSoftwareElements.add(app)
colocality.hardwareLevel = HardwareArchitectureLevelType.BOARD
assistModel.colocalityRelations.add(colocality)
}
@@ -10,7 +10,7 @@ Require-Bundle: ch.hilbri.assist.mapping.dsl,
org.junit;bundle-version="4.7.0",
org.eclipse.xtext.junit4,
org.eclipse.xtext.xbase.junit,
org.eclipse.xtext.xbase.lib,
org.eclipse.xtext.xbase.lib;bundle-version="2.14.0",
org.eclipse.xtext.testing,
org.eclipse.xtext.xbase.testing
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
@@ -17,7 +17,7 @@ Require-Bundle: ch.hilbri.assist.mapping.dsl,
org.eclipse.compare,
org.eclipse.xtext.builder,
org.eclipse.xtend.lib;resolution:=optional,
org.eclipse.xtext.xbase.lib
org.eclipse.xtext.xbase.lib;bundle-version="2.14.0"
Import-Package: org.apache.log4j
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Export-Package: ch.hilbri.assist.mapping.dsl.ui.contentassist,
@@ -95,10 +95,7 @@ class MappingDSLLabelProvider extends DefaultEObjectLabelProvider {
val output = new StringBuilder()
output.append("[")
for (app : r.applications) {
output.append(app.name)
if (r.applications.last != app) output.append(", ")
}
output.append(r.softwareElementNames)
output.append("]")
output.append(" dislocal up to ")
output.append(r.hardwareLevel)
@@ -115,10 +112,7 @@ class MappingDSLLabelProvider extends DefaultEObjectLabelProvider {
val output = new StringBuilder()
output.append("[")
for (app : r.applications) {
output.append(app.name)
if (r.applications.last != app) output.append(", ")
}
output.append(r.softwareElementNames)
output.append("]")
output.append(" dissimilar ")
@@ -133,10 +127,7 @@ class MappingDSLLabelProvider extends DefaultEObjectLabelProvider {
val output = new StringBuilder()
output.append("[")
for (app : r.applications) {
output.append(app.name)
if (r.applications.last != app) output.append(", ")
}
output.append(r.softwareElementNames)
output.append("]")
output.append(" on same ")
output.append(r.hardwareLevel)
@@ -9,10 +9,10 @@ Require-Bundle: ch.hilbri.assist.model,
org.eclipse.xtext,
org.eclipse.xtext.xbase,
org.eclipse.equinox.common;bundle-version="3.5.0",
org.eclipse.xtext.xbase.lib,
org.eclipse.xtext.xbase.lib;bundle-version="2.14.0",
org.antlr.runtime,
org.eclipse.xtext.util,
org.eclipse.xtend.lib,
org.eclipse.xtend.lib;bundle-version="2.14.0",
ch.hilbri.assist.gui
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Export-Package: ch.hilbri.assist.mapping.dsl.serializer,
@@ -1,6 +1,6 @@
grammar ch.hilbri.assist.mapping.dsl.MappingDSL with org.eclipse.xtext.common.Terminals
import "ch.hilbri.assist.model"
import "ch.hilbri.assist.model"
import "http://www.eclipse.org/emf/2002/Ecore" as ecore
AssistModel:
@@ -125,14 +125,18 @@ ExclusiveFeatureRequirement returns FeatureRequirement:
/* Safety Restrictions / Relations */
DislocalityRelation:
applications+=[Application] (',' applications+=[Application])* 'dislocal' 'up' 'to' hardwareLevel=HardwareArchitectureLevelType ';';
abstractSoftwareElements+=[AbstractSoftwareElement] (',' abstractSoftwareElements+=[AbstractSoftwareElement])*
'dislocal' 'up' 'to' hardwareLevel=HardwareArchitectureLevelType ';';
ColocalityRelation:
applications+=[Application|QualifiedName] (',' (applications+=[Application]))* 'on' 'same' hardwareLevel=HardwareArchitectureLevelType ';';
abstractSoftwareElements+=[AbstractSoftwareElement] (',' abstractSoftwareElements+=[AbstractSoftwareElement])*
'on' 'same' hardwareLevel=HardwareArchitectureLevelType ';';
DissimilarityRelation:
applications+=[Application|QualifiedName] (',' (applications+=[Application]))*
abstractSoftwareElements+=[AbstractSoftwareElement] (',' abstractSoftwareElements+=[AbstractSoftwareElement])*
'dissimilar' 'based' 'on'
dissimilarityClause=DissimilarityClause ';';
@@ -17,7 +17,7 @@
default="true"
extensions="mdsl"
icon="icons/mapping-specification.png"
id="ch.hilbri.assist.mapping.editors.mappingeditor"
id="ch.hilbri.assist.mapping.dsl.MappingDSL"
name="Mapping Specification">
</editor>
</extension>
@@ -14,9 +14,7 @@ class ColocalityConstraint extends AbstractMappingConstraint {
var worked = false
for (relation : model.colocalityRelations) {
val level = relation.hardwareLevel.value
val tasks = relation.applications.map[tasks]
.flatten
val tasks = relation.allTasks.flatten
val taskVars = tasks.map[solverVariables.getLocationVariablesForTask(it).get(level)]
/* No we require all these variable to take the same value */
@@ -49,9 +49,9 @@ class DislocalityConstraint extends AbstractMappingConstraint {
* to the location variables.
*
* */
if (relation.applications.filter[tasks.size > 1].isNullOrEmpty) {
if (relation.allTasks.filter[size > 1].isNullOrEmpty) {
val tasks = relation.applications.map[tasks].flatten.toSet
val tasks = relation.allTasks.flatten.toSet
val taskVars = tasks.map[solverVariables.getLocationVariablesForTask(it).get(level)]
/* We want to make these vars take different values */
@@ -64,7 +64,7 @@ class DislocalityConstraint extends AbstractMappingConstraint {
*
*/
else {
val taskList = relation.applications.map[tasks]
val taskList = relation.allTasks
val taskVars = taskList.map[it.map[solverVariables.getLocationVariablesForTask(it).get(level)]]
switch (mode) {
@@ -2,16 +2,16 @@ package ch.hilbri.assist.mapping.solver.constraints
import ch.hilbri.assist.mapping.solver.constraints.choco.ACF
import ch.hilbri.assist.mapping.solver.variables.SolverVariablesContainer
import ch.hilbri.assist.model.Application
import ch.hilbri.assist.model.AssistModel
import ch.hilbri.assist.model.DissimilarityClause
import ch.hilbri.assist.model.DissimilarityConjunction
import ch.hilbri.assist.model.DissimilarityDisjunction
import ch.hilbri.assist.model.DissimilarityEntry
import java.util.List
import ch.hilbri.assist.model.Task
import org.chocosolver.solver.Model
import org.chocosolver.solver.constraints.Constraint
import org.chocosolver.solver.constraints.^extension.Tuples
import org.eclipse.emf.common.util.EList
class DissimilarityConstraint extends AbstractMappingConstraint {
new(AssistModel model, Model chocoModel, SolverVariablesContainer solverVariables) {
@@ -23,7 +23,7 @@ class DissimilarityConstraint extends AbstractMappingConstraint {
for (dissimRelation : model.dissimilarityRelations) {
val dissimClause = dissimRelation.dissimilarityClause
val constraint = generateConstraint(dissimRelation.applications, dissimClause)
val constraint = generateConstraint(dissimRelation.allTasks, dissimClause)
if (constraint !== null) {
chocoModel.post(constraint)
worked = true
@@ -33,23 +33,23 @@ class DissimilarityConstraint extends AbstractMappingConstraint {
}
private def Constraint generateConstraint(List<Application> applications, DissimilarityClause clause) {
private def Constraint generateConstraint(EList<EList<Task>> tasksets, DissimilarityClause clause) {
if (clause instanceof DissimilarityConjunction) {
val constraints = clause.dissimilarityClauses.map[generateConstraint(applications, it)]
val constraints = clause.dissimilarityClauses.map[generateConstraint(tasksets, it)]
return chocoModel.and(constraints)
}
else if (clause instanceof DissimilarityDisjunction) {
val constraints = clause.dissimilarityClauses.map[generateConstraint(applications, it)]
val constraints = clause.dissimilarityClauses.map[generateConstraint(tasksets, it)]
return chocoModel.or(constraints)
}
else if (clause instanceof DissimilarityEntry) {
return generateBasicConstraint(applications, clause)
return generateBasicConstraint(tasksets, clause)
}
else
return null
}
private def Constraint generateBasicConstraint(List<Application> applications, DissimilarityEntry entry) {
private def Constraint generateBasicConstraint(EList<EList<Task>> tasksets, DissimilarityEntry entry) {
// Which level in the hardware hierarchy is affected?
val hardwareLevelIdx = entry.hardwareLevel.value
@@ -58,16 +58,13 @@ class DissimilarityConstraint extends AbstractMappingConstraint {
val dissimilarityValuesList = entry.dissimValues
val dissimilarityValues = dissimilarityValuesList.toSet.toList
// Tasks which are affected by this constraint (this is a list of a list of tasks)
val tasks = applications.map[tasks]
// Location Variables for each affected task
val taskLocationVars = tasks.map[map[solverVariables.getLocationVariablesForTask(it).get(hardwareLevelIdx)]]
val taskLocationVars = tasksets.map[map[solverVariables.getLocationVariablesForTask(it).get(hardwareLevelIdx)]]
// Variables to store the index to the dissimilarity value of the deployment of each task
// (these are the variables which should take different values for different applications)
val taskDissimValueVars = newArrayList()
for (group : tasks)
for (group : tasksets)
taskDissimValueVars.add(chocoModel.intVarArray(group.size, 0, dissimilarityValues.size, false).toList)
// Create the tuples to link the deployment to a hardware element (index)
@@ -91,7 +88,7 @@ class DissimilarityConstraint extends AbstractMappingConstraint {
}
/* Simple Case: we assume that in each application, there is only one task! */
if (applications.map[tasks].filter[size > 1].isNullOrEmpty) {
if (tasksets.filter[size > 1].isNullOrEmpty) {
// We want to enforce, that each of these taskDissimValueVars takes a unique value
// --> a simple allDifferent is sufficient
return chocoModel.allDifferent(taskDissimValueVars.flatten)
@@ -514,3 +514,10 @@ _UI_ExplorationResult_mappingResult_feature = Mapping Result
_UI_MappingResult_isUsed_feature = Is Used
_UI_MappingResult_c_feature = C
_UI_MappingResult___feature =
_UI_MappingRelation_HardwareArchitectureLevelType_feature = Hardware Architecture Level Type
_UI_MappingRelation___feature =
_UI_MappingRelation_tasks_feature = Tasks
_UI_MappingRelation_allTasks_feature = All Tasks
_UI_AbstractSoftwareElement_type = Abstract Software Element
_UI_MappingRelation_abstractSoftwareElements_feature = Abstract Software Elements
_UI_MappingRelation_softwareElementNames_feature = Software Element Names
Oops, something went wrong.

0 comments on commit a74edde

Please sign in to comment.