change frequency of garbage collection requests
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import org.jgrapht.Graphs;
|
||||||
import org.jgrapht.alg.interfaces.MatchingAlgorithm;
|
import org.jgrapht.alg.interfaces.MatchingAlgorithm;
|
||||||
import org.jgrapht.alg.matching.MaximumWeightBipartiteMatching;
|
import org.jgrapht.alg.matching.MaximumWeightBipartiteMatching;
|
||||||
import org.jgrapht.graph.DefaultWeightedEdge;
|
import org.jgrapht.graph.DefaultWeightedEdge;
|
||||||
@@ -147,15 +148,22 @@ public class Simulator implements GraphModificationFunctions {
|
|||||||
vertexLabelValue++;
|
vertexLabelValue++;
|
||||||
}
|
}
|
||||||
betaVertices.forEach(graph::addVertex);
|
betaVertices.forEach(graph::addVertex);
|
||||||
//add edges
|
//add edges (best so far)
|
||||||
|
int edgesAddedCount = 0;
|
||||||
for(Vertex a: alphaVertices) {
|
for(Vertex a: alphaVertices) {
|
||||||
|
Set<Integer> a_wells = a.getRecord().getWells();
|
||||||
for(Vertex b: betaVertices) {
|
for(Vertex b: betaVertices) {
|
||||||
Set<Integer> sharedWells = new HashSet<>(a.getRecord().getWells());
|
Set<Integer> sharedWells = new HashSet<>(a_wells);
|
||||||
sharedWells.retainAll(b.getRecord().getWells());
|
sharedWells.retainAll(b.getRecord().getWells());
|
||||||
double weight = (double) sharedWells.size();
|
if (!sharedWells.isEmpty()) {
|
||||||
if (weight != 0.0) {
|
Graphs.addEdge(graph, a, b, (double) sharedWells.size());
|
||||||
DefaultWeightedEdge edge = graph.addEdge(a, b);
|
}
|
||||||
graph.setEdgeWeight(edge, weight);
|
edgesAddedCount++;
|
||||||
|
if (edgesAddedCount % 10000000 == 0) { //collect garbage every 10,000,000 edges
|
||||||
|
System.out.println(edgesAddedCount + " edges added");
|
||||||
|
//request garbage collection
|
||||||
|
System.gc();
|
||||||
|
System.out.println("Garbage collection requested");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user