Commit 0e9fe450 authored by Peter Wagenhuber's avatar Peter Wagenhuber
Browse files

muss mal pause machen

parent 42c3e135
......@@ -169,7 +169,10 @@ public class Nloc {
this.getModulesByName(Arrays.asList(modulesToVisit));
List<Channel> payloadPath = this.getDesiredPath(moduleChanList, pathlist);
SequenceTuple plt = new SequenceTuple(payloadDroplet,payloadPath,0,0);
Channel previousBifurcation = plt.getPreviousBifurcation();
plt.setCurrentBifurcation(previousBifurcation);
List<SequenceTuple> s1 = new ArrayList<SequenceTuple>();
s1.add(plt);
......@@ -179,20 +182,25 @@ public class Nloc {
// actually compile list of sequences going through the bifurcations from
// "end" to "start"
for (int i = bifurcationList.size() - 1; i >= 0; --i) {
Channel currentBifurcation = bifurcationList.get(i);
//for (int i = bifurcationList.size() - 1; i >= 0; --i) {
//Channel currentBifurcation = bifurcationList.get(i);
List<List<SequenceTuple>> oldsequences;
do {
oldsequences = new ArrayList<List<SequenceTuple>>(sequences);
List<List<SequenceTuple>> tmpSeqs = new ArrayList<List<SequenceTuple>>();
for (List<SequenceTuple> stl: sequences) {
tmpSeqs.addAll(
this.getSequencesAtBifurcation(stl, currentBifurcation));
this.computeSequences(stl));
}
sequences = tmpSeqs;
}
} while (sequences.size() != oldsequences.size());
//}
} catch (Exception e) {
System.out.println( e.getMessage());
}
return sequences;
}
}
public void addChannel(Channel chan) {
chanlist.add(chan);
......@@ -365,22 +373,28 @@ public class Nloc {
}
}
public List<List<SequenceTuple>> getSequencesAtBifurcation(
List<SequenceTuple> seqTup, Channel currentBifurcation) {
public List<List<SequenceTuple>> computeSequences(List<SequenceTuple> seqTup){
//List<SequenceTuple> seqTup, Channel currentBifurcation) {
List<List<SequenceTuple>> seqTupList = new ArrayList<List<SequenceTuple>>();
SequenceTuple currentSeqTup = seqTup.get(0);
getSequencesAtBifurcationRecursive(seqTup, currentSeqTup, seqTupList,
currentBifurcation);
getSequencesAtBifurcationRecursive(seqTup, currentSeqTup, seqTupList);
return seqTupList;
}
private void getSequencesAtBifurcationRecursive(
List<SequenceTuple> seqTupList, SequenceTuple currentSeqTup,
List<List<SequenceTuple>> possibleSequences, Channel currentBifurcation) {
List<List<SequenceTuple>> possibleSequences) {
System.out.println("Working on: " + currentSeqTup + " Name: " + currentSeqTup.getDroplet().getName());
Channel currentBifurcation = currentSeqTup.getCurrentBifurcation();
currentSeqTup.setCurrentBifurcation(currentSeqTup.getPreviousBifurcation());
System.out.println("Current Bifurcation: " + currentBifurcation.getName());
// check if header droplet is needed
List<Channel> dropletPath = currentSeqTup.getPath();
......@@ -392,11 +406,13 @@ public class Nloc {
int prio = currentBifurcation.getChildrenList().indexOf(bifurcSuccessor);
if (currentSeqTup.equals(seqTupList.get(seqTupList.size() - 1))) {
System.out.println("At the last Sequence Tuple in List");
// if at last sequence tuple add another header droplet tuple if needed
// and add the list of sequence tuples to the possible sequences list
if (dropletPath.contains(currentBifurcation) && prio > 0) {
System.out.println("We need header droplets");
// we need header droplet
// cirst check all possible paths of header droplets
......@@ -407,9 +423,14 @@ public class Nloc {
for (List<Channel> path: pathList) {
List<SequenceTuple> tmp = new ArrayList<SequenceTuple>(seqTupList);
SequenceTuple tmpTuple =
new SequenceTuple(new Droplet(DropletType.HEADER,"h"),path);
new SequenceTuple(new Droplet(DropletType.HEADER,"h"),path,
currentBifurcation);
tmpTuple.setCurrentBifurcation(tmpTuple.getPreviousBifurcation());
System.out.println("Adding header droplet: " + tmpTuple.getDroplet() + " current Bifurc: " + tmpTuple.getCurrentBifurcation().getName());
tmp.add(tmpTuple);
// calculate and set pump offsets
int minPos = currentSeqTup.getMinPos();
int maxPos = currentSeqTup.getMaxPos();
......@@ -444,58 +465,64 @@ public class Nloc {
possibleSequences.add(seqTupList);
}
} else {
if (dropletPath.contains(currentBifurcation) && prio > 0) {
// we need header droplet
// cirst check all possible paths of header droplets
Channel defaultChan = currentBifurcation.getChildrenList().get(0);
List<List<Channel>> pathList =
this.getAllPathsFromTo(dropletPath.get(0), defaultChan);
for (List<Channel> path: pathList) {
List<SequenceTuple> tmp = new ArrayList<SequenceTuple>(seqTupList);
SequenceTuple tmpTuple =
new SequenceTuple(new Droplet(DropletType.HEADER,"h"),path);
tmp.add(seqTupList.indexOf(currentSeqTup) + 1, tmpTuple);
// calculate and set pump offsets
int minPos = currentSeqTup.getMinPos();
int maxPos = currentSeqTup.getMaxPos();
List<Channel> pathToCurrentBifurcation =
dropletPath.subList(0,dropletPath.indexOf(currentBifurcation) + 1);
int pathLenCurrDroplet = 0;
if (currentSeqTup.getDroplet().getType() == DropletType.HEADER) {
pathLenCurrDroplet = getHeaderPathlength(pathToCurrentBifurcation);
} else {
pathLenCurrDroplet = getPayloadPathlength(pathToCurrentBifurcation);
}
int maxPathLenNewDroplet = getHeaderPathlength(path);
int minPathLenNewDroplet =
maxPathLenNewDroplet - defaultChan.getHSteps() + 1;
//System.out.println("minPos: " + minPos + " pathLenCurrDroplet: " +
// pathLenCurrDroplet + " minPathLenNewDroplet: " + minPathLenNewDroplet);
int newTupleMinPos =
minPos - (pathLenCurrDroplet - minPathLenNewDroplet);
int newTupleMaxPos =
maxPos - (pathLenCurrDroplet - maxPathLenNewDroplet);
tmpTuple.setMinPos(newTupleMinPos);
tmpTuple.setMaxPos(newTupleMaxPos);
getSequencesAtBifurcationRecursive(tmp,
seqTupList.get(seqTupList.indexOf(currentSeqTup) + 1),
possibleSequences, currentBifurcation);
}
} else {
getSequencesAtBifurcationRecursive(seqTupList,
seqTupList.get(seqTupList.indexOf(currentSeqTup) + 1),
possibleSequences, currentBifurcation);
}
//if (dropletPath.contains(currentBifurcation) && prio > 0) {
// // we need header droplet
// // cirst check all possible paths of header droplets
// Channel defaultChan = currentBifurcation.getChildrenList().get(0);
// List<List<Channel>> pathList =
// this.getAllPathsFromTo(dropletPath.get(0), defaultChan);
// for (List<Channel> path: pathList) {
// List<SequenceTuple> tmp = new ArrayList<SequenceTuple>(seqTupList);
// SequenceTuple tmpTuple =
// new SequenceTuple(new Droplet(DropletType.HEADER,"h"),path,
// currentBifurcation);
// tmpTuple.setCurrentBifurcation(tmpTuple.getPreviousBifurcation());
// tmp.add(seqTupList.indexOf(currentSeqTup) + 1, tmpTuple);
// // calculate and set pump offsets
// int minPos = currentSeqTup.getMinPos();
// int maxPos = currentSeqTup.getMaxPos();
// List<Channel> pathToCurrentBifurcation =
// dropletPath.subList(0,dropletPath.indexOf(currentBifurcation) + 1);
// int pathLenCurrDroplet = 0;
// if (currentSeqTup.getDroplet().getType() == DropletType.HEADER) {
// pathLenCurrDroplet = getHeaderPathlength(pathToCurrentBifurcation);
// } else {
// pathLenCurrDroplet = getPayloadPathlength(pathToCurrentBifurcation);
// }
// int maxPathLenNewDroplet = getHeaderPathlength(path);
// int minPathLenNewDroplet =
// maxPathLenNewDroplet - defaultChan.getHSteps() + 1;
// //System.out.println("minPos: " + minPos + " pathLenCurrDroplet: " +
// // pathLenCurrDroplet + " minPathLenNewDroplet: " + minPathLenNewDroplet);
// int newTupleMinPos =
// minPos - (pathLenCurrDroplet - minPathLenNewDroplet);
// int newTupleMaxPos =
// maxPos - (pathLenCurrDroplet - maxPathLenNewDroplet);
// tmpTuple.setMinPos(newTupleMinPos);
// tmpTuple.setMaxPos(newTupleMaxPos);
// getSequencesAtBifurcationRecursive(tmp,
// seqTupList.get(seqTupList.indexOf(currentSeqTup) + 1),
// possibleSequences);
// }
//} else {
// SequenceTuple nextSeqTup =
// seqTupList.get(seqTupList.indexOf(currentSeqTup) + 1);
// getSequencesAtBifurcationRecursive(seqTupList, nextSeqTup,
// possibleSequences);
//}
}
}
}
package nloc;
import java.util.List;
import java.util.ArrayList;
public class SequenceTuple {
......@@ -7,12 +8,23 @@ public class SequenceTuple {
private Droplet droplet;
private int minPos, maxPos;
private List<Channel> path;
private Channel currentBifuraction;
public SequenceTuple(Droplet droplet, List<Channel> path) {
this.minPos = 0;
this.maxPos = 0;
this.droplet = droplet;
this.path = path;
this.currentBifuraction = null;
}
public SequenceTuple(Droplet droplet, List<Channel> path,
Channel currentBifuraction) {
this.minPos = 0;
this.maxPos = 0;
this.droplet = droplet;
this.path = path;
this.currentBifuraction = currentBifuraction;
}
public SequenceTuple(Droplet droplet, List<Channel> path, int minPos, int maxPos) {
......@@ -20,6 +32,7 @@ public class SequenceTuple {
this.maxPos = maxPos;
this.droplet = droplet;
this.path = path;
this.currentBifuraction = null;
}
public int getMinPos() {
......@@ -54,6 +67,35 @@ public class SequenceTuple {
this.path = path;
}
public void setCurrentBifurcation(Channel currentBifuraction) {
this.currentBifuraction = currentBifuraction;
}
public Channel getCurrentBifurcation() {
return currentBifuraction;
}
public Channel getPreviousBifurcation() {
Channel prevBifurc = null;
List<Channel> bfList = new ArrayList<Channel>();
for (Channel ch: this.path) {
if (ch instanceof Pump) {
bfList.add(ch);
}
if (ch.isBifurcation()) {
bfList.add(ch);
}
}
if (this.currentBifuraction == null) {
prevBifurc = bfList.get(bfList.size() - 1);
} else if (!(this.currentBifuraction instanceof Pump)) {
prevBifurc = bfList.get(bfList.indexOf(this.currentBifuraction) - 1);
} else {
prevBifurc = this.currentBifuraction;
}
return prevBifurc;
}
public Channel getPumpOutlet() {
Channel outlet = null;
for (Channel ch: path) {
......
......@@ -55,7 +55,7 @@ public class TestNloc {
//}
//printPaths(allPaths);
String[] mtv = {"h0", "m2", "m3"};
String[] mtv = {"h0", "m2", "m1", "m3"};
try {
List<List<SequenceTuple>> stll = nl.getPossibleSequences(mtv);
printSequences(stll);
......
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