jaga.experiment
Class ExperimentLib

java.lang.Object
  |
  +--jaga.experiment.ExperimentLib

public abstract class ExperimentLib
extends java.lang.Object

Provides common functionality used by many Experiment imlementations.


Constructor Summary
ExperimentLib()
           
 
Method Summary
static SampleData[] bitsToSampleDatas(int[][] bits, int dataLength)
          Generates an array of SampleDatas from the positions of 1s and their lengths
static SampleData[] generateCompleteShuffledTest(int nrInputs)
           
static SampleData[] generateCompleteShuffledTest(int nrInputs, long seed)
           
static SampleData[] generateCompleteTest(int nrInputs)
           
static SampleData[] generateCompleteTest(int nrInputs, int sampleSeparation)
          Not sure why allow to change inputSampleSep - to use as pattern directly
static SampleData[] generateInputFromTest(BitSet[] fixedTestBits, double fixedTestProportion, int inputDataLength, int inputSampleSeparation)
          given a set of fixed tests we wish to send as inputs to an individual it generates the inputs of the desired length by repeating these tests and then filling the rest with random inputs.
static double getCorrelationFitness(double tsetup, int inputSamples, int inputSampleSeparation, BitSet desQ, BitSet actQ)
           
static double getCorrelationFitness(double tsetup, int inputSamples, int inputSampleSeparation, BitSet desQ, BitSet actQ, int ignoredTests)
          Wrapper version for BitSets
static double getCorrelationFitness(double tsetup, int inputSamples, int inputSampleSeparation, double[] desQ, double[] actQ)
          Wrapper for getCorrelationFitness with default ignoredTests = 0
static double getCorrelationFitness(double tsetup, int inputSamples, int inputSampleSeparation, double[] desQ, double[] actQ, int ignoredTests)
          Given what the output should have been and what it was returns fitness value based on their correlation.
static double getCorrelationFitness(double tsetup, int inputSamples, int inputSampleSeparation, int[] desQ, int[] actQ)
          Wrapper version for arrays of ints
static double getSimpleCorrFitness(double tsetup, int inputSamples, int inputSampleSeparation, BitSet desQ, BitSet Q)
          Simplification of correlation function for boolean series.
static double getSumFitness(double tsetup, int inputSamples, int inputSampleSeparation, BitSet Q, BitSet desQ)
           
static void setRandomSeed(long seed)
           
static BitSet[] shuffleTest(BitSet[] test)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExperimentLib

public ExperimentLib()
Method Detail

setRandomSeed

public static void setRandomSeed(long seed)

getSimpleCorrFitness

public static double getSimpleCorrFitness(double tsetup,
                                          int inputSamples,
                                          int inputSampleSeparation,
                                          BitSet desQ,
                                          BitSet Q)
Simplification of correlation function for boolean series. Uses covariance W(X,Y) = E(XY)-E(X)E(Y). Now define W'(XY)=|X| * E'(XY) - E'(X) E'(Y), where |X| is the length of the series, E'(XY) is number of times both are 1 in the data series, and E'(X) is the number of 1s in the series. W'(XY) makes the same decision (of < or > corr) as true correlation fitness for random series >90% of cases.

getSumFitness

public static double getSumFitness(double tsetup,
                                   int inputSamples,
                                   int inputSampleSeparation,
                                   BitSet Q,
                                   BitSet desQ)

getCorrelationFitness

public static double getCorrelationFitness(double tsetup,
                                           int inputSamples,
                                           int inputSampleSeparation,
                                           double[] desQ,
                                           double[] actQ)
Wrapper for getCorrelationFitness with default ignoredTests = 0

getCorrelationFitness

public static double getCorrelationFitness(double tsetup,
                                           int inputSamples,
                                           int inputSampleSeparation,
                                           double[] desQ,
                                           double[] actQ,
                                           int ignoredTests)
Given what the output should have been and what it was returns fitness value based on their correlation.
Parameters:
tsetup - setup time allowed for output to stabilize.
inputSamples - how many input samples there were.
inputSampleSeparation - how often the input changed, counted in output samples. Note outputSamples = inputSamples * inputSampleSeparation.
desQ - the desired (perfect) output.
actQ - the actual output whose fitness we want to evaluate.
ignoredTests - number of tests of length inputSampleSeparation which will be ignored from the beginning.

getCorrelationFitness

public static double getCorrelationFitness(double tsetup,
                                           int inputSamples,
                                           int inputSampleSeparation,
                                           BitSet desQ,
                                           BitSet actQ)

getCorrelationFitness

public static double getCorrelationFitness(double tsetup,
                                           int inputSamples,
                                           int inputSampleSeparation,
                                           BitSet desQ,
                                           BitSet actQ,
                                           int ignoredTests)
Wrapper version for BitSets

getCorrelationFitness

public static double getCorrelationFitness(double tsetup,
                                           int inputSamples,
                                           int inputSampleSeparation,
                                           int[] desQ,
                                           int[] actQ)
Wrapper version for arrays of ints

bitsToSampleDatas

public static SampleData[] bitsToSampleDatas(int[][] bits,
                                             int dataLength)
Generates an array of SampleDatas from the positions of 1s and their lengths

generateCompleteTest

public static SampleData[] generateCompleteTest(int nrInputs)

generateCompleteTest

public static SampleData[] generateCompleteTest(int nrInputs,
                                                int sampleSeparation)
Not sure why allow to change inputSampleSep - to use as pattern directly

generateCompleteShuffledTest

public static SampleData[] generateCompleteShuffledTest(int nrInputs,
                                                        long seed)

generateCompleteShuffledTest

public static SampleData[] generateCompleteShuffledTest(int nrInputs)

shuffleTest

public static BitSet[] shuffleTest(BitSet[] test)

generateInputFromTest

public static SampleData[] generateInputFromTest(BitSet[] fixedTestBits,
                                                 double fixedTestProportion,
                                                 int inputDataLength,
                                                 int inputSampleSeparation)
given a set of fixed tests we wish to send as inputs to an individual it generates the inputs of the desired length by repeating these tests and then filling the rest with random inputs. We can vary the proportion of all test data that will be based on these fixed tests, the rest is randomized.
Parameters:
fixedTestBits - array of BitSets holding test data
fixedTestProportion - double varying from 0 to 1 indicating what proportion of input samples to fill in with the fixed test. 0=>all random, 1=>as many fixed tests as fit
inputDataLength - how many inputs to generate
inputSampleSeparation - what sample separation to create the inputs with