Commit c4e95b45 authored by Peter Wagenhuber's avatar Peter Wagenhuber
Browse files

backtracking mal zum testen bereit. testcases gehoeren noch geschrieben

parent 2e72c27b
......@@ -141,6 +141,9 @@ public class Nloc {
}
int span = max - min;
pump.setSteps(span);
possibleSequences = setTuplePumpoffsetToPumpPosition(possibleSequences,
min);
List<Droplet> dropletSequence = generateDropletListRecursive(new ArrayList<Droplet>(), currentSeq, currentSeq.get(0).getMinPos());
......@@ -152,6 +155,21 @@ public class Nloc {
return pump;
}
public List<List<SequenceTuple>> setTuplePumpoffsetToPumpPosition(
List<List<SequenceTuple>> possibleSequences, int minOffset) {
for (List<SequenceTuple> stl: possibleSequences) {
for (SequenceTuple stup: stl) {
int pumpOffsetMin = stup.getMinPos();
stup.setMinPos(pumpOffsetMin + Math.abs(minOffset));
int pumpOffsetMax = stup.getMaxPos();
stup.setMaxPos(pumpOffsetMax + Math.abs(minOffset));
}
}
return possibleSequences;
}
private List<Droplet> generateDropletListRecursive(
List<Droplet> dropletList, List<SequenceTuple> currentSequence,
int currentPos) {
......@@ -167,6 +185,8 @@ public class Nloc {
Droplet tmpDr = tmpTup.getDroplet();
tmpDr.setPosition(new Position(this.getPump(), currentPos));
Channel pumpOutlet = tmpTup.getPumpOutlet();
tmpDr.setPumpOutlet(pumpOutlet);
dropletList.add(tmpDr);
// set current pos to minimum of the following sequence tuple
......@@ -184,10 +204,28 @@ public class Nloc {
return generateDropletListRecursive(dropletList, currentSequence,
currentPos);
} else {
return null;
ListIterator<Droplet> revIter = dropletList.listIterator(
dropletList.size());
boolean found = false;
while (!found && revIter.hasPrevious()) {
Droplet tmpDr = revIter.previous();
revIter.remove();
SequenceTuple tmpTup1 = currentSequence.get(dropletList.size() - 1);
if (tmpDr.getPosition().getSteps() == currentPos &&
currentPos < tmpTup1.getMaxPos()) {
found = true;
}
}
if (found) {
currentPos++;
return generateDropletListRecursive(dropletList, currentSequence,
currentPos);
} else {
return dropletList;
}
}
//Droplet tmpDr = dropletList.get(dropletList.size() - 1);
//if (currentPos <= tmpDr
}
}
}
......
......@@ -53,4 +53,15 @@ public class SequenceTuple {
public void setPath(List<Channel> path) {
this.path = path;
}
public Channel getPumpOutlet() {
Channel outlet = null;
for (Channel ch: path) {
if (ch.getParents().size() == 1 &&
ch.getParents().get(0) instanceof Pump) {
outlet = ch;
}
}
return outlet;
}
}
Supports Markdown
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