Commit 1b9d40d6 authored by Peter Wagenhuber's avatar Peter Wagenhuber
Browse files

started default path haeder heurstics implementaition

parent c3a4deb0
......@@ -21,7 +21,49 @@ public class Nloc {
this.dropletList = new ArrayList<Droplet>();
}
public List<Droplet> getShortestSequence(String[] modulesToVisit) {
public List<Droplet>
getShortestSequenceOnlyDefaultPathHeader(String [] modulesToVisit) {
// start at last bifrucation of payload droplet and move up all bifurcatons
// while adding header droplets that only have paths with default channels
// at bifurcations
// get the payload path
List<Channel> pathlist = this.getAllPaths();
List<Channel> moduleChanList =
this.getModulesByName(Arrays.asList(modulesToVisit));
List<Channel> payloadPath = this.getDesiredPath(moduleChanList, pathlist);
// set up initial list of sequence tuples
SequenceTuple payldTuple = new SequenceTuple(payloadDroplet,payloadPath,0,0);
Channel previousBifurcation = payldTuple.getPreviousBifurcation();
payldTuple.setCurrentBifurcation(previousBifurcation);
List<SequenceTuple> s1 = new ArrayList<SequenceTuple>();
s1.add(payldTuple);
/* while still bifurcatins to cover (bifurcation not pump) ascend along
* the path of bifurcations of payload droplet and add header droplets
* that only take default paths at bifurcations
* if no header droplet found that only takes default paths stop and
* return empty list droplets indicating no suitable sequence found
*/
boolean suitableHeaderFound = true;
do {
Channel currentBifurcation = payldTuple.getCurrentBifurcation();
// check if header droplet needed
Channel bifurcSuccessor =
payloadPath.get(payloadPath.indexOf(currentBifurcation) + 1);
// bifurcation priority: prio = 0 if default channel; prio >= 1 if not
// default and threrfore header droplet needed
int prio = currentBifurcation.getChildrenList().indexOf(bifurcSuccessor);
} while (suitableHeaderFound &&
!(plt.getCurrentBifurcation() instanceof Pump));
}
public List<Droplet> getShortestSequenceExhaustive(String[] modulesToVisit) {
Pump pump = this.getPump();
List<List<SequenceTuple>> possibleSequences;
......@@ -29,7 +71,7 @@ public class Nloc {
List<SequenceTuple> currentSeq;
try {
possibleSequences = getPossibleSequences(modulesToVisit);
possibleSequences = getPossibleSequencesExhausitve(modulesToVisit);
// sort the list of possible sequences according to the sequences length
possibleSequences.sort((a,b) -> a.size() - b.size());
......@@ -167,7 +209,7 @@ public class Nloc {
}
}
public List<List<SequenceTuple>> getPossibleSequences(
public List<List<SequenceTuple>> getPossibleSequencesExhaustive(
String[] modulesToVisit) throws NoSuchModuleException {
Droplet payloadDroplet = new Droplet(DropletType.PAYLOAD,"p");
......
......@@ -23,12 +23,12 @@ public class TestNloc {
//String[] mtv = { "f2", "m3", "m0", "m5"}; //old S2 problem
//try {
// List<List<SequenceTuple>> stll = nl.getPossibleSequences(mtv);
// List<List<SequenceTuple>> stll = nl.getPossibleSequencesExhaustive(mtv);
// //printSequences(stll);
//} catch (Exception e) {
// e.printStackTrace();
//}
//List<Droplet> drlist = nl.getShortestSequence(mtv);
//List<Droplet> drlist = nl.getShortestSequenceExhaustive(mtv);
//printDropletSequence(drlist);
//printPumpcontents(p);
......@@ -43,12 +43,12 @@ public class TestNloc {
}
System.out.println("");
try {
List<List<SequenceTuple>> stll = nl.getPossibleSequences(modulesToVisit);
List<List<SequenceTuple>> stll = nl.getPossibleSequencesExhaustive(modulesToVisit);
//printSequences(stll);
} catch (Exception e) {
e.printStackTrace();
}
List<Droplet> drlist = nl.getShortestSequence(modulesToVisit);
List<Droplet> drlist = nl.getShortestSequenceExhaustive(modulesToVisit);
printDropletSequence(drlist);
}
}
......
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