net.sourceforge.cilib.measurement
Class StateAwareMeasurement

java.lang.Object
  extended by net.sourceforge.cilib.measurement.StateAwareMeasurement
All Implemented Interfaces:
Externalizable, Serializable, Measurement, Cloneable

public abstract class StateAwareMeasurement
extends Object
implements Measurement, Externalizable

This class serves as the base class for all state based measurements. If a measurement is a complex structure that needs to be computed over a period of time (iterations / function evaluations etc), then the measurement should extend this class.

The MeasurementSuite is aware of instances of this class and will correctly handle any data recording and restoring that may be required as the measurements are performed on the current algorithm.

Author:
gpampara
See Also:
Serialized Form

Constructor Summary
StateAwareMeasurement()
           
 
Method Summary
 MeasurementMemento getState()
          Obtain a new externalised state from the current measurement.
 boolean isStateAware()
          Get the state awareness of the current measurement.
 void setState(MeasurementMemento memento)
          Set the state of the Measurement based on the provided instance.
 void setStateAware(boolean state)
          Set the state of the measurement.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.sourceforge.cilib.measurement.Measurement
getClone, getDomain, getValue
 
Methods inherited from interface java.io.Externalizable
readExternal, writeExternal
 

Constructor Detail

StateAwareMeasurement

public StateAwareMeasurement()
Method Detail

setStateAware

public void setStateAware(boolean state)
Set the state of the measurement. If this property is set, the measurement will then have it's internal state saved and restored each an everytime a measurement is to take place.

Parameters:
state - The state awareness value of this measurement class.

isStateAware

public boolean isStateAware()
Get the state awareness of the current measurement.

Returns:
The state awareness of the measurement.

setState

public void setState(MeasurementMemento memento)
              throws IOException,
                     ClassNotFoundException
Set the state of the Measurement based on the provided instance.

Parameters:
memento - The instance containing the externalised state.
Throws:
IOException - If an IO error occours.
ClassNotFoundException - If a specified class cannot be found.

getState

public MeasurementMemento getState()
                            throws IOException
Obtain a new externalised state from the current measurement. This state is maintained in a MeasurementMemento and is returned as an immutable object.

Returns:
The externalised state within a MeasurementMemento
Throws:
IOException - If an IO error occours.


Copyright © 2009 CIRG. All Rights Reserved.