org.apache.java.recycle
Class GaussianController

java.lang.Object
  |
  +--org.apache.java.recycle.GaussianController

public class GaussianController
extends java.lang.Object
implements Controller

This is an adaptive controller based on a statistical analysis of the level transitions. The optimal level is derived from the variance of the transitions using the following equation:

   adaptiveLevel = bias + factor * standardDeviation   
where the standard deviation signifies the variability of level around its average.

This class creates a convergence of the system Container-Controller to a point in which the average level tends to its standard deviation. This creates a negative feedback that stabilizes the system.

NOTE: This class is only experimental and it is meant to show only a more complex implementation of a Controller. The routines that calculate the statistical parameters this class uses to determine the level use heavy calculations and should be used only when a very precise adaptivity is required.

Version:
$Revision: 1.3 $ $Date: 1999/06/24 00:50:49 $

Field Summary
private static int BIAS
          This is the minimum value allowed to be reached.
private  int cursor
          The cursor in the circular array.
private static int FACTOR
          This is multiplication factor for the standard deviation.
private  int level
          The current pool level.
private  int[] levels
          The array of pool levels.
private static int WINDOW
          This is the log2 value of the sampling window.
 
Constructor Summary
GaussianController()
           
 
Method Summary
 void down()
          Writes on the memory of this controller decrementing the level.
private  float getAverage(int[] array)
          Calculates the average value of a given array.
private  float getStandardDeviation(int[] array)
          Calculates the RMS value of a given array.
 boolean isThereRoomFor(Recyclable object)
          Evaluates the room for the object to recycle basing this decision to the optimum level estrapolated from the level history.
 void up()
          Writes on the memory of this controller incrementing the level.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

WINDOW

private static final int WINDOW
This is the log2 value of the sampling window.

BIAS

private static final int BIAS
This is the minimum value allowed to be reached.

FACTOR

private static final int FACTOR
This is multiplication factor for the standard deviation.

level

private int level
The current pool level.

levels

private int[] levels
The array of pool levels.

cursor

private int cursor
The cursor in the circular array.
Constructor Detail

GaussianController

public GaussianController()
Method Detail

up

public void up()
Writes on the memory of this controller incrementing the level.
Specified by:
up in interface Controller

down

public void down()
Writes on the memory of this controller decrementing the level.
Specified by:
down in interface Controller

isThereRoomFor

public boolean isThereRoomFor(Recyclable object)
Evaluates the room for the object to recycle basing this decision to the optimum level estrapolated from the level history.
Specified by:
isThereRoomFor in interface Controller

getStandardDeviation

private float getStandardDeviation(int[] array)
Calculates the RMS value of a given array.

getAverage

private float getAverage(int[] array)
Calculates the average value of a given array.