public class Energies extends Object
The main intended usage is with the various force layout algorithms that use a an "energy" minimization process to compute a layout. This class allows to store the energy at a current step of layout computation and to remember a history of such steps.
At a current step of layout computation, one can accumulate energy in the current
cell of the energies buffer using accumulateEnergy(double)
. When the step
finishes, one calls storeEnergy()
to store this accumulated energy in
a cell of the memory, push a new cell on the memory and therefore start a new step.
At any time you can get the last energy value computed with getEnergy()
.
Be careful this is not the energy currently accumulated but the value of the last
energy stored with storeEnergy()
. You can also get at any time the average
energy in the memory with getAverageEnergy()
, as well as an estimate of
the stabilization (how much the energies are varying) using getStabilization()
.
Modifier and Type | Field and Description |
---|---|
protected double[] |
energies
A circular array of the last values of energy.
|
protected int |
energiesBuffer
Memory.
|
protected int |
energiesPos
The current position in the energies array.
|
protected double |
energy
Global current energy (maybe actually updated).
|
protected double |
energySum
The sum of all memorized energies.
|
protected double |
lastEnergy
The last computed energy.
|
Constructor and Description |
---|
Energies() |
Modifier and Type | Method and Description |
---|---|
void |
accumulateEnergy(double value)
Accumulate some energy in the current energy cell.
|
protected void |
clearEnergies()
Randomize the energies array.
|
double |
getAverageEnergy()
The average energy in the whole buffer.
|
int |
getBufferSize()
The number of energy values remembered, the memory.
|
double |
getEnergy()
The last computed energy value.
|
double |
getPreviousEnergyValue(int stepsBack)
A previous energy value.
|
double |
getStabilization()
A number in [0..1] with 1 meaning fully stabilized.
|
void |
storeEnergy()
Add a the current accumulated energy value in the set.
|
protected double energy
protected double lastEnergy
protected int energiesBuffer
protected double[] energies
protected int energiesPos
protected double energySum
public Energies()
public double getEnergy()
public int getBufferSize()
public double getStabilization()
public double getAverageEnergy()
public double getPreviousEnergyValue(int stepsBack)
stepsBack
- The number of steps back in history. This number must not be larger than
the size of the memory (energy buffer) else it is set to this size.public void accumulateEnergy(double value)
value
- The value to accumulate to the current cell.public void storeEnergy()
protected void clearEnergies()
WebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses