Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
droplet-sequence-generator
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pedatestcontrib
droplet-sequence-generator
Commits
1d3f86a8
Commit
1d3f86a8
authored
7 years ago
by
Peter Wagenhuber
Browse files
Options
Downloads
Patches
Plain Diff
funtkion pathOnlyContainsDefaults getestet
parent
1b9d40d6
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/Nloc.java
+106
-6
106 additions, 6 deletions
src/Nloc.java
src/SequenceTuple.java
+10
-0
10 additions, 0 deletions
src/SequenceTuple.java
src/TestNloc.java
+43
-34
43 additions, 34 deletions
src/TestNloc.java
with
159 additions
and
40 deletions
src/Nloc.java
+
106
−
6
View file @
1d3f86a8
...
...
@@ -28,13 +28,24 @@ public class Nloc {
// while adding header droplets that only have paths with default channels
// at bifurcations
// the list representing the sequence //
List
<
Droplet
>
dropletSequence
=
null
;
Pump
pump
=
this
.
getPump
();
// get the payload path
List
<
Channel
>
pathlist
=
this
.
getAllPaths
();
List
<
Channel
>
moduleChanList
=
this
.
getModulesByName
(
Arrays
.
asList
(
modulesToVisit
));
List
<
Channel
>
payloadPath
=
this
.
getDesiredPath
(
moduleChanList
,
pathlist
);
List
<
List
<
Channel
>>
pathlist
=
this
.
getAllPaths
();
List
<
Channel
>
moduleChanList
=
null
;
List
<
Channel
>
payloadPath
=
null
;
try
{
moduleChanList
=
this
.
getModulesByName
(
Arrays
.
asList
(
modulesToVisit
));
payloadPath
=
this
.
getDesiredPath
(
moduleChanList
,
pathlist
);
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
e
.
getMessage
());
System
.
exit
(
1
);
}
// set up initial list of sequence tuples
Droplet
payloadDroplet
=
new
Droplet
(
DropletType
.
PAYLOAD
,
"p"
);
SequenceTuple
payldTuple
=
new
SequenceTuple
(
payloadDroplet
,
payloadPath
,
0
,
0
);
Channel
previousBifurcation
=
payldTuple
.
getPreviousBifurcation
();
payldTuple
.
setCurrentBifurcation
(
previousBifurcation
);
...
...
@@ -55,12 +66,91 @@ public class Nloc {
Channel
bifurcSuccessor
=
payloadPath
.
get
(
payloadPath
.
indexOf
(
currentBifurcation
)
+
1
);
Channel
bifurcationDefaultPath
=
currentBifurcation
.
getChildrenList
().
get
(
0
);
// bifurcation priority: prio = 0 if default channel; prio >= 1 if not
// default and threrfore header droplet needed
int
prio
=
currentBifurcation
.
getChildrenList
().
indexOf
(
bifurcSuccessor
);
if
(
prio
>
0
)
{
// we need a header droplet
// get list of all possible header paths
List
<
List
<
Channel
>>
possibleHeaderPathlist
=
this
.
getAllPathsFromTo
(
pump
,
bifurcationDefaultPath
);
// find header droplets with only default pahts
List
<
SequenceTuple
>
headersWithDefaultPaths
=
new
ArrayList
<
SequenceTuple
>();
for
(
List
<
Channel
>
path:
possibleHeaderPathlist
)
{
if
(
this
.
pathOnlyContainsDefaults
(
path
))
{
String
randHeaderName
=
"h-"
+
ThreadLocalRandom
.
current
().
nextInt
(
1000
,
10000
);
SequenceTuple
tmpTuple
=
new
SequenceTuple
(
new
Droplet
(
DropletType
.
HEADER
,
randHeaderName
),
path
,
currentBifurcation
);
headersWithDefaultPaths
.
add
(
tmpTuple
);
// calculate and set pump offsets
List
<
Channel
>
payloadPathToCurrentBifurcation
=
payloadPath
.
subList
(
0
,
payloadPath
.
indexOf
(
currentBifurcation
));
int
pathLenPayloadDroplet
=
this
.
getPayloadPathlength
(
payloadPathToCurrentBifurcation
);
int
maxPathLenNewDroplet
=
getHeaderPathlength
(
path
);
int
minPathLenNewDroplet
=
maxPathLenNewDroplet
-
bifurcationDefaultPath
.
getHSteps
()
+
1
;
int
newTupleMinPos
=
minPathLenNewDroplet
-
pathLenPayloadDroplet
;
int
newTupleMaxPos
=
maxPathLenNewDroplet
-
pathLenPayloadDroplet
;
tmpTuple
.
setMinPos
(
newTupleMinPos
);
tmpTuple
.
setMaxPos
(
newTupleMaxPos
);
}
}
if
(
headersWithDefaultPaths
.
isEmpty
())
{
// if no header with default path is found empty sequencetuple list
// and stop the search
s1
.
clear
();
suitableHeaderFound
=
false
;
}
else
{
int
oldSeqTupListLen
=
s1
.
size
();
for
(
SequenceTuple
hstup:
headersWithDefaultPaths
)
{
if
(!
SequenceTuple
.
conflictingOffsets
(
hstup
,
s1
))
{
s1
.
add
(
hstup
);
}
}
}
}
else
{
// no header needed just ascend to next bifurcation
payldTuple
.
setCurrentBifurcation
(
payldTuple
.
getPreviousBifurcation
());
}
}
while
(
suitableHeaderFound
&&
!(
plt
.
getCurrentBifurcation
()
instanceof
Pump
));
!(
payldTuple
.
getCurrentBifurcation
()
instanceof
Pump
));
if
(!
s1
.
isEmpty
())
{
int
min
=
0
,
max
=
0
;
for
(
SequenceTuple
stl:
s1
)
{
int
tmp
=
stl
.
getMinPos
();
if
(
tmp
>
max
)
max
=
tmp
;
if
(
tmp
<
min
)
min
=
tmp
;
}
int
span
=
max
-
min
;
pump
.
setSteps
(
span
);
s1
=
setTuplePumpoffsetToPumpPosition
(
s1
,
min
);
dropletSequence
=
generateDropletListRecursive
(
new
ArrayList
<
Droplet
>(),
s1
,
s1
.
get
(
0
).
getMinPos
());
}
return
dropletSequence
;
}
public
List
<
Droplet
>
getShortestSequenceExhaustive
(
String
[]
modulesToVisit
)
{
...
...
@@ -71,7 +161,7 @@ public class Nloc {
List
<
SequenceTuple
>
currentSeq
;
try
{
possibleSequences
=
getPossibleSequencesExhaus
i
tve
(
modulesToVisit
);
possibleSequences
=
getPossibleSequencesExhaust
i
ve
(
modulesToVisit
);
// sort the list of possible sequences according to the sequences length
possibleSequences
.
sort
((
a
,
b
)
->
a
.
size
()
-
b
.
size
());
...
...
@@ -120,6 +210,16 @@ public class Nloc {
return
dropletSequence
;
}
public
boolean
pathOnlyContainsDefaults
(
List
<
Channel
>
path
)
{
boolean
onlyDefaults
=
true
;
for
(
Channel
ch:
path
)
{
if
(
ch
.
isBifurcation
())
{
onlyDefaults
&=
path
.
contains
(
ch
.
getChildrenList
().
get
(
0
));
}
}
return
onlyDefaults
;
}
public
void
setDropletList
(
List
<
Droplet
>
dropletList
)
{
this
.
dropletList
=
dropletList
;
}
...
...
This diff is collapsed.
Click to expand it.
src/SequenceTuple.java
+
10
−
0
View file @
1d3f86a8
...
...
@@ -43,6 +43,16 @@ public class SequenceTuple {
this
.
currentBifuraction
=
stup
.
getCurrentBifurcation
();
}
public
static
boolean
conflictingOffsets
(
SequenceTuple
stup
,
List
<
SequenceTuple
>
stl
)
{
boolean
conflict
=
false
;
for
(
SequenceTuple
tmp:
stl
)
{
conflict
|=
(
stup
.
getMinPos
()
==
tmp
.
getMinPos
())
&&
(
stup
.
getMaxPos
()
==
tmp
.
getMaxPos
());
}
return
conflict
;
}
public
int
getMinPos
()
{
return
minPos
;
}
...
...
This diff is collapsed.
Click to expand it.
src/TestNloc.java
+
43
−
34
View file @
1d3f86a8
...
...
@@ -10,47 +10,56 @@ public class TestNloc {
public
static
void
main
(
String
[]
args
)
{
List
<
Channel
>
chList
=
getNlocS
3
();
//getNlocSXX();
List
<
Channel
>
chList
=
getNlocS
XX
();
//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.getPossibleSequencesExhaustive(mtv);
// //printSequences(stll);
//} catch (Exception e) {
// e.printStackTrace();
//}
//List<Droplet> drlist = nl.getShortestSequenceExhaustive(mtv);
//printDropletSequence(drlist);
//printPumpcontents(p);
for
(
List
<
Channel
>
path:
allPaths
)
{
String
[]
mtv
=
{
"h0"
,
"d0"
,
"m2"
,
"m3"
};
String
[]
modulesToVisit
=
extractModuleStringArrayFromPath
(
path
);
System
.
out
.
println
(
"Pathnum: "
+
count
++);
System
.
out
.
println
(
"Modules to visit: "
);
for
(
String
str:
modulesToVisit
)
{
System
.
out
.
print
(
str
+
" "
);
}
System
.
out
.
println
(
""
);
try
{
List
<
List
<
SequenceTuple
>>
stll
=
nl
.
getPossibleSequencesExhaustive
(
modulesToVisit
);
//printSequences(stll);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
List
<
Droplet
>
drlist
=
nl
.
getShortestSequenceExhaustive
(
modulesToVisit
);
printDropletSequence
(
drlist
);
try
{
List
<
Channel
>
ptt
=
nl
.
getDesiredPath
(
nl
.
getModulesByName
(
Arrays
.
asList
(
mtv
)),
allPaths
);
System
.
out
.
println
(
"only defaults: "
+
nl
.
pathOnlyContainsDefaults
(
ptt
));
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
e
.
getMessage
());
}
//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.getPossibleSequencesExhaustive(mtv);
//// //printSequences(stll);
////} catch (Exception e) {
//// e.printStackTrace();
////}
////List<Droplet> drlist = nl.getShortestSequenceExhaustive(mtv);
////printDropletSequence(drlist);
////printPumpcontents(p);
//for (List<Channel> path: allPaths) {
// String[] modulesToVisit = extractModuleStringArrayFromPath(path);
// System.out.println("Pathnum: " + count++);
// System.out.println("Modules to visit: ");
// for (String str: modulesToVisit) {
// System.out.print(str + " " );
// }
// System.out.println("");
// try {
// List<List<SequenceTuple>> stll = nl.getPossibleSequencesExhaustive(modulesToVisit);
// //printSequences(stll);
// } catch (Exception e) {
// e.printStackTrace();
// }
// List<Droplet> drlist = nl.getShortestSequenceExhaustive(modulesToVisit);
// printDropletSequence(drlist);
//}
}
public
static
void
printDropletSequence
(
List
<
Droplet
>
drList
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment