Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ xtend-gen/
*.iml

tests/dev.arcovia.mitigation.sat.tests/testresults/*.json
tests/dev.arcovia.mitigation.sat.tests/efficencyTest/*.json
tests/dev.arcovia.mitigation.ilp.tests/efficencyTest/*.json
tests/dev.arcovia.mitigation.sat.tests/efficiencyTest/*.json
tests/dev.arcovia.mitigation.ilp.tests/efficiencyTest/*.json
!*literalMapping.json
*.lp
tests/dev.arcovia.mitigation.ilp.tests/models/temp-repaired.json
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,49 +72,88 @@ public int calculateCost() {

return cost;
}
public int calculateCostWithoutForwarding() {

public void changedLabelsWithoutForwarding() {
determineRelevantLabels();
for (var label : allRelevantLabels.keySet()) {
for (var vertex : nodes) {
if (vertex.hasVertexLabel(label))
allRelevantLabels.get(label)
.add("Vertex: " + vertex.name);

var assignments = vertex.getAssignments();

for (var assignment : assignments) {

List<org.dataflowanalysis.dfd.datadictionary.Label> assignmentLabel = null;

if (assignment instanceof Assignment cast) {
assignmentLabel = cast.getOutputLabels();

}
else if (assignment instanceof SetAssignment cast) {

} else if (assignment instanceof SetAssignment cast) {
assignmentLabel = cast.getOutputLabels();
}
if (assignmentLabel == null) continue;

if (assignmentLabel == null)
continue;

for (var l : assignmentLabel) {
LabelTypeImpl labelType = (LabelTypeImpl) l.eContainer();

var tempLabel = new Label(labelType.getEntityName(),l.getEntityName());

if (tempLabel.toString().equals(label.toString())) {

var tempLabel = new Label(labelType.getEntityName(), l.getEntityName());

if (tempLabel.toString()
.equals(label.toString())) {
Pin outpin = assignment.getOutputPin();
allRelevantLabels.get(label)
.add("Outgoing: " + outpin.getId() + " from: " + vertex.name);
.add("Outgoing: " + outpin.getId() + " from: " + vertex.name);
}
}
}
}
}
}

public int calculateCostWithoutForwarding() {
changedLabelsWithoutForwarding();

for (var label : allRelevantLabels.keySet()) {
cost += allRelevantLabels.get(label)
.size() * costs.get(label);
}

return cost;
}

public int calculateSymmetricDifferenceCost(ModelCostCalculator referenceCalculator) {

changedLabelsWithoutForwarding();
referenceCalculator.changedLabelsWithoutForwarding();

Set<Label> mergedRelevantLabels = new HashSet<>();
mergedRelevantLabels.addAll(allRelevantLabels.keySet());
mergedRelevantLabels.addAll(referenceCalculator.allRelevantLabels.keySet());

int changeCost = 0;

for (var label : mergedRelevantLabels) {
Set<String> currentPlacements = allRelevantLabels.getOrDefault(label, Set.of());

Set<String> referencePlacements = referenceCalculator.allRelevantLabels.getOrDefault(label, Set.of());

Set<String> addedPlacements = new HashSet<>(currentPlacements);
addedPlacements.removeAll(referencePlacements);

Set<String> removedPlacements = new HashSet<>(referencePlacements);
removedPlacements.removeAll(currentPlacements);

int labelCost = costs.get(label);

changeCost += (addedPlacements.size() + removedPlacements.size()) * labelCost;
}

return changeCost;
}

private void pushLabel(Label label, Pin sourcePin) {
var destinationPin = sourcePinToDestinationPin.get(sourcePin);
var destinationNode = inPinToVertex.get(destinationPin);
Expand Down
Comment thread
uuqjz marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -3,55 +3,55 @@
<target name="Target Platform" sequenceNumber="1">
<locations>
<location includeAllPlatforms="false" includeConfigurePhase="true" includeMode="planner" includeSource="false" type="InstallableUnit">
<unit id="de.uka.ipd.sdq.identifier.feature.feature.group" version="0.0.0"/>
<unit id="org.palladiosimulator.commons.stoex.sdk.feature.group" version="0.0.0"/>
<repository location="https://updatesite.palladio-simulator.com/palladio-core-commons/nightly/"/>
<unit id="de.uka.ipd.sdq.identifier.feature.feature.group" version="5.2.2"/>
<unit id="org.palladiosimulator.commons.stoex.sdk.feature.group" version="5.2.2"/>
<repository location="https://updatesite.palladio-simulator.com/palladio-core-commons/releases/5.2.2/"/>
</location>
<location includeAllPlatforms="false" includeConfigurePhase="true" includeMode="planner" includeSource="false" type="InstallableUnit">
<unit id="org.palladiosimulator.pcm.feature.feature.group" version="0.0.0"/>
<repository location="https://updatesite.palladio-simulator.com/palladio-core-pcm/nightly/"/>
<unit id="org.palladiosimulator.pcm.feature.feature.group" version="5.2.2"/>
<repository location="https://updatesite.palladio-simulator.com/palladio-core-pcm/releases/5.2.2/"/>
</location>
<location includeAllPlatforms="false" includeConfigurePhase="true" includeMode="planner" includeSource="false" type="InstallableUnit">
<unit id="org.palladiosimulator.pcm.edit" version="0.0.0"/>
<repository location="https://updatesite.palladio-simulator.com/palladio-editors-commons/nightly/"/>
<unit id="org.palladiosimulator.pcm.edit" version="5.2.2"/>
<repository location="https://updatesite.palladio-simulator.com/palladio-editors-commons/releases/5.2.2/"/>
</location>
<location includeAllPlatforms="false" includeConfigurePhase="true" includeMode="planner" includeSource="false" type="InstallableUnit">
<unit id="de.uka.ipd.sdq.workflow.feature.core.feature.group" version="0.0.0"/>
<repository location="https://updatesite.palladio-simulator.com/palladio-supporting-workflowengine/nightly/"/>
<unit id="de.uka.ipd.sdq.workflow.feature.core.feature.group" version="5.2.2"/>
<repository location="https://updatesite.palladio-simulator.com/palladio-supporting-workflowengine/releases/5.2.2/"/>
</location>
<location includeAllPlatforms="false" includeConfigurePhase="true" includeMode="planner" includeSource="false" type="InstallableUnit">
<unit id="tools.mdsd.library.emfeditutils.feature.feature.group" version="0.0.0"/>
<repository location="https://updatesite.mdsd.tools/library-emfeditutils/nightly/"/>
<repository location="https://updatesite.mdsd.tools/library-emfeditutils/releases/1.0.0/"/>
</location>
<location includeAllPlatforms="false" includeConfigurePhase="true" includeMode="planner" includeSource="false" type="InstallableUnit">
<unit id="tools.mdsd.library.standalone.initialization.log4j" version="0.0.0"/>
<unit id="tools.mdsd.library.standalone.initialization.emfprofiles" version="0.0.0"/>
<unit id="tools.mdsd.library.standalone.initialization" version="0.0.0"/>
<repository location="https://updatesite.mdsd.tools/library-standaloneinitialization/nightly/"/>
<repository location="https://updatesite.mdsd.tools/library-standaloneinitialization/releases/1.0.0/"/>
</location>
<location includeAllPlatforms="false" includeConfigurePhase="true" includeMode="planner" includeSource="false" type="InstallableUnit">
<unit id="tools.mdsd.license.epl2.feature.group" version="0.0.0"/>
<repository location="https://updatesite.mdsd.tools/build-licensefeature/releases/latest/"/>
<repository location="https://updatesite.mdsd.tools/build-licensefeature/releases/1.0.0/"/>
</location>
<location includeAllPlatforms="false" includeConfigurePhase="true" includeMode="planner" includeSource="false" type="InstallableUnit">
<unit id="org.modelversioning.emfprofile.registry" version="0.0.0"/>
<repository location="https://updatesite.palladio-simulator.com/palladio-thirdparty-emfprofiles/nightly/"/>
<unit id="org.modelversioning.emfprofile.registry" version="5.2.2"/>
<repository location="https://updatesite.palladio-simulator.com/palladio-thirdparty-emfprofiles/releases/5.2.2/"/>
</location>
<location includeAllPlatforms="false" includeConfigurePhase="true" includeMode="planner" includeSource="false" type="InstallableUnit">
<unit id="tools.mdsd.modelingfoundations.identifier.feature.feature.group" version="0.0.0"/>
<unit id="tools.mdsd.modelingfoundations.identifier.ui.feature.feature.group" version="0.0.0"/>
<repository location="https://updatesite.mdsd.tools/metamodel-modeling-foundations/nightly/"/>
<repository location="https://updatesite.mdsd.tools/metamodel-modeling-foundations/releases/1.0.0/"/>
</location>
<location includeAllPlatforms="false" includeConfigurePhase="true" includeMode="planner" includeSource="false" type="InstallableUnit">
<unit id="org.dataflowanalysis.pcm.extension.dictionary.characterized" version="0.0.0"/>
<unit id="org.dataflowanalysis.pcm.extension.dddsl" version="0.0.0"/>
<unit id="org.dataflowanalysis.pcm.extension.model" version="0.0.0"/>
<unit id="org.dataflowanalysis.pcm.extension.nodecharacteristics" version="0.0.0"/>
<repository location="https://dataflowanalysis.github.io/updatesite/release/pcm-dataflowanalysis-extension/v5.2.1/"/>
<repository location="https://dataflowanalysis.github.io/updatesite/release/pcm-dataflowanalysis-extension/v5.2.2/"/>
</location>
<location includeAllPlatforms="false" includeConfigurePhase="true" includeMode="planner" includeSource="false" type="InstallableUnit">
<unit id="org.palladiosimulator.mdsdprofiles.api" version="0.0.0"/>
<repository location="https://updatesite.palladio-simulator.com/palladio-supporting-mdsdprofiles/nightly/"/>
<unit id="org.palladiosimulator.mdsdprofiles.api" version="5.2.2"/>
<repository location="https://updatesite.palladio-simulator.com/palladio-supporting-mdsdprofiles/releases/5.2.2/"/>
</location>
<location includeAllPlatforms="false" includeConfigurePhase="true" includeMode="planner" includeSource="false" type="InstallableUnit">
<unit id="org.hamcrest.library" version="0.0.0"/>
Expand Down Expand Up @@ -113,7 +113,7 @@
</location>

<location includeAllPlatforms="false" includeConfigurePhase="true" includeMode="planner" includeSource="false" type="InstallableUnit">
<repository location="https://updatesite.mdsd.tools/ecore-workflow/releases/latest/"/>
<repository location="https://updatesite.mdsd.tools/ecore-workflow/releases/1.0.0/"/>
<unit id="tools.mdsd.ecoreworkflow.mwe2lib.feature.feature.group" version="0.0.0"/>
</location>
<location includeAllPlatforms="false" includeConfigurePhase="true" includeMode="planner" includeSource="false" type="InstallableUnit">
Expand All @@ -128,7 +128,7 @@
<unit id="org.palladiosimulator.branding.feature.feature.group" version="2.0.0"/>
<unit id="org.palladiosimulator.license.feature.group" version="1.0.0"/>
<unit id="org.palladiosimulator.license.epl2.feature.group" version="1.0.0"/>
<repository location="https://updatesite.palladio-simulator.com/palladio-supporting-branding/nightly/"/>
<repository location="https://updatesite.palladio-simulator.com/palladio-supporting-branding/releases/5.2.2/"/>
</location>

<location includeAllPlatforms="false" includeConfigurePhase="true" includeMode="planner" includeSource="false" type="InstallableUnit">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,7 @@ void evaluateCost(String model, int variant) throws Exception {
satConstraint.add(c);
}

int baseCost = new ModelCostCalculator(dfd, satConstraint, minCosts)
.calculateCostWithoutForwarding();
var baseCostCalculator = new ModelCostCalculator(loadDFD(model, name), satConstraint, minCosts);

MitigationApproach approach = getApproach(dfd, constraints);

Expand All @@ -166,10 +165,9 @@ void evaluateCost(String model, int variant) throws Exception {

assertEquals(0, violationsAfter);

int repairedCost = new ModelCostCalculator(repairedDFD, satConstraint, minCosts)
.calculateCostWithoutForwarding();
var repairedCostCalculator = new ModelCostCalculator(repairedDFD, satConstraint, minCosts);

int approachCost = repairedCost - baseCost;
int approachCost = repairedCostCalculator.calculateSymmetricDifferenceCost(baseCostCalculator);

ObjectMapper mapper = new ObjectMapper();
Path out = Path.of("testresults/" + getApproachName().toLowerCase() + "_efficiency_results.json");
Expand All @@ -181,6 +179,23 @@ void evaluateCost(String model, int variant) throws Exception {

existing.add(new CostResult(model, variant, approachCost));
mapper.writerWithDefaultPrettyPrinter().writeValue(out.toFile(), existing);

if(getApproachName().equals("SAT")) {
Comment thread
uuqjz marked this conversation as resolved.
var tuhhBaseCostCalculator = new ModelCostCalculator(loadDFD(model, name), satConstraint, minCosts);
var tuhhRepairedCostCalculator = new ModelCostCalculator(loadDFD(model, model + "_" + variant), satConstraint, minCosts);
var tuhhCost = tuhhRepairedCostCalculator.calculateSymmetricDifferenceCost(tuhhBaseCostCalculator);

mapper = new ObjectMapper();
out = Path.of("testresults/tuhh_efficiency_results.json");

existing = Files.exists(out)
? mapper.readValue(out.toFile(), new TypeReference<List<CostResult>>() {
})
: new ArrayList<>();

existing.add(new CostResult(model, variant, tuhhCost));
mapper.writerWithDefaultPrettyPrinter().writeValue(out.toFile(), existing);
}

}

Expand Down
Loading
Loading