Search in sources :

Example 11 with Node

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);
        }
    }
}
Also used : Vector2D(org.vcell.util.geometry2d.Vector2D) NodesShift(org.vcell.util.graphlayout.NodesShift) Node(org.vcell.util.graphlayout.ContainedGraph.Node) ContainedGraph(org.vcell.util.graphlayout.ContainedGraph) Map(java.util.Map)

Aggregations

Node (org.vcell.util.graphlayout.ContainedGraph.Node)11 Container (org.vcell.util.graphlayout.ContainedGraph.Container)5 ContainedGraph (org.vcell.util.graphlayout.ContainedGraph)2 Edge (org.vcell.util.graphlayout.ContainedGraph.Edge)2 NodesShift (org.vcell.util.graphlayout.NodesShift)2 ReactionRuleDiagramShape (cbit.vcell.graph.ReactionRuleDiagramShape)1 ReactionStepShape (cbit.vcell.graph.ReactionStepShape)1 RuleParticipantSignatureDiagramShape (cbit.vcell.graph.RuleParticipantSignatureDiagramShape)1 SpeciesContextShape (cbit.vcell.graph.SpeciesContextShape)1 Dimension (java.awt.Dimension)1 Point (java.awt.Point)1 Rectangle (java.awt.Rectangle)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 SetOfTwo (org.sbpax.util.sets.SetOfTwo)1 ListOfTwo (org.vcell.sybil.util.lists.ListOfTwo)1 Vector2D (org.vcell.util.geometry2d.Vector2D)1 EnergyTerm (org.vcell.util.graphlayout.energybased.EnergySum.EnergyTerm)1