hu.birot.OTKit.performance
Class Temperature

java.lang.Object
  extended by hu.birot.OTKit.performance.Temperature

public class Temperature
extends java.lang.Object

This class, actually a data type, represents "temperature", as it is used in simulated annealing. It can take several type: at the moment, it is either a real value or a pair as defined for SA-OT.


Field Summary
 int counter
          This additional component of the temperature can be used to count the number of iterations.
 int counter1
          An additional counter that can be used to store information.
 int counter2
          An additional counter that can be used to store information.
 int iterations
          This field can be used to count the number of iterations that has been performed in total since the beginning of the random walk.
 Candidate output
          This field can be used to include information of type Candidate in the temperature.
 double range
          The first component of the temperature in SA-OT.
 double real
          The "real value" of temperature.
static java.lang.String RealTemperatureType
          This string is the value of Temperature.type for temperatures of type "real" (used in traditional simulated annealing with a real-valued target function).
static java.lang.String SAOTTemperatureType
          This string is the value of Temperature.type for temperatures of type "saot" (used in SA-OT).
 java.lang.String type
          This variable tells the type of temperature.
 int unmoved
          An additional counter that can be used to store information.
 
Constructor Summary
Temperature(double r)
          This constructor creates a new Temperature of type "real", with real value r.
Temperature(double k, double r)
          This constructor creates a new Temperature of type "saot", whose first component (range) is k, and whose second component is r.
 
Method Summary
 Temperature clone()
          This method creates a clone of the present temperature, with all their fields being equal.
 void copy(Temperature t)
          This method fills all the nine fields of a temperature (counter, counter1, counter2, iterations, output, range, real, type and unmoved) with the corresponding fields of temperature t.
 boolean equals(java.lang.Object t)
          This temperature is equal to object t if and only if: (1) t is also a temperature; (2) the two temperatures are of the same type; and (3) their value(s) are equal.
 java.lang.String toString()
          Convert a Temperature to a String.
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

type

public java.lang.String type

This variable tells the type of temperature. Its values can be:

  1. "real": for traditional simulated annealing or Harmony Grammar; then Temperature.real is used.
  2. "saot": for the SA-OT algorithm; then Temperature.range and Temperature.real are used.


RealTemperatureType

public static java.lang.String RealTemperatureType
This string is the value of Temperature.type for temperatures of type "real" (used in traditional simulated annealing with a real-valued target function).


SAOTTemperatureType

public static java.lang.String SAOTTemperatureType
This string is the value of Temperature.type for temperatures of type "saot" (used in SA-OT).


real

public double real
The "real value" of temperature. It is used as "the" temperature in traditional simulated annealing and in HG, and as the second component of the temperature in SA-OT. NB: it must be non-negative, otherwise you may get all kinds of exceptions by all kinds of algorithms.


range

public double range
The first component of the temperature in SA-OT.


counter

public int counter
This additional component of the temperature can be used to count the number of iterations. For instance, you may want to have k iterations with each value of the temperature: then you increase the counter without decreasing the temperature until the counter has not reached k.


counter1

public int counter1
An additional counter that can be used to store information.

See Also:
counter

counter2

public int counter2
An additional counter that can be used to store information.

See Also:
counter

unmoved

public int unmoved
An additional counter that can be used to store information. For instance, the number of times the algorithm has not moved.

See Also:
counter

iterations

public int iterations
This field can be used to count the number of iterations that has been performed in total since the beginning of the random walk.


output

public Candidate output
This field can be used to include information of type Candidate in the temperature.

In fact, this field is used as a trick so that random walks can return an output candidate, but also further information (number of iterations performed, final temperature, etc.). Therefore, random walks return an output of type Temperature, and not of type Candidate as they should, and so the field output of the returned temperature will contain the candidate actually returned as the output.

Constructor Detail

Temperature

public Temperature(double r)
This constructor creates a new Temperature of type "real", with real value r. Make sure r > 0. Field Temperature.unmoved is set to 0.

Parameters:
r - : The (real) value of the temperature.

Temperature

public Temperature(double k,
                   double r)
This constructor creates a new Temperature of type "saot", whose first component (range) is k, and whose second component is r. Make sure r > 0. Field Temperature.unmoved is set to 0.

Parameters:
k - : The first component of the SA-OT-style temperature to be created ("range").
r - : The second component of the SA-OT-style temperature to be created ("real part").
Method Detail

copy

public void copy(Temperature t)

This method fills all the nine fields of a temperature (counter, counter1, counter2, iterations, output, range, real, type and unmoved) with the corresponding fields of temperature t.

Parameters:
t - : The temperature whose fields are copied.

equals

public boolean equals(java.lang.Object t)

This temperature is equal to object t if and only if: (1) t is also a temperature; (2) the two temperatures are of the same type; and (3) their value(s) are equal. For temperatures of type "real", field real must be equal. For temperatures of type "saot", both fields real and range must be equal.

Note that the other fields (e.g. the counters, output, unmoved, iterations) of the two temperatures need not be equal in order to have equal temperatures.

Overrides java.lang.Object.equals.

Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()

Convert a Temperature to a String. Temperatures of type "saot" are converted in the form <range,real>, whereas Temperatures of type "real" are converted simply as (the decimal representation of) their real value.

This method overrides java.lang.Object.toString.

Overrides:
toString in class java.lang.Object
Returns:
A String representation of the Temperature.

clone

public Temperature clone()

This method creates a clone of the present temperature, with all their fields being equal.

This method overrides method java.lang.Object.clone. Note that in this new method the return type is Temperature, and not Object, as in the original one.

Overrides:
clone in class java.lang.Object