diff --git a/.idea/libraries/jheaps.xml b/.idea/libraries/jheaps.xml
new file mode 100644
index 0000000..2783e46
--- /dev/null
+++ b/.idea/libraries/jheaps.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/out/artifacts/TCellSim_jar/TCellSim.jar b/out/artifacts/TCellSim_jar/TCellSim.jar
index a397aa9..e6c75de 100644
Binary files a/out/artifacts/TCellSim_jar/TCellSim.jar and b/out/artifacts/TCellSim_jar/TCellSim.jar differ
diff --git a/src/main/java/Plate.java b/src/main/java/Plate.java
index 32d6ceb..37601b6 100644
--- a/src/main/java/Plate.java
+++ b/src/main/java/Plate.java
@@ -51,7 +51,7 @@ public class Plate {
//n = Equations.getRandomNumber(0, cells.size());
// was testing generating the cell sample file with exponential dist, then sampling flat here
//that would be more realistic
- //But would mess up my
+ //But would mess up other things in the simulation with how I've coded it.
if(n > test){
test = n;
}
diff --git a/src/main/java/Simulator.java b/src/main/java/Simulator.java
index e645252..0471e1b 100644
--- a/src/main/java/Simulator.java
+++ b/src/main/java/Simulator.java
@@ -4,13 +4,18 @@ import org.jgrapht.alg.matching.MaximumWeightBipartiteMatching;
import org.jgrapht.generate.SimpleWeightedBipartiteGraphMatrixGenerator;
import org.jgrapht.graph.DefaultWeightedEdge;
import org.jgrapht.graph.SimpleWeightedGraph;
+import org.jheaps.AddressableHeap;
+import org.jheaps.tree.PairingHeap;
import java.math.BigDecimal;
+import java.math.BigInteger;
import java.math.MathContext;
import java.text.NumberFormat;
import java.time.Instant;
import java.time.Duration;
import java.util.*;
+import java.util.function.Function;
+import java.util.function.Supplier;
import java.util.stream.IntStream;
public class Simulator {
@@ -158,19 +163,26 @@ public class Simulator {
Map alphaWellCounts = new HashMap<>();
//count how many wells each beta appears in
Map betaWellCounts = new HashMap<>();
+ //the adjacency matrix to be used by the graph generator
double[][] weights = new double[plateVtoAMap.size()][plateVtoBMap.size()];
-
countPeptidesAndFillMatrix(samplePlate, allAlphas, allBetas, plateAtoVMap,
plateBtoVMap, alphaIndex, betaIndex, alphaWellCounts, betaWellCounts, weights);
if(verbose){System.out.println("matrix created");}
+ /**
+ * This is where the bipartite graph is created
+ */
if(verbose){System.out.println("creating graph");}
+ //the graph object
SimpleWeightedGraph graph =
new SimpleWeightedGraph<>(DefaultWeightedEdge.class);
+ //the graph generator
SimpleWeightedBipartiteGraphMatrixGenerator graphGenerator = new SimpleWeightedBipartiteGraphMatrixGenerator();
+ //the list of alpha vertices
List alphaVertices = new ArrayList<>();
alphaVertices.addAll(plateVtoAMap.keySet()); //This will work because LinkedHashMap preserves order of entry
graphGenerator.first(alphaVertices);
+ //the list of beta vertices
List betaVertices = new ArrayList<>();
betaVertices.addAll(plateVtoBMap.keySet());
graphGenerator.second(betaVertices); //This will work because LinkedHashMap preserves order of entry
@@ -183,9 +195,24 @@ public class Simulator {
if(verbose){System.out.println("Over- and under-weight edges set to 0.0");}
+ /**
+ * This is where the maximum weighted matching is found
+ */
+// if(verbose){System.out.println("Finding maximum weighted matching");}
+// MaximumWeightBipartiteMatching maxWeightMatching =
+// new MaximumWeightBipartiteMatching(graph, plateVtoAMap.keySet(), plateVtoBMap.keySet());
+// MatchingAlgorithm.Matching graphMatching = maxWeightMatching.getMatching();
+// if(verbose){System.out.println("Matching completed");}
+// Instant stop = Instant.now();
+
+ //trying with jheaps now
if(verbose){System.out.println("Finding maximum weighted matching");}
+ //Attempting to use addressable heap to improve performance
MaximumWeightBipartiteMatching maxWeightMatching =
- new MaximumWeightBipartiteMatching(graph, plateVtoAMap.keySet(), plateVtoBMap.keySet());
+ new MaximumWeightBipartiteMatching(graph,
+ plateVtoAMap.keySet(),
+ plateVtoBMap.keySet(),
+ (i) -> new PairingHeap(Comparator.naturalOrder()));
MatchingAlgorithm.Matching graphMatching = maxWeightMatching.getMatching();
if(verbose){System.out.println("Matching completed");}
Instant stop = Instant.now();
@@ -660,10 +687,15 @@ public class Simulator {
private static Map invertVertexMap(Map map) {
Map inverse = new HashMap<>();
- for(Integer k: map.keySet()) {
+ for (Integer k : map.keySet()) {
inverse.put(map.get(k), k);
}
return inverse;
}
+ private static int bigDecimalComparator(BigDecimal bd, Integer i) {
+ return bd.compareTo(BigDecimal.valueOf(i));
+ }
+
+
}
diff --git a/src/main/java/UserInterface.java b/src/main/java/UserInterface.java
index 9c559c5..0265f6e 100644
--- a/src/main/java/UserInterface.java
+++ b/src/main/java/UserInterface.java
@@ -16,6 +16,12 @@ public class UserInterface {
public static void main(String[] args) {
if(args.length != 0){
+ //These command line options are a big mess
+ //Really, I don't think command line tools are expected to work in this many different modes
+ //making cells, making plates, and matching are the sort of thing that UNIX philosophy would say
+ //should be three separate programs.
+ //There might be a way to do it with option parameters?
+
Options mainOptions = new Options();
Option makeCells = Option.builder("cells")
.longOpt("make-cells")