use of org.vcell.util.graphlayout.ContainedGraph.Node in project vcell by virtualcell.
the class WerewolfMinimizer method minimize.
public void minimize(EnergySum energySum) {
ContainedGraph graph = energySum.getGraph();
NodesShift.Default nodesShift = new NodesShift.Default(graph);
for (int iIteration = 0; iIteration < nIterations; ++iIteration) {
double absShiftMax = 0;
for (Node node : graph.getNodes()) {
double shiftX = ContainedGraphUtil.getRandomShiftX(node, random);
double shiftY = ContainedGraphUtil.getRandomShiftY(node, random);
nodesShift.getShifts().put(node, new Vector2D(shiftX, shiftY));
double absShiftX = Math.abs(shiftX);
if (absShiftX > absShiftMax) {
absShiftMax = absShiftX;
}
double absShiftY = Math.abs(shiftY);
if (absShiftY > absShiftMax) {
absShiftMax = absShiftY;
}
}
while (absShiftMax > 0.3) {
for (Map.Entry<Node, Vector2D> entry : nodesShift.getShifts().entrySet()) {
Vector2D vShift = entry.getValue();
vShift.x *= (1 - cut);
vShift.y *= (1 - cut);
}
if (energySum.getDifference(nodesShift) < 0) {
nodesShift.apply();
break;
}
absShiftMax *= (1 - cut);
}
}
}
Aggregations