Commit 80c8b94b authored by Alexander Diewald's avatar Alexander Diewald

DSE-TCgen: Do not mark all components strongly causal

* Marking all Components as strongly causal would create non-realistic
  test cases for scheduling problems.
* Heuristically mark one component of each strongly connected cycle of
  each component architecture as strongly causal. This eliminates most
  cycles. To be safe, the weak cycle checker is executed afterwards and
  all violating components are marked as strongly causal, too, at the
  risk of marking few more components as strongly causal than needed.

Issue-Ref: 4008
Issue-Url: https://af3-developer.fortiss.org/issues/4008Signed-off-by: Alexander Diewald's avatarAlexander Diewald <diewald@fortiss.org>
parent 4a67aeff
ArchitectureGraph.java 4f1539b6997b7a71d744ef750aa2f102097f211d YELLOW
ExplorationTestCaseGenerator.java 583c4679996e0c8c277c23da4f5285dea849b650 RED
ExplorationTestCaseGenerator.java 583c4679996e0c8c277c23da4f5285dea849b650 YELLOW
AnnotationGenerationUtils.java 7fdab0a64ce72636bc59262b889b62eed54980ee YELLOW
CompArchGeneratonUtil.java d8c6db8002cc003f3681d6afd5fff3742c5fa437 RED
CompArchGeneratonUtil.java e771498a4bd7fe56219a3af74c40c190d02959ae YELLOW
DseUtils.java d81af0b7f649d2453aada362fc50572fce31ebc8 YELLOW
FileWriterUtil.java 4a95559f571d41fa44e6236fc055ab5baac7c384 YELLOW
GraphGenerationUtilities.java 40213f344dec1f62a0bb965739cb967f367803d4 YELLOW
GraphMetricUtils.java 99a398d4ff9b15b3eeb35748e32aa34a9b197f07 YELLOW
GraphUtils.java d11a2a067b343a2639f495c3417328f268f57127 YELLOW
GraphUtils.java 08b285a67bf86c2b92bb0eab3d50551ba23dc410 YELLOW
ProjectUtils.java fe0009a32f6aaa58fb3330e2b9e383e217afc0dd YELLOW
......@@ -23,7 +23,6 @@ import static java.lang.Math.pow;
import static org.fortiss.af3.component.utils.ComponentModelElementFactory.createComponent;
import static org.fortiss.af3.exploration.testgenerator.util.GraphGenerationUtilities.generateRandomGraph;
import static org.fortiss.af3.exploration.testgenerator.util.GraphUtils.getComponentArchitecture;
import static org.fortiss.tooling.base.utils.AnnotationUtils.instantiateAnnotationsRecursive;
import java.io.IOException;
import java.util.HashSet;
......@@ -65,7 +64,7 @@ public class CompArchGeneratonUtil {
// this property should only be set for components to break cycles. This also has an impact
// on the DSE results.
Function<Integer, Component> createComponent =
index -> createComponent("Component_" + index, "", true);
index -> createComponent("Component_" + index, "", false);
Set<ArchitectureGraph<Component>> templates =
generateNetworkTemplates(minNumberOfComponents, maxNumberOfComponents,
numberOfArchitectures, createComponent);
......@@ -76,10 +75,6 @@ public class CompArchGeneratonUtil {
template.vertexSet().size() + "_" + template.edgeSet().size()));
}
for(ComponentArchitecture compArch : logicalArchitectures) {
instantiateAnnotationsRecursive(compArch);
}
return logicalArchitectures;
}
......
......@@ -4,8 +4,13 @@ import static org.fortiss.af3.component.utils.ComponentModelElementFactory.creat
import static org.fortiss.af3.component.utils.ComponentModelElementFactory.createInputPort;
import static org.fortiss.af3.component.utils.ComponentModelElementFactory.createOutputPort;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.fortiss.af3.component.constraint.WeakCausalityCycleConstraintChecker;
import org.fortiss.af3.component.model.Channel;
import org.fortiss.af3.component.model.Component;
import org.fortiss.af3.component.model.ComponentArchitecture;
......@@ -13,6 +18,9 @@ import org.fortiss.af3.component.model.InputPort;
import org.fortiss.af3.component.model.OutputPort;
import org.fortiss.af3.component.utils.ComponentModelElementFactory;
import org.fortiss.af3.exploration.testgenerator.ArchitectureGraph;
import org.fortiss.tooling.kernel.extension.data.IConstraintViolation;
import org.jgrapht.alg.connectivity.GabowStrongConnectivityInspector;
import org.jgrapht.alg.interfaces.StrongConnectivityAlgorithm;
import org.jgrapht.graph.DefaultWeightedEdge;
import com.google.common.collect.HashBasedTable;
......@@ -92,6 +100,8 @@ public class GraphUtils {
ComponentArchitecture architecture =
ComponentModelElementFactory.createComponentArchitecture(topLevelComponent);
defineStronglyCausalComponents(graph);
for(Component component : graph.vertexSet()) {
topLevelComponent.getContainedElements().add(component);
}
......@@ -111,9 +121,57 @@ public class GraphUtils {
channel_id++;
}
breakRemainingCycles(architecture);
return architecture;
}
/**
* Heuristically sets the strong connectivity property of {@link Component}s to break cycles.
* This method identifies strongly connected cycles and marks one {@link Component} of each as
* strongly causal.
*/
private static void defineStronglyCausalComponents(ArchitectureGraph<Component> graph) {
StrongConnectivityAlgorithm<Component, DefaultWeightedEdge> connAlg =
new GabowStrongConnectivityInspector<>(graph);
Map<Component, Integer> cycleOccurrenceMap = new HashMap<>();
graph.vertexSet().forEach(c -> cycleOccurrenceMap.put(c, 0));
for(Set<Component> strongCycle : connAlg.stronglyConnectedSets()) {
for(Component comp : strongCycle) {
Integer occurence = cycleOccurrenceMap.get(comp);
++occurence;
}
}
for(Set<Component> strongCycle : connAlg.stronglyConnectedSets()) {
// Select that component of the strongly connected cycle that is most promising to break
// cycles. It is the component occuring in most other cycles.
Component strongComp = strongCycle.stream().findAny().get();
for(Component comp : strongCycle) {
if(cycleOccurrenceMap.get(comp) > cycleOccurrenceMap.get(strongComp)) {
strongComp = comp;
}
}
strongComp.getCausalitySpecification().setStronglyCausal(true);
}
}
/**
* Uses the constraint checker to identify {@link Component}s of remaining cycles that were not
* broken by the heuristics.
*/
private static void breakRemainingCycles(ComponentArchitecture compArch) {
List<IConstraintViolation<Component>> results = new ArrayList<>();
WeakCausalityCycleConstraintChecker checker = new WeakCausalityCycleConstraintChecker();
checker.collectViolations(compArch, results);
for(IConstraintViolation<Component> violation : results) {
violation.getSource().getCausalitySpecification().setStronglyCausal(true);
}
}
/**
* Checks whether a logical component is connected to another one.
*
......
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