Changeset 14510


Ignore:
Timestamp:
12/20/16 14:30:06 (4 years ago)
Author:
bburlacu
Message:

#2704: Minor changes (sample template arguments without repetition)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.ExpressionGenerator/HeuristicLab.ExpressionGenerator/3.4/ExpressionGenerator.cs

    r14505 r14510  
    3939      productTemplate.AddArguments(variables);
    4040
    41 
    42       //      var count = (int)Enumerable.Range(1, variables.Length).Sum(x => EnumerableExtensions.BinomialCoefficient(x, variables.Length));
    43       var count = 10;
     41      const int count = 10; // how many instances of each template should be produce?
    4442      int i = 1;
    4543
    4644      var logTemplate = new FixedArityTemplate(Log, 1) { Label = "log" };
    4745      logTemplate.AddArguments(variables);
    48       logTemplate.AddArguments(Enumerable.Range(1, count).Select(x => sumTemplate.Instantiate(string.Format("sum{0}", i++), uniformRandom, true)));
     46      logTemplate.AddArguments(Enumerable.Range(1, count).Select(x => sumTemplate.Instantiate(string.Format("sum{0}", i++), uniformRandom)));
    4947
    5048      var expTemplate = new FixedArityTemplate(Exp, 1) { Label = "exp" };
    5149      expTemplate.AddArguments(variables);
    52       expTemplate.AddArguments(Enumerable.Range(1, count).Select(x => productTemplate.Instantiate(string.Format("prod{0}", i++), uniformRandom, true)));
     50      expTemplate.AddArguments(Enumerable.Range(1, count).Select(x => productTemplate.Instantiate(string.Format("prod{0}", i++), uniformRandom)));
    5351
    54       var inverseTemplate = new FixedArityTemplate(Division, 1);
     52      var inverseTemplate = new FixedArityTemplate(Division, 1) { Label = "/" };
    5553      inverseTemplate.AddArguments(variables);
    56       inverseTemplate.AddArguments(Enumerable.Range(1, count).Select(x => sumTemplate.Instantiate(string.Format("sum{0}", i++), uniformRandom, true)));
    57       inverseTemplate.AddArguments(Enumerable.Range(1, count).Select(x => productTemplate.Instantiate(string.Format("prod{0}", i++), uniformRandom, true)));
    58       inverseTemplate.AddArguments(Enumerable.Range(1, count).Select(x => logTemplate.Instantiate(string.Format("log{0}", i++), uniformRandom, true)));
    59       inverseTemplate.AddArguments(Enumerable.Range(1, count).Select(x => expTemplate.Instantiate(string.Format("exp{0}", i++), uniformRandom, true)));
    60 
     54      inverseTemplate.AddArguments(Enumerable.Range(1, count).Select(x => sumTemplate.Instantiate(string.Format("sum{0}", i++), uniformRandom)));
     55      inverseTemplate.AddArguments(Enumerable.Range(1, count).Select(x => productTemplate.Instantiate(string.Format("prod{0}", i++), uniformRandom)));
     56      inverseTemplate.AddArguments(Enumerable.Range(1, count).Select(x => logTemplate.Instantiate(string.Format("log{0}", i++), uniformRandom)));
     57      inverseTemplate.AddArguments(Enumerable.Range(1, count).Select(x => expTemplate.Instantiate(string.Format("exp{0}", i++), uniformRandom)));
    6158
    6259      var template = new RandomArityTemplate(Sum, new UniformDistributedRandom(uniformRandom, 2, count)) { Label = "+" };
Note: See TracChangeset for help on using the changeset viewer.