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

jetzt sollt alles soweit stimmen - die performance sickt aber gewaltig

parent 83025f7e
......@@ -21,11 +21,11 @@ public class Nloc {
this.dropletList = new ArrayList<Droplet>();
}
public Pump getShortestSequence(String[] modulesToVisit) {
public List<Droplet> getShortestSequence(String[] modulesToVisit) {
Pump pump = this.getPump();
List<List<SequenceTuple>> possibleSequences;
List<Droplet> dropletSequence;
List<Droplet> dropletSequence = null;
List<SequenceTuple> currentSeq;
try {
......@@ -37,7 +37,16 @@ public class Nloc {
pump.removeAllDroplets();
currentSeq = possibleSequences.remove(0);
//System.out.println("Working on sequence");
//for (SequenceTuple stup: currentSeq) {
// if (currentSeq.indexOf(stup) == (currentSeq.size() - 1)) {
// System.out.print(stup.getDroplet().getName() + ": " + stup.getMinPos() + ":" + stup.getMaxPos() + " : " + stup.getPath().get(1).getName());
// } else {
// System.out.print(stup.getDroplet().getName() + ": " + stup.getMinPos() + ":" + stup.getMaxPos() + " : " + stup.getPath().get(1).getName() + " -> ");
// }
//}
//System.out.println("\n");
int min = 0, max = 0;
for (SequenceTuple stl: currentSeq) {
int tmp = stl.getMinPos();
......@@ -51,13 +60,13 @@ public class Nloc {
dropletSequence = generateDropletListRecursive(new ArrayList<Droplet>(), currentSeq, currentSeq.get(0).getMinPos());
//currentSeq = resetPayloadDropletPosition(currentSeq);
currentSeq = resetPayloadDropletPosition(currentSeq);
} while (!possibleSequences.isEmpty() &&
dropletSequence.size() != currentSeq.size() &&
!this.sequenceFunctinal());
!(dropletSequence.size() == currentSeq.size() &&
this.sequenceFunctional()));
if (dropletSequence.size() != currentSeq.size()) {
pump = null;
dropletSequence.clear();
}
......@@ -65,7 +74,8 @@ public class Nloc {
System.out.println(nsme.getMessage());
System.exit(1);
}
return pump;
return dropletSequence;
}
public void setDropletList(List<Droplet> dropletList) {
......@@ -215,16 +225,14 @@ public class Nloc {
return pump;
}
public boolean sequenceFunctinal() {
this.dropletList = this.getPump().getDropletList();
public boolean sequenceFunctional() {
boolean works = true;
while (!allDropletsInSink()) {
//for(int i = 0; i < 10; i++) {
try {
this.moveDroplets();
} catch (CoalescedDropletException e) {
works = false;
System.out.println("Coalesce! Droplet: " + e.getDroplet().getName() + " Position: " + e.getDroplet().getPosition().getChannel().getName());
//System.out.println("Coalesce! Droplet: " + e.getDroplet().getName() + " Position: " + e.getDroplet().getPosition().getChannel().getName());
break;
}
}
......
......@@ -10,13 +10,28 @@ public class TestNloc {
public static void main(String[] args) {
List<Channel> chList = getNlocS2(); //getNlocSXX();
List<Channel> chList = getNlocS3(); //getNlocSXX();
Nloc nl = new Nloc(chList);
List<List<Channel>> allPaths = nl.getAllPaths();
int count = 0;
//
//String[] mtv = { m2 d1 m4 h2 m1 d5}; // S3 problem
//String[] mtv = { "f2", "m3", "h0", "m5"}; //old S2 problem
//String[] mtv = { "f2", "m3", "m0", "m5"}; //old S2 problem
//try {
// List<List<SequenceTuple>> stll = nl.getPossibleSequences(mtv);
// //printSequences(stll);
//} catch (Exception e) {
// e.printStackTrace();
//}
//List<Droplet> drlist = nl.getShortestSequence(mtv);
//printDropletSequence(drlist);
//printPumpcontents(p);
for (List<Channel> path: allPaths) {
String[] modulesToVisit = extractModuleStringArrayFromPath(path);
......@@ -29,12 +44,28 @@ public class TestNloc {
System.out.println("");
try {
List<List<SequenceTuple>> stll = nl.getPossibleSequences(modulesToVisit);
printSequences(stll);
//printSequences(stll);
} catch (Exception e) {
e.printStackTrace();
}
Pump p = nl.getShortestSequence(modulesToVisit);
printPumpcontents(p);
List<Droplet> drlist = nl.getShortestSequence(modulesToVisit);
printDropletSequence(drlist);
}
}
public static void printDropletSequence(List<Droplet> drList) {
if (drList.isEmpty()) {
System.out.println("No Sequence Found");
} else {
for (Droplet dr: drList) {
System.out.print("Droplet: " + dr.getName() + " Pos: " + dr.getPosition().getSteps() + " Outlet: " + dr.getPumpOutlet().getName());
if (drList.indexOf(dr) == drList.size() - 1) {
System.out.println("");
} else {
System.out.print(" ||| ");
}
}
System.out.println("");
}
}
......
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