urdar
Class BString

java.lang.Object
  extended by urdar.BString

public class BString
extends java.lang.Object

The BString class represents the bit strings on which the organisms feed. Each bit string is characterised by its binary sequence, length and metabolic history (i.e. the species which it has been metabolised by). * @author Philip Gerlee


Field Summary
 java.util.Vector<java.lang.Integer> H
          The metabolic history of the string
 int length
          The length of the string
 boolean[] S
          The bit sequence
 
Constructor Summary
BString(boolean[] S)
          Creates a string from a given bit sequence
BString(boolean[] S, java.util.Vector<java.lang.Integer> H)
          Creates a string from a given bit sequence and metabolic history
BString(int size, double E, int mode)
          Creates a string with a given length of certain type with bitflips
 
Method Summary
 double blockEntropy(int level)
          Calculates the block entropy of string B
 BString change(int rule)
          Applies a Cellular Automaton rule to the string once and returns the modified string
 BString cloneString()
          Deep-copy of the string
 double deltaE(BString S0, int L)
          Calculates difference in entropy between this string and and another string
 double Entropy(int level)
          Calculates the approximation of the entropy S of a string B
 boolean equals(BString Si)
          Compares two strings
 boolean get(int i)
          Returns bit at position i
 double getFraction()
          Returns the fraction of ones in the string
 java.util.Vector<java.lang.Integer> getHistory()
          Returns metabolic history
 void manipulate(int rule)
          Applies a Cellular Automaton rule to the string once
 void printString()
          Prints the string to Std.out
 void radiate(double rate)
          Induce random bitflips, not really used
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

length

public int length
The length of the string


S

public boolean[] S
The bit sequence


H

public java.util.Vector<java.lang.Integer> H
The metabolic history of the string

Constructor Detail

BString

public BString(boolean[] S)
Creates a string from a given bit sequence

Parameters:
S - The bit sequence

BString

public BString(boolean[] S,
               java.util.Vector<java.lang.Integer> H)
Creates a string from a given bit sequence and metabolic history

Parameters:
S - The bit sequence
H - metabolic history

BString

public BString(int size,
               double E,
               int mode)
Creates a string with a given length of certain type with bitflips

Parameters:
size - String length
E - Bitflip probability
mode - Different string modes:
0 (default) = Bitflips on repeated 0-strings and 1-strings.
1 = Bitflips on repeated ...111111... pattern.
2 = Bitflips on repeated ...01010101... pattern.
3 = Bitflips on repeated ...011011011... pattern.
4 = Bitflips on repeated ...011101110111... pattern.
Method Detail

get

public boolean get(int i)
Returns bit at position i

Parameters:
i - position along the string
Returns:
bit at position i

getHistory

public java.util.Vector<java.lang.Integer> getHistory()
Returns metabolic history

Returns:
the metabolic history as a Vector of Integers representing the species that have metabolised the string

printString

public void printString()
Prints the string to Std.out


radiate

public void radiate(double rate)
Induce random bitflips, not really used

Parameters:
rate - probability of bitflip

getFraction

public double getFraction()
Returns the fraction of ones in the string

Returns:
the fraction of 1s in the string

manipulate

public void manipulate(int rule)
Applies a Cellular Automaton rule to the string once

Parameters:
rule - the CA-rule applied to the string

change

public BString change(int rule)
Applies a Cellular Automaton rule to the string once and returns the modified string

Parameters:
rule - the CA-rule applied to the string
Returns:
the modified string

cloneString

public BString cloneString()
Deep-copy of the string

Returns:
copy of the string

equals

public boolean equals(BString Si)
Compares two strings

Returns:
true if the two strings have the same bit sequence, false otherwise

Entropy

public double Entropy(int level)
Calculates the approximation of the entropy S of a string B

Parameters:
level - the level at which the entropy is calculated
Returns:
the approximate entropy, i.e. S(B) ≈ SL+1(B) - SL(B), where SL is the block entropy of length L

blockEntropy

public double blockEntropy(int level)
Calculates the block entropy of string B

Parameters:
level - the level at which the block entropy is calculated
Returns:
the block entropy SL(B) = - Σ p(σn) log p(σn)

deltaE

public double deltaE(BString S0,
                     int L)
Calculates difference in entropy between this string and and another string

Parameters:
S0 - the string with which the difference is calculated
L - the level of entropy calculation
Returns:
the entropy difference E(S) - E(S0) between the two strings