private void UpdateGrammar()
        {
            var g = new SimpleSymbolicExpressionGrammar();

            g.AddSymbols(new[] { "AND", "OR" }, 2, 2); // See Koza 1992, page 171, section 7.4.1 11-multiplexer
            g.AddSymbols(new[] { "NOT" }, 1, 1);
            g.AddSymbols(new[] { "IF" }, 3, 3);

            // find the number of address lines and input lines
            // e.g. 11-MUX: 3 addrBits + 8 input bits

            var addrBits  = (int)Math.Log(NumberOfBits, 2); // largest power of two that fits into the number of bits
            var inputBits = NumberOfBits - addrBits;

            for (int i = 0; i < addrBits; i++)
            {
                g.AddTerminalSymbol(string.Format("a{0}", i));
            }
            for (int i = 0; i < inputBits; i++)
            {
                g.AddTerminalSymbol(string.Format("d{0}", i));
            }

            Encoding.Grammar = g;

            BestKnownQuality = Math.Pow(2, NumberOfBits); // this is a benchmark problem (the best achievable quality is known for a given number of bits)
        }
Beispiel #2
0
    public Problem()
      : base() {
      BoolMatrix world = new BoolMatrix(ToBoolMatrix(santaFeAntTrail));
      Parameters.Add(new ValueParameter<BoolMatrix>("World", "The world for the artificial ant with scattered food items.", world));
      Parameters.Add(new ValueParameter<IntValue>("MaximumTimeSteps", "The number of time steps the artificial ant has available to collect all food items.", new IntValue(600)));

      base.BestKnownQuality = 89;
      var g = new SimpleSymbolicExpressionGrammar();
      g.AddSymbols(new string[] { "IfFoodAhead", "Prog2" }, 2, 2);
      g.AddSymbols(new string[] { "Prog3" }, 3, 3);
      g.AddTerminalSymbols(new string[] { "Move", "Left", "Right" });
      base.Encoding = new SymbolicExpressionTreeEncoding(g, 20, 10);
      base.Encoding.GrammarParameter.ReadOnly = true;
    }
Beispiel #3
0
        private void UpdateGrammar()
        {
            // whenever ProblemData is changed we create a new grammar with the necessary symbols
            var g = new SimpleSymbolicExpressionGrammar();

            g.AddSymbols(new[] { "+", "*", "%", "-" }, 2, 2); // % is protected division 1/0 := 0

            foreach (var variableName in ProblemData.AllowedInputVariables)
            {
                g.AddTerminalSymbol(variableName);
            }

            // generate ephemeral random consts in the range [-10..+10[ (2*number of variables)
            var rand = new System.Random();

            for (int i = 0; i < ProblemData.AllowedInputVariables.Count() * 2; i++)
            {
                string newErcSy;
                do
                {
                    newErcSy = string.Format("{0:F2}", rand.NextDouble() * 20 - 10);
                } while (g.Symbols.Any(sy => sy.Name == newErcSy)); // it might happen that we generate the same constant twice
                g.AddTerminalSymbol(newErcSy);
            }

            Encoding.Grammar = g;
        }
        public GaussianProcessCovarianceOptimizationProblem()
            : base()
        {
            Parameters.Add(new ValueParameter <IRegressionProblemData>(ProblemDataParameterName, "The data for the regression problem", new RegressionProblemData()));
            Parameters.Add(new FixedValueParameter <IntValue>(ConstantOptIterationsParameterName, "Number of optimization steps for hyperparameter values", new IntValue(50)));
            Parameters.Add(new FixedValueParameter <IntValue>(RestartsParameterName, "The number of random restarts for constant optimization.", new IntValue(10)));
            Parameters["Restarts"].Hidden = true;
            var g = new SimpleSymbolicExpressionGrammar();

            g.AddSymbols(new string[] { "Sum", "Product" }, 2, 2);
            g.AddTerminalSymbols(new string[]
            {
                "Linear",
                "LinearArd",
                "MaternIso1",
                "MaternIso3",
                "MaternIso5",
                "NeuralNetwork",
                "Periodic",
                "PiecewisePolynomial0",
                "PiecewisePolynomial1",
                "PiecewisePolynomial2",
                "PiecewisePolynomial3",
                "Polynomial2",
                "Polynomial3",
                "RationalQuadraticArd",
                "RationalQuadraticIso",
                "SpectralMixture1",
                "SpectralMixture3",
                "SpectralMixture5",
                "SquaredExponentialArd",
                "SquaredExponentialIso"
            });
            base.Encoding = new SymbolicExpressionTreeEncoding(g, 10, 5);
        }
Beispiel #5
0
        public Problem()
            : base()
        {
            Parameters.Add(new FixedValueParameter <IntValue>(LawnWidthParameterName, "Width of the lawn.", new IntValue(8)));
            Parameters.Add(new FixedValueParameter <IntValue>(LawnLengthParameterName, "Length of the lawn.", new IntValue(8)));

            var g = new SimpleSymbolicExpressionGrammar();

            g.AddSymbols(new string[] { "Sum", "Prog" }, 2, 2);
            g.AddSymbols(new string[] { "Frog" }, 1, 1);
            g.AddTerminalSymbols(new string[] { "Left", "Forward" });
            // initialize 20 ephemeral random constants in [0..32[
            var fastRand = new FastRandom(314159);

            for (int i = 0; i < 20; i++)
            {
                g.AddTerminalSymbol(string.Format("{0},{1}", fastRand.Next(0, 32), fastRand.Next(0, 32)));
            }

            Encoding = new SymbolicExpressionTreeEncoding(g, 1000, 17);
        }
        private void UpdateGrammar()
        {
            var g = new SimpleSymbolicExpressionGrammar();

            g.AddSymbols(new[] { "AND", "OR", "NAND", "NOR" }, 2, 2); // see Koza, 1992, page 529 section 20.2 Symbolic Regression of Even-Parity Functions

            // add one terminal symbol for each bit
            for (int i = 0; i < NumberOfBits; i++)
            {
                g.AddTerminalSymbol(string.Format("{0}", i));
            }

            Encoding.Grammar = g;

            BestKnownQuality = Math.Pow(2, NumberOfBits); // this is a benchmark problem (the best achievable quality is known for a given number of bits)
        }