Changeset 14510
- Timestamp:
- 12/20/16 14:30:06 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.ExpressionGenerator/HeuristicLab.ExpressionGenerator/3.4/ExpressionGenerator.cs
r14505 r14510 39 39 productTemplate.AddArguments(variables); 40 40 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? 44 42 int i = 1; 45 43 46 44 var logTemplate = new FixedArityTemplate(Log, 1) { Label = "log" }; 47 45 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))); 49 47 50 48 var expTemplate = new FixedArityTemplate(Exp, 1) { Label = "exp" }; 51 49 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))); 53 51 54 var inverseTemplate = new FixedArityTemplate(Division, 1) ;52 var inverseTemplate = new FixedArityTemplate(Division, 1) { Label = "/" }; 55 53 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))); 61 58 62 59 var template = new RandomArityTemplate(Sum, new UniformDistributedRandom(uniformRandom, 2, count)) { Label = "+" };
Note: See TracChangeset
for help on using the changeset viewer.