Commit 26c53f4c authored by Andreas Bayha's avatar Andreas Bayha
Browse files

Merge remote-tracking branch 'remotes/origin/master' into 4014

parents 6b54dc48 5f678e7a
AF3ExplorationSMTActivator.java db8c07de55429ead58b5127affc48232e31819d3 YELLOW
AF3ExplorationSMTActivator.java db8c07de55429ead58b5127affc48232e31819d3 GREEN
DumpSMTLibFileCommandLineHandler.java 95604962b4db14786ec8143663278c4a865bbd55 GREEN
DumpSMTLibFileCommandLineHandler.java d23183aa018acc0a749a464e13cfa2a5d15db26a GREEN
......@@ -144,7 +144,7 @@ public final class DumpSMTLibFileCommandLineHandler implements ICommandLineSwitc
ProcessStep dseStep = dse.getCurrentStep();
for(RuleSet ruleSet : dseStep.getRuleSets()) {
allExplorationTargets = ruleSet.getExplorationTargets();
allExplorationTargets.addAll(ruleSet.getExplorationTargets());
}
return allExplorationTargets;
......
RuleSetUIProvider.java 9805f8c6d231992cc3471ea2cd9e6b3eb05e004d GREEN
SolverSettingsDialog.java 25b3541fc6eab090500321fa32a3f68992fff0a0 GREEN
SolverSettingsTreeTableViewer.java 0f0be7ff52d2c48fbff9d37c7e23bd7a99eb1948 GREEN
SynthesisCategoryExplorationTargetContentProvider.java 410f00e07b5f4208b762b80baf563b2b73a93a71 GREEN
SynthesisCategoryRuleSetContentProvider.java 039913dba18b0248d10a77275258bc9acf9526cf GREEN
SynthesisCategoryExplorationTargetContentProvider.java ecc4072d6ba9611da5f9996e80d4ccaaf376414e GREEN
SynthesisCategoryRuleSetContentProvider.java f17ea9c4b6fb4126d834e0852b766b686d3c7e42 GREEN
SynthesisFXContentController.java 0af860ed5ab2788042296d89c195ba2e2204447e GREEN
SynthesisFXViewPart.java e40c2bd501d87b41c6324ab80fd34e64410db644 GREEN
......@@ -18,7 +18,6 @@ package org.fortiss.af3.exploration.ui.perspective.synthesis;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.function.Predicate;
import java.util.function.Supplier;
import java.util.stream.Stream;
......@@ -47,10 +46,11 @@ public class SynthesisCategoryExplorationTargetContentProvider<T extends IExplor
/** {@inheritDoc} */
@Override
protected Predicate<T> getFilterPredicate() {
return (e) -> {
return e != null ? synthCategories.containsAll(e.getSynthesisCategories()) : false;
};
protected boolean filter(T element, String filterValue) {
if (element == null) {
return false;
}
return synthCategories.containsAll(element.getSynthesisCategories());
}
/** {@inheritDoc} */
......
......@@ -20,7 +20,6 @@ import static java.util.stream.Collectors.toList;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.function.Predicate;
import java.util.function.Supplier;
import java.util.stream.Stream;
......@@ -49,14 +48,12 @@ public class SynthesisCategoryRuleSetContentProvider extends
/** {@inheritDoc} */
@Override
protected Predicate<RuleSet> getFilterPredicate() {
return (rs) -> {
@SuppressWarnings("unchecked") Collection<Class<? extends ISynthesisCategory>> rsCategories =
(Collection<Class<? extends ISynthesisCategory>>)(Collection<?>)rs
.getExplorationTargets().stream()
.flatMap(c -> c.getSynthesisCategories().stream()).collect(toList());
return synthCategories.containsAll(rsCategories);
};
protected boolean filter(RuleSet element, String filterValue) {
@SuppressWarnings("unchecked") Collection<Class<? extends ISynthesisCategory>> rsCategories =
(Collection<Class<? extends ISynthesisCategory>>)(Collection<?>)element
.getExplorationTargets().stream()
.flatMap(c -> c.getSynthesisCategories().stream()).collect(toList());
return synthCategories.containsAll(rsCategories);
}
/** {@inheritDoc} */
......
ExecuteDSECommandLineHandler.java 4d80dee08bbf5f66d460bcdd158aaf3c96b654ab GREEN
TestCaseGenerationCommandLineHandler.java ccd942515f5490ff9ed6ece891f3ade206333a08 GREEN
ExecuteDSECommandLineHandler.java 7955b0bf22da3f4c4b72b441d201cf60d71ae6b6 GREEN
TestCaseGenerationCommandLineHandler.java 8df52cceacf8e873d612643e6b0ba50202b97c71 GREEN
ValidateDSESolutionCommandLineInterface.java 1b882428463c21c355d96c883af428d3fa4cce2d GREEN
......@@ -145,7 +145,7 @@ public final class ExecuteDSECommandLineHandler implements ICommandLineSwitchHan
ProcessStep dseStep = dse.getCurrentStep();
for(RuleSet ruleSet : dseStep.getRuleSets()) {
allExplorationTargets = ruleSet.getExplorationTargets();
allExplorationTargets.addAll(ruleSet.getExplorationTargets());
}
return allExplorationTargets;
......
......@@ -40,13 +40,13 @@ public class TestCaseGenerationCommandLineHandler implements ICommandLineSwitchH
* cases is the cross product of {@link ComponentArchitecture}s and generated
* {@link PlatformArchitecture}s.
*/
private final int compArchNum = 1;
private final static int COMP_ARCH_NUM = 1;
/** Minimal number of {@link Component}s per {@link ComponentArchitecture}. */
private final int minComponentNum = 10;
private final static int MIN_COMP_NUM = 20;
/** Maximum number of {@link Component}s per {@link ComponentArchitecture}. */
private final int maxComponentNum = 15;
private final static int MAX_COMP_NUM = 30;
/** {@inheritDoc} */
@Override
......@@ -64,7 +64,7 @@ public class TestCaseGenerationCommandLineHandler implements ICommandLineSwitchH
}
try {
generateTestCases(compArchNum, minComponentNum, maxComponentNum);
generateTestCases(COMP_ARCH_NUM, MIN_COMP_NUM, MAX_COMP_NUM);
} catch(Exception e) {
error(AF3ExpressionActivator.getDefault(),
"The DSE random test case generation failed.", e);
......
AnnotationGenerationUtils.java 0808cbc47239dfb8984690b51864ad5ea594bb01 GREEN
AnnotationGenerationUtils.java a4f1635f783e4764f963107fcbcb96bc070366ca GREEN
CompArchGeneratonUtil.java 0f1e3c048884fa4df6a35b6a110c46da58f59857 GREEN
DseUtils.java 1a9e73e2605271ad1e559e4ad38843171a60a48d GREEN
DseUtils.java 7a93f643bcc25adc9df3c53a1c8e74f89eda4608 GREEN
FileWriterUtil.java 4a95559f571d41fa44e6236fc055ab5baac7c384 GREEN
GraphGenerationUtilities.java e637fd6a38339c60a6a7ac5af116db304266d345 GREEN
GraphMetricUtils.java 99a398d4ff9b15b3eeb35748e32aa34a9b197f07 GREEN
......
......@@ -34,9 +34,9 @@ import java.util.Random;
import org.fortiss.af3.component.model.ComponentArchitecture;
import org.fortiss.af3.exploration.AF3ExplorationActivator;
import org.fortiss.af3.platform.model.ExecutionUnit;
import org.fortiss.af3.platform.model.PlatformArchitecture;
import org.fortiss.af3.platform.model.annotation.FlashSize;
import org.fortiss.af3.platform.model.annotation.RamSize;
import org.fortiss.af3.project.model.FileProject;
import org.fortiss.af3.safety.model.SIL;
import org.fortiss.af3.safety.model.annotation.SafetyIntegrityLevel;
......@@ -47,6 +47,7 @@ import org.fortiss.af3.task.model.timing.TaskStartEvent;
import org.fortiss.af3.timing.model.PeriodicConstraint;
import org.fortiss.af3.timing.model.TimingSpecification;
import org.fortiss.af3.timing.model.annotation.Wcet;
import org.fortiss.tooling.base.model.element.IAnnotatedSpecification;
import org.fortiss.tooling.kernel.utils.EcoreUtils;
/**
......@@ -56,6 +57,9 @@ import org.fortiss.tooling.kernel.utils.EcoreUtils;
*/
public class AnnotationGenerationUtils {
/** Amount of memory available for tasks relative to the memory provided by execution units. */
private static double[] MEMORY_USAGE = {1.0};
/** Hiding constructor. */
private AnnotationGenerationUtils() {
// Prevent instantiation.
......@@ -63,13 +67,19 @@ public class AnnotationGenerationUtils {
/**
* Creates an expanded set of the given {@link ComponentArchitecture}s where each element is
* based on a copy of the given architectures The returned set is larger than the initial one.
* based on a copy of the given architectures. The returned set is larger than the initial one.
* The added annotation values are generated randomly.
*
* @param fileProjects
* Set of {@link FileProject}s to whose architectures
* {@link IAnnotatedSpecification}s are added.
* @return Set of {@link FileProject}s with {@link IAnnotatedSpecification}s.
*/
public static Collection<FileProject> expandArchitecturesByAnnotations(
Collection<FileProject> fileProjects) throws Exception {
// Add the expansion code for other
fileProjects = definePlatformArchitectureAnnotations(fileProjects);
fileProjects = expandPlatformArchitectureAnnotations(fileProjects);
fileProjects = expandTaskArchitecturesByAnnotations(fileProjects);
return fileProjects;
......@@ -79,44 +89,34 @@ public class AnnotationGenerationUtils {
* PlatformArchitecture Annotations.
**********************************************************************************************/
/** Amount of available Flash memory per ECU. */
private final static Integer[] FLASH_AMOUNT = {10, 100, 1000};
/** Sets the annotation values for the {@link PlatformArchitecture}s. */
/**
* Sets the annotation values for the {@link PlatformArchitecture}s.
*
* @param fileProjects
* Set of {@link FileProject}s to whose architectures
* {@link IAnnotatedSpecification}s are added.
* @return Set of {@link FileProject}s with {@link IAnnotatedSpecification}s.
*/
private static Collection<FileProject>
definePlatformArchitectureAnnotations(Collection<FileProject> fileProjects) {
fileProjects = defineRAM(fileProjects);
fileProjects = defineFlash(fileProjects);
fileProjects = defineSIL(fileProjects);
expandPlatformArchitectureAnnotations(Collection<FileProject> fileProjects) {
fileProjects = expandByFlash(fileProjects);
fileProjects = expandBySIL(fileProjects);
return fileProjects;
}
/** Sets the values of {@link RamSize} annotations. */
private static Collection<FileProject> defineRAM(Collection<FileProject> fileProjects) {
Collection<FileProject> expandedProjects = new ArrayList<>();
for(FileProject origProject : fileProjects) {
for(int amount : FLASH_AMOUNT) {
FileProject project = copy(origProject);
PlatformArchitecture platArch =
pickFirstInstanceOf(PlatformArchitecture.class, project.getRootElements());
List<RamSize> rams = getChildrenWithType(platArch, RamSize.class);
rams.forEach(ram -> ram.setBytes(amount));
expandedProjects.add(project);
}
}
return expandedProjects;
}
/** Sets the values of {@link FlashSize} annotations. */
private static Collection<FileProject> defineFlash(Collection<FileProject> fileProjects) {
private static Collection<FileProject> expandByFlash(Collection<FileProject> fileProjects) {
Collection<FileProject> expandedProjects = new ArrayList<>();
for(FileProject origProject : fileProjects) {
for(int amount : FLASH_AMOUNT) {
FileProject project = copy(origProject);
PlatformArchitecture platArch =
pickFirstInstanceOf(PlatformArchitecture.class, project.getRootElements());
List<FlashSize> falshs = getChildrenWithType(platArch, FlashSize.class);
falshs.forEach(flash -> flash.setBytes(amount));
List<FlashSize> flashs = getChildrenWithType(platArch, FlashSize.class);
flashs.forEach(flash -> flash.setBytes(amount));
expandedProjects.add(project);
}
}
......@@ -125,7 +125,7 @@ public class AnnotationGenerationUtils {
}
/** Sets the values of {@link SafetyIntegrityLevel} annotations. */
private static Collection<FileProject> defineSIL(Collection<FileProject> fileProjects) {
private static Collection<FileProject> expandBySIL(Collection<FileProject> fileProjects) {
Random rand = new Random(System.currentTimeMillis());
Collection<FileProject> expandedProjects = new ArrayList<>();
......@@ -155,7 +155,13 @@ public class AnnotationGenerationUtils {
* TaskArchitecture Annotations.
**********************************************************************************************/
/** Adds annotations to the {@link TaskArchitecture}s of the given {@link FileProject}s */
/**
* Adds annotations to the {@link TaskArchitecture}s of the given {@link FileProject}s.
*
* @param fileProjects
* {@link FileProject}s to be updated.
* @return Set of {@link FileProject}s with {@link IAnnotatedSpecification}s.
*/
private static Collection<FileProject> expandTaskArchitecturesByAnnotations(
Collection<FileProject> fileProjects) throws Exception {
Collection<FileProject> expandedFileProjects = new ArrayList<>();
......@@ -163,14 +169,16 @@ public class AnnotationGenerationUtils {
for(FileProject filePrj : fileProjects) {
PlatformArchitecture platArch =
pickFirstInstanceOf(PlatformArchitecture.class, filePrj.getRootElements());
int numExecUnits = getChildrenWithType(platArch, ExecutionUnit.class).size();
List<FlashSize> flashAnnotations = getChildrenWithType(platArch, FlashSize.class);
long availFlash = flashAnnotations.stream().map(flash -> flash.getValue())
.mapToLong(Long::longValue).sum();
for(double memoryUsage = 0.5; memoryUsage < 1; memoryUsage += 0.25) {
for(double memoryUsage : MEMORY_USAGE) {
FileProject expandedFP = EcoreUtils.copy(filePrj);
TaskArchitecture taskArch =
pickFirstInstanceOf(TaskArchitecture.class, expandedFP.getRootElements());
defineTaskMemoryRequirements(taskArch, availFlash, memoryUsage);
defineTaskMemoryRequirements(taskArch, availFlash, memoryUsage, numExecUnits);
defineWCETs(taskArch);
definePeriods(expandedFP, taskArch);
expandedFileProjects.add(expandedFP);
......@@ -181,14 +189,23 @@ public class AnnotationGenerationUtils {
}
/**
* Defines the flash memory requirements of tasks based on an upper limit and random assignment.
* Defines flash memory requirements of tasks based on an upper limit and random assignment.
*
* @param taskArch
* modified.
* @param availableMemory
* available system memory
* @param memoryUsageRatio
* how much available memory may be defined as required by {@link Task}s.
* @param numExecUnits
* number of {@link ExecutionUnit}s of the platform.
*/
private static void defineTaskMemoryRequirements(TaskArchitecture taskArch,
long availableMemory, double memoryUsageRatio) throws Exception {
long availableMemory, double memoryUsageRatio, int numExecUnits) throws Exception {
List<Task> tasks = taskArch.getTasks();
int childComponentNum = tasks.size();
List<Long> memoryRequirements =
generateMemoryRequirements(availableMemory, childComponentNum, memoryUsageRatio);
List<Long> memoryRequirements = generateMemoryRequirements(availableMemory,
childComponentNum, memoryUsageRatio, numExecUnits);
for(int index = 0; index < childComponentNum; index++) {
setAnnotationValue(tasks.get(index), FlashRequirement.class,
......@@ -196,7 +213,12 @@ public class AnnotationGenerationUtils {
}
}
/** Defines the WCETs of tasks. */
/**
* Defines the WCETs of tasks.
*
* @param taskArch
* modified.
*/
private static void defineWCETs(TaskArchitecture taskArch) {
Random rand = new Random(currentTimeMillis());
......@@ -222,23 +244,26 @@ public class AnnotationGenerationUtils {
* Number of components
* @param memoryUsageRatio
* Ratio of the total amount of memory to use
* @param numExecUnits
* Number of {@link ExecutionUnit}s in the platform.
* @return A set of integers, each representing a memory constraint for a component
*/
private static List<Long> generateMemoryRequirements(long availableMemory,
int numberOfComponents, double memoryUsageRatio) {
int numberOfComponents, double memoryUsageRatio, int numExecUnits) {
double maxMemory = availableMemory * memoryUsageRatio;
Random random = new Random();
List<Double> randomNumbers = new ArrayList<Double>();
for(int i = 0; i < numberOfComponents; i++) {
randomNumbers.add(random.nextDouble());
double randAmount = random.nextDouble() * maxMemory / numberOfComponents;
randAmount = randAmount < (availableMemory / numExecUnits) ? randAmount
: (availableMemory / numExecUnits);
randomNumbers.add(randAmount);
}
double randomSum = randomNumbers.stream().mapToDouble(Double::doubleValue).sum();
double factor = maxMemory / randomSum;
List<Long> memoryRequirements = new ArrayList<>();
for(double randomNumber : randomNumbers) {
memoryRequirements.add((long)floor(randomNumber * factor));
memoryRequirements.add((long)floor(randomNumber));
}
return memoryRequirements;
......
......@@ -68,12 +68,10 @@ import org.fortiss.af3.platform.model.ExecutionUnit;
import org.fortiss.af3.platform.model.PlatformArchitecture;
import org.fortiss.af3.platform.model.Route;
import org.fortiss.af3.platform.model.annotation.FlashSize;
import org.fortiss.af3.platform.model.annotation.RamSize;
import org.fortiss.af3.project.model.FileProject;
import org.fortiss.af3.task.model.Task;
import org.fortiss.af3.task.model.TaskArchitecture;
import org.fortiss.af3.task.model.annotation.FlashRequirement;
import org.fortiss.af3.task.model.annotation.RamRequirement;
import org.fortiss.af3.timing.model.TimingSpecification;
import org.fortiss.tooling.kernel.model.IProjectRootElement;
import org.fortiss.tooling.kernel.utils.EcoreUtils;
......@@ -87,10 +85,10 @@ import org.fortiss.tooling.kernel.utils.EcoreUtils;
public class DseUtils {
/** Maximally allowed flash utilization per {@link ExecutionUnit} (ratio) */
private static final double FLASH_MAX_UTIL = 1.0;
private static final double[] FLASH_MAX_UTIL = {0.5, 1.0};
/** List of task percentages whose allocation is fixed. */
private static final int[] ALLOC_PERCENTAGES = {0, 25, 50, 75};
private static final int[] ALLOC_PERCENTAGES = {25, 75};
/** Hiding constructor. */
private DseUtils() {
......@@ -168,26 +166,29 @@ public class DseUtils {
*/
private static Collection<FileProject>
addFlashConstraints(Collection<FileProject> fileProjects) {
Collection<FileProject> expandedProjects = new ArrayList<>();
for(FileProject fp : fileProjects) {
DSE dse = pickFirstInstanceOf(DSE.class, fp.getRootElements());
TargetDefinitionStep tgtDefStep = getTargetDefinitionStep(dse);
for(double maxFlashUtil : FLASH_MAX_UTIL) {
FileProject expandedFileProject = copy(fp);
expandedProjects.add(expandedFileProject);
DSE dse = pickFirstInstanceOf(DSE.class, expandedFileProject.getRootElements());
TargetDefinitionStep tgtDefStep = getTargetDefinitionStep(dse);
Collection<IExplorationConstraint<Boolean>> constraints = new ArrayList<>();
SuperSet<ExecutionUnit> execUnits =
dse.getCurrentStep().getSuperSetMap().get(ExecutionUnit.class);
SuperSet<ExecutionUnit> execUnits =
dse.getCurrentStep().getSuperSetMap().get(ExecutionUnit.class);
IBooleanExpression expression = createBooleanLiteral(true);
for(ExecutionUnit executionUnit : execUnits.getEntries()) {
expression = createAnd(expression, createUtilizationPatternExpression(dse,
FLASH_MAX_UTIL, executionUnit, RamRequirement.class, RamSize.class));
}
@SuppressWarnings("unchecked") IExplorationConstraint<Boolean> constr =
createExplorationConstraint(Boolean.class, createResourceDimension(),
newHashSet(IDeploymentSynthesis.class), expression,
"Max Flash Util " + FLASH_MAX_UTIL * 100 + " of all ExecutionUnits.",
false);
IBooleanExpression expression = createBooleanLiteral(true);
for(ExecutionUnit executionUnit : execUnits.getEntries()) {
expression = createAnd(expression, createUtilizationPatternExpression(dse,
maxFlashUtil, executionUnit, FlashRequirement.class, FlashSize.class));
}
@SuppressWarnings("unchecked") IExplorationConstraint<Boolean> constr =
createExplorationConstraint(Boolean.class, createResourceDimension(),
newHashSet(IDeploymentSynthesis.class), expression,
"Max Flash Util " + maxFlashUtil * 100 + " of all ExecutionUnits.",
false);
if(!constraints.isEmpty()) {
RuleSet flashRuleSet = createRuleSet("Flash constraints", "Generated", "");
flashRuleSet.getExplorationTargets().add(constr);
......@@ -196,7 +197,7 @@ public class DseUtils {
}
}
return fileProjects;
return expandedProjects;
}
/**
......
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