Skip to content

Commit

Permalink
WiSe24 Embedded Survey hotfixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
soerendomroes committed Jun 27, 2024
1 parent 8216642 commit 50a6f5a
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,37 +37,40 @@ public void findNodes(int offset) {
}
LNode min = null;
LNode max = null;
int maxGroupModelOrder = 13;
int modelOrderMin = Integer.MAX_VALUE;
int modelOrderMax = Integer.MIN_VALUE;
int groupModelOrderMin = Integer.MAX_VALUE;
int groupModelOrderMax = Integer.MIN_VALUE;
for (LNode n : stronglyConnectedComponents.get(i)) {
// FIXME what is the layer mask? These are the group ids that are considered for this algorithm
// These have to be configurable!!
List<Integer> layermask = new LinkedList<Integer>();
layermask.add(1);
layermask.add(2);
layermask.add(3);
layermask.add(4);
layermask.add(5);
layermask.add(6);
layermask.add(7);
int groupID = n.getProperty(LayeredOptions.CONSIDER_MODEL_ORDER_GROUP_I_D);
if (!layermask.contains(groupID)) {
continue;
}
if (min == null || max == null) {
min = n;
modelOrderMin = computeConstraintModelOrder(n,offset);
groupModelOrderMin = computeConstraintGroupModelOrder(n, maxGroupModelOrder);
max = n;
modelOrderMax = modelOrderMin;
groupModelOrderMax = groupModelOrderMin;
continue;
}
int modelOrderCurrent = computeConstraintModelOrder(n, offset);
if (modelOrderMin > modelOrderCurrent) {
int groupModelOrderCurrent = computeConstraintGroupModelOrder(n, maxGroupModelOrder);
if (groupModelOrderMin < groupModelOrderCurrent) {
min = n;
groupModelOrderMin = groupModelOrderCurrent;
modelOrderMin = modelOrderCurrent;
}
else if(modelOrderMax < modelOrderCurrent) {
} else if (groupModelOrderMin == groupModelOrderCurrent) {
if (modelOrderMin > modelOrderCurrent) {
min = n;
modelOrderMin = modelOrderCurrent;
}
} else if (groupModelOrderMax == groupModelOrderCurrent) {
if (modelOrderMax < modelOrderCurrent) {
max = n;
modelOrderMax = modelOrderCurrent;
}
} else if (groupModelOrderMax > groupModelOrderCurrent) {
max = n;
groupModelOrderMax = groupModelOrderCurrent;
modelOrderMax = modelOrderCurrent;
}
}
Expand All @@ -89,4 +92,4 @@ else if(modelOrderMax < modelOrderCurrent) {
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,10 @@ public void findNodes(int offset) {
for (LNode n : stronglyConnectedComponents.get(i)) {
List<Integer> groupmask = new LinkedList<Integer>();
// FIXME this may not always work and should not be hard coded.
groupmask.add(1);
groupmask.add(4);
int groupID = n.getProperty(LayeredOptions.CONSIDER_MODEL_ORDER_GROUP_I_D);
if (!groupmask.contains(groupID)) {
continue;
}
// int groupID = n.getProperty(LayeredOptions.CONSIDER_MODEL_ORDER_GROUP_I_D);
// if (!groupmask.contains(groupID)) {
// continue;
// }
if (max == null) {
max = n;
maxModelOrder = computeConstraintModelOrder(n, offset);
Expand Down Expand Up @@ -177,6 +175,32 @@ protected int computeConstraintModelOrder(final LNode node, final int offset) {
return modelOrder;
}

protected int computeConstraintGroupModelOrder(final LNode node, final int offset) {
int modelOrder = 0;
switch (node.getProperty(LayeredOptions.LAYERING_LAYER_CONSTRAINT)) {
case FIRST_SEPARATE:
modelOrder = 2 * -offset + firstSeparateModelOrder;
firstSeparateModelOrder++;
break;
case FIRST:
modelOrder = -offset;
break;
case LAST:
modelOrder = offset;
break;
case LAST_SEPARATE:
modelOrder = 2 * offset + lastSeparateModelOrder;
lastSeparateModelOrder++;
break;
default:
break;
}
if (node.hasProperty(LayeredOptions.CONSIDER_MODEL_ORDER_GROUP_I_D)) {
modelOrder += node.getProperty(LayeredOptions.CONSIDER_MODEL_ORDER_GROUP_I_D);
}
return modelOrder;
}

private void TARJAN(final LGraph graph) {
index = 0;
stack = new Stack<LNode>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,33 +33,42 @@ public void findNodes(int offset) {
continue;
}
LNode min = null;
int maxGroupModelOrder = 13; // FIXME hardcoded
int modelOrderMin = Integer.MAX_VALUE;
int modelOrderMax = Integer.MIN_VALUE;
int groupModelOrderMin = Integer.MAX_VALUE;
int groupModelOrderMax = Integer.MIN_VALUE;

LNode max = null;
int modelOrderMax = Integer.MIN_VALUE;
for (LNode n : stronglyConnectedComponents.get(i)) {
List<Integer> layermask = new LinkedList<Integer>();
layermask.add(1);
layermask.add(4);
int groupID = n.getProperty(LayeredOptions.CONSIDER_MODEL_ORDER_GROUP_I_D);
if (!layermask.contains(groupID)) {
continue;
}
if (min == null && max == null) {
if (min == null || max == null) {
min = n;
modelOrderMin = computeConstraintModelOrder(n,offset);

groupModelOrderMin = computeConstraintGroupModelOrder(n, maxGroupModelOrder);
max = n;
modelOrderMax = computeConstraintModelOrder(n,offset);
modelOrderMax = modelOrderMin;
groupModelOrderMax = groupModelOrderMin;
continue;
}
int modelOrderCurrent = computeConstraintModelOrder(n, offset);
if (modelOrderMin > modelOrderCurrent) {
int groupModelOrderCurrent = computeConstraintGroupModelOrder(n, maxGroupModelOrder);
if (groupModelOrderMin < groupModelOrderCurrent) {
min = n;
groupModelOrderMin = groupModelOrderCurrent;
modelOrderMin = modelOrderCurrent;
}
else if (modelOrderMax < modelOrderCurrent) {
} else if (groupModelOrderMin == groupModelOrderCurrent) {
if (modelOrderMin > modelOrderCurrent) {
min = n;
modelOrderMin = modelOrderCurrent;
}
} else if (groupModelOrderMax == groupModelOrderCurrent) {
if (modelOrderMax < modelOrderCurrent) {
max = n;
modelOrderMax = modelOrderCurrent;
}
} else if (groupModelOrderMax > groupModelOrderCurrent) {
max = n;
groupModelOrderMax = groupModelOrderCurrent;
modelOrderMax = modelOrderCurrent;
}
}
Expand Down

0 comments on commit 50a6f5a

Please sign in to comment.