001 /*
002 * SimuCS - Simulator to use with Classifier Systems
003 * MSc project - Oxford University
004 * by Benoit Isaac - Summer 2005
005 */
006
007 package simuLCS;
008
009 /**
010 * Parameters used by our ZCS.
011 * A few lines of code (random number generator) below draw inspiration from the freely available XCSJava
012 * by Martin V. Butz
013 * @author Benoit, Martin V. Butz
014 *
015 */
016 public class ZCSConfig{
017 /**
018 * Specifies the maximal number classifiers in the population.
019 */
020 final public static int maxPopSize = 40;
021
022 /**
023 * The portion of strength a classifier should give to the bucket
024 */
025 final public static double beta = 0.1;
026
027 /**
028 * The portion of the bucket redistributed
029 */
030 final public static double gamma = 0.60;
031
032
033 /**
034 * The GA periodicity
035 */
036 final public static double theta_GA = 100;
037
038 /**
039 * The probability of applying crossover in an offspring classifier.
040 */
041 final public static double pX = 0.8;
042
043 /**
044 * The probability of mutating one bit in a classifier generated by the GA.
045 */
046 final public static double pM = 0.1;
047
048 /**
049 * The probability of using a don't care symbol in a bit when covering.
050 */
051 final public static double P_dontcare = 0.3;
052
053
054 /**
055 * The initial strength value when generating a new classifier
056 */
057 final public static double strengthIni = 5000;
058
059 /**
060 * The don't care symbol
061 */
062 final public static char dontCare = '#';
063
064 /**
065 * The initialization of the pseudo random generator. Must be at lest one and smaller than _M.
066 */
067 private static long seed = 1;
068
069 /**
070 * Constant for the random number generator (modulus of PMMLCG = 2^31 -1).
071 */
072 final private static long _M = 2147483647;
073
074 /**
075 * Constant for the random number generator (default = 16807).
076 */
077
078 final private static long _A = 16807;
079 /**
080 * Constant for the random number generator (=_M/_A).
081 */
082
083 final private static long _Q = _M / _A;
084 /**
085 * Constant for the random number generator (=_M mod _A).
086 */
087 final private static long _R = _M % _A;
088
089
090 public ZCSConfig()
091 {
092 }
093
094 /**
095 * Sets a random seed in order to randomize the pseudo random generator.
096 */
097 public static void setSeed(long s) {
098 seed = s;
099 }
100
101 /**
102 * Returns a random number in between zero and one.
103 */
104 public static double drand() {
105 long hi = seed / _Q;
106 long lo = seed % _Q;
107 long test = _A * lo - _R * hi;
108
109 if (test > 0)
110 seed = test;
111 else
112 seed = test + _M;
113
114 return (double) (seed) / _M;
115 }
116 }